Crate good_memory_allocator
source · [−]Expand description
This is a linked list allocator, inspired by the dlmalloc algorithm, to be
used in no_std environments such as operating system kernels. The overhead
for each allocation is a single usize. The implementation prioritizes
runtime efficiency over memory efficiency, but also provides very good
memory utilization. The allocator is heavily tested with test cases covering
almost all code paths; fuzzing is used to cover the rest.
Usage
Create a static allocator:
use good_memory_allocator::SpinLockedAllocator;
#[global_allocator]
static ALLOCATOR: SpinLockedAllocator = SpinLockedAllocator::empty();Before using this allocator, you need to initialize it:
pub fn init_heap() {
unsafe {
ALLOCATOR.init(heap_start, heap_size);
}
}Features
spin(default): Provide aSpinLockedAllocatortype that implements theGlobalAlloctrait by using a spinlock.allocator: Provides an implementation of the unstableAllocatortrait for theSpinLockedAllocatortype.
Structs
A linked list memory allocator.
A spin locked memory allocator that can be used as the global allocator.