#[repr(C)]pub struct Allocator {
pub ctx: *mut c_void,
pub vtable: *const AllocatorVtable,
}Expand description
Custom memory allocator.
For functions that take an allocator pointer, a NULL pointer indicates that the default allocator should be used. The default allocator will be libc malloc/free if we’re linking to libc. If libc isn’t linked, a custom allocator is used (currently Zig’s SMP allocator).
Usage example: GhosttyAllocator allocator = { .vtable = &my_allocator_vtable, .ctx = my_allocator_state };
Fields§
§ctx: *mut c_voidOpaque context pointer passed to all vtable functions. This allows the allocator implementation to maintain state or reference external resources needed for memory management.
vtable: *const AllocatorVtablePointer to the allocator’s vtable containing function pointers for memory operations (alloc, resize, remap, free).
Trait Implementations§
Auto Trait Implementations§
impl !Send for Allocator
impl !Sync for Allocator
impl Freeze for Allocator
impl RefUnwindSafe for Allocator
impl Unpin for Allocator
impl UnsafeUnpin for Allocator
impl UnwindSafe for Allocator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more