memapi
provides a minimal, no_std
-friendly memory allocation interface
for managing raw buffers, suitable for use in collections.
This crate exports:
- [
Alloc
], a trait defining basic allocate, deallocate, grow, and shrink operations. - [
DefaultAlloc
], a zero-cost wrapper delegating to the global allocator. - [
AllocError
], an enum of possible error cases.
Examples
# use ;
# use Layout;
# use NonNull;
let allocator = DefaultAlloc;
// Make the layout for the block.
let layout = from_size_align.unwrap;
// Allocate 64 bytes
let ptr: = allocator.alloc.expect;
// Deallocate the block.
unsafe ;