Struct slabmalloc::ZoneAllocator [] [src]

pub struct ZoneAllocator<'a> {
    // some fields omitted
}

A zone allocator.

Has a bunch of slab allocators and can serve allocation requests for many different (MAX_SLABS) object sizes (by selecting the right slab allocator).

Methods

impl<'a> ZoneAllocator<'a>

fn new(pager: Option<&'a mut SlabPageProvider<'a>>) -> ZoneAllocator<'a>

fn allocate<'b>(&'b mut self, size: usize, align: usize) -> Option<*mut u8>

Allocate a pointer to a block of memory of size size with alignment align.

Can return None in case the zone allocator can not satisfy the allocation of the requested size or if we do not have enough memory. In case we are out of memory we try to refill the slab using our local pager and re-try the allocation request once more before we give up.

fn deallocate<'b>(&'b mut self, ptr: *mut u8, old_size: usize, align: usize)

Deallocates a pointer to a block of memory previously allocated by allocate.

Arguments

  • ptr - Address of the memory location to free.
  • old_size - Size of the block.
  • align - Alignment of the block.