Simple slab based malloc implementation in rust, in order to provide the necessary interface to rusts liballoc library. slabmalloc only relies on libcore and is designed to be used in kernel level code as the only interface a client needs to provide is the necessary mechanism to allocate and free 4KiB frames (or any other default page-size on non-x86 hardware).
match zone.allocate(objectsize, alignment) { None => println!("Out of memory..."), Some(ptr) => zone.deallocate(ptr, objectsize, alignment), } ```
rust
let object_size = 10;
let alignment = 8;
let mmap = MmapSlabAllocator::new();
let mut sa: SlabAllocator = SlabAllocator::new(object_size, &mmap);
sa.allocate(alignment);
The slabmalloc API is designed satisfy the rust liballoc low-level memory allocation interface.