[][src]Struct slabmalloc::ZoneAllocator

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

A zone allocator for arbitrary sized allocations.

Has a bunch of SCAllocator and through that can serve allocation requests for many different object sizes up to (MAX_SIZE_CLASSES) by selecting the right SCAllocator for allocation and deallocation.

The allocator provides to refill functions refill and refill_large to provide the underlying SCAllocator with more memory in case it runs out.

Methods

impl<'a> ZoneAllocator<'a>[src]

pub const MAX_ALLOC_SIZE: usize[src]

Maximum size that allocated within LargeObjectPages (2 MiB). This is also the maximum object size that this allocator can handle.

pub const MAX_BASE_ALLOC_SIZE: usize[src]

Maximum size which is allocated with ObjectPages (4 KiB pages).

e.g. this is 4 KiB - 80 bytes of meta-data.

pub const fn new() -> ZoneAllocator<'a>[src]

pub unsafe fn refill(
    &mut self,
    layout: Layout,
    new_page: &'a mut ObjectPage<'a>
) -> Result<(), AllocationError>
[src]

Refills the SCAllocator for a given Layout with an ObjectPage.

Safety

ObjectPage needs to be emtpy etc.

pub unsafe fn refill_large(
    &mut self,
    layout: Layout,
    new_page: &'a mut LargeObjectPage<'a>
) -> Result<(), AllocationError>
[src]

Refills the SCAllocator for a given Layout with an ObjectPage.

Safety

ObjectPage needs to be emtpy etc.

pub fn allocate(
    &mut self,
    layout: Layout
) -> Result<NonNull<u8>, AllocationError>
[src]

Allocate a pointer to a block of memory described by layout.

pub fn deallocate(
    &mut self,
    ptr: NonNull<u8>,
    layout: Layout
) -> Result<(), AllocationError>
[src]

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

Arguments

  • ptr - Address of the memory location to free.
  • layout - Memory layout of the block pointed to by ptr.

Trait Implementations

impl<'a> Default for ZoneAllocator<'a>[src]

Auto Trait Implementations

impl<'a> Unpin for ZoneAllocator<'a>

impl<'a> Send for ZoneAllocator<'a>

impl<'a> Sync for ZoneAllocator<'a>

impl<'a> !UnwindSafe for ZoneAllocator<'a>

impl<'a> RefUnwindSafe for ZoneAllocator<'a>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]