#[repr(C)]pub struct GhosttyAllocator {
pub ctx: *mut c_void,
pub vtable: *const GhosttyAllocatorVtable,
}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).
@ingroup allocator
Usage example: @code GhosttyAllocator allocator = { .vtable = &my_allocator_vtable, .ctx = my_allocator_state }; @endcode
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 GhosttyAllocatorVtablePointer to the allocator’s vtable containing function pointers for memory operations (alloc, resize, remap, free).
Trait Implementations§
Source§impl Clone for GhosttyAllocator
impl Clone for GhosttyAllocator
Source§fn clone(&self) -> GhosttyAllocator
fn clone(&self) -> GhosttyAllocator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GhosttyAllocator
impl Debug for GhosttyAllocator
Source§impl Default for GhosttyAllocator
impl Default for GhosttyAllocator
impl Copy for GhosttyAllocator
Auto Trait Implementations§
impl Freeze for GhosttyAllocator
impl RefUnwindSafe for GhosttyAllocator
impl !Send for GhosttyAllocator
impl !Sync for GhosttyAllocator
impl Unpin for GhosttyAllocator
impl UnsafeUnpin for GhosttyAllocator
impl UnwindSafe for GhosttyAllocator
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