[][src]Trait context_allocator::MemorySource

pub trait MemorySource: Debug {
    fn obtain(
        &self,
        non_zero_size: NonZeroUsize
    ) -> Result<NonNull<u8>, AllocErr>;
fn release(&self, non_zero_size: NonZeroUsize, current_memory: NonNull<u8>); }

A memory source is a sort-of crude allocator that can obtain and release memory, from, say, the operating system, an arena or some fixed range.

It is thread-aware but not necessarily thread-safe.

Required methods

fn obtain(&self, non_zero_size: NonZeroUsize) -> Result<NonNull<u8>, AllocErr>

Obtain memory from the operating system, say.

Alignment will be whatever is appropriate, but is likely to be quite large.

fn release(&self, non_zero_size: NonZeroUsize, current_memory: NonNull<u8>)

Release memory to the operating system, say.

Alignment will be whatever is appropriate, but is likely to be quite large.

Loading content...

Implementors

impl MemorySource for MemoryMapAllocator[src]

impl<MS: MemorySource> MemorySource for ArenaMemorySource<MS>[src]

Loading content...