pub struct MmapHeap { /* private fields */ }Expand description
Dynamic virtual-memory allocator backed by mmap_anonymous slabs for small blocks
(<= 4080 bytes) and direct page-granularity mmap_anonymous/munmap mappings for
large or over-aligned allocations.
Implementations§
Source§impl MmapHeap
impl MmapHeap
Sourcepub unsafe fn alloc_c(&self, size: usize, align: usize) -> *mut u8
pub unsafe fn alloc_c(&self, size: usize, align: usize) -> *mut u8
Allocates size bytes with alignment align (at least 16-byte aligned), recording
C-compatible metadata immediately preceding the returned user pointer.
§Safety
Any non-null pointer returned must be released via MmapHeap::free_c or MmapHeap::realloc_c.
Sourcepub unsafe fn calloc_c(&self, nobj: usize, size: usize) -> *mut u8
pub unsafe fn calloc_c(&self, nobj: usize, size: usize) -> *mut u8
Allocates and zero-initializes nobj * size bytes.
§Safety
Any non-null pointer returned must be released via MmapHeap::free_c or MmapHeap::realloc_c.
Sourcepub unsafe fn free_c(&self, ptr: *mut u8)
pub unsafe fn free_c(&self, ptr: *mut u8)
Frees a pointer previously returned by MmapHeap::alloc_c, MmapHeap::calloc_c,
or MmapHeap::realloc_c. Passing null is a safe no-op.
§Safety
ptr must be null or a live pointer allocated by this MmapHeap.
Trait Implementations§
Source§impl GlobalAlloc for MmapHeap
impl GlobalAlloc for MmapHeap
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
layout. Read moreSource§unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8
alloc, but also ensures that the contents
are set to zero before being returned. Read more