Struct slabmalloc::SlabAllocator
[−]
[src]
pub struct SlabAllocator<'a> { // some fields omitted }
A slab allocator allocates elements of a fixed size.
It has a list of SlabPages stored inside slabs
from which
it allocates memory.
Methods
impl<'a> SlabAllocator<'a>
fn new(size: usize, pager: Option<&'a mut SlabPageProvider<'a>>) -> SlabAllocator<'a>
Create a new SlabAllocator.
fn size(&self) -> usize
Return object size of this allocator.
fn insert_slab<'b>(&'b mut self, new_head: &'a mut SlabPage<'a>)
Add a new SlabPage.
fn allocate<'b>(&'b mut self, alignment: usize) -> Option<*mut u8>
Allocates a block of memory with respect to alignment
.
In case of failure will try to grow the slab allocator by requesting additional pages and re-try the allocation once more before we give up.
fn deallocate<'b>(&'b mut self, ptr: *mut u8)
Deallocates a previously allocated block.
Bug
This never releases memory in case the SlabPages are provided by the zone.