Skip to main content

Allocator

Trait Allocator 

Source
pub trait Allocator: Send + Sync {
    // Required methods
    fn allocate(&self, size: usize, alignment: usize) -> Result<NonNull<u8>>;
    fn deallocate(&self, ptr: NonNull<u8>, size: usize) -> Result<()>;
    fn stats(&self) -> Arc<AllocatorStats>;
}
Expand description

Generic allocator trait

Required Methods§

Source

fn allocate(&self, size: usize, alignment: usize) -> Result<NonNull<u8>>

Allocate memory

Source

fn deallocate(&self, ptr: NonNull<u8>, size: usize) -> Result<()>

Deallocate memory

Source

fn stats(&self) -> Arc<AllocatorStats>

Get statistics

Implementors§