[][src]Trait dynvec::Region

pub trait Region<H> {
    type Pointers: Iterator<Item = *mut u8>;
    pub fn allocate(&mut self, layout: Layout, header: H) -> Result<*mut u8, H>;
pub fn deallocate(&mut self, ptr: *mut u8) -> Option<H>;
pub fn has_allocated(&self, ptr: *mut u8) -> bool;
pub fn allocations(&self) -> Self::Pointers;
pub fn count(&self) -> usize; pub fn deallocate_all(&mut self) -> DeallocateAll<'_, H, Self>
    where
        Self: Sized
, { ... } }

Represents a region of the memory. Objects can be allocated into this region. Regions can carry additional data with each allocation.

Associated Types

type Pointers: Iterator<Item = *mut u8>[src]

An iterator over all the allocations of this region.

Loading content...

Required methods

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

Finds a free location within this region that is:

  • Properly aligned to layout.align
  • layout.size bytes long

Returns

The pointer is returned if the allocation is successful and the provided header is given back in the error if the allocation could not be done.

pub fn deallocate(&mut self, ptr: *mut u8) -> Option<H>[src]

Deallocates the memory allocated at the given pointer.

Returns

If the given pointer was not allocated in this region, None is returned. Otherwise, the header is returned.

Safety

  • The old value must've been properly dropped.

pub fn has_allocated(&self, ptr: *mut u8) -> bool[src]

Checks whether the given pointer is allocated in this region.

pub fn allocations(&self) -> Self::Pointers[src]

Returns an iterator over all the allocations of this region.

pub fn count(&self) -> usize[src]

Returns the number of allocations this region has.

Loading content...

Provided methods

pub fn deallocate_all(&mut self) -> DeallocateAll<'_, H, Self> where
    Self: Sized
[src]

Returns an iterator that causes all allocations to be deallocated. The iterator yield the headers.

Loading content...

Implementors

Loading content...