slabmalloc
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).
Usage
- The slabmalloc API is designed to satisfy the rust liballoc low-level memory allocation interface:
use ;
static MEM_PROVIDER: SafeZoneAllocator = new;
- Use the ZoneAllocator to allocate arbitrary sized objects:
let object_size = 12;
let alignment = 4;
let mmap = new;
let mut zone = new;
unsafe
- Use the SCAllocator to allocate fixed sized objects:
let object_size = 10;
let alignment = 8;
let layout = from_size_align.unwrap;
let mut mmap = new;
let mut sa: SCAllocator = new;
sa.allocate;
Using on stable
By default this packages requires a nightly version of the Rust compiler. To be able to use this package with a stable version of the Rust compiler, default features have to be disabled, e.g. with
slabmalloc = { version = ..., default_features = false }
Documentation
TODO
- No focus on performance yet