Type Alias Slab

Source
pub type Slab<const SLOT_SIZE: usize> = UniqueFrame<Link<SlabMeta<SLOT_SIZE>>>;
Expand description

A slab.

The slot size is the maximum size of objects that can be allocated from the slab. The slab is densely divided into slots of this size.

The SLOT_SIZE is the size of the slots in bytes. The size of the slots cannot be smaller than the size of [usize]. It must be smaller than or equal to PAGE_SIZE.

A slab should have the size of one basic page. This restriction may be lifted in the future.

Aliased Type§

struct Slab<const SLOT_SIZE: usize> { /* private fields */ }

Implementations§

Source§

impl<const SLOT_SIZE: usize> Slab<SLOT_SIZE>

Source

pub fn new() -> Result<Self>

Allocates a new slab of the given size.

If the size is less than SLOT_SIZE or PAGE_SIZE, the size will be the maximum of the two.

Source

pub fn dealloc(&mut self, slot: HeapSlot) -> Result<(), AllocError>

Deallocates a slot to the slab.

If the slot does not belong to the slab it returns [AllocError].