Struct sp_allocator::FreeingBumpHeapAllocator
source · [−]pub struct FreeingBumpHeapAllocator { /* private fields */ }
Expand description
An implementation of freeing bump allocator.
Refer to the module-level documentation for further details.
Implementations
sourceimpl FreeingBumpHeapAllocator
impl FreeingBumpHeapAllocator
sourcepub fn new(heap_base: u32) -> Self
pub fn new(heap_base: u32) -> Self
Creates a new allocation heap which follows a freeing-bump strategy.
Arguments
heap_base
- the offset from the beginning of the linear memory where the heap starts.
sourcepub fn allocate<M: Memory + ?Sized>(
&mut self,
mem: &mut M,
size: WordSize
) -> Result<Pointer<u8>, Error>
pub fn allocate<M: Memory + ?Sized>(
&mut self,
mem: &mut M,
size: WordSize
) -> Result<Pointer<u8>, Error>
Gets requested number of bytes to allocate and returns a pointer. The maximum size which can be allocated at once is 16 MiB. There is no minimum size, but whatever size is passed into this function is rounded to the next power of two. If the requested size is below 8 bytes it will be rounded up to 8 bytes.
NOTE: Once the allocator has returned an error all subsequent requests will return an error.
Arguments
mem
- a slice representing the linear memory on which this allocator operates.size
- size in bytes of the allocation request
sourcepub fn deallocate<M: Memory + ?Sized>(
&mut self,
mem: &mut M,
ptr: Pointer<u8>
) -> Result<(), Error>
pub fn deallocate<M: Memory + ?Sized>(
&mut self,
mem: &mut M,
ptr: Pointer<u8>
) -> Result<(), Error>
Deallocates the space which was allocated for a pointer.
NOTE: Once the allocator has returned an error all subsequent requests will return an error.
Arguments
mem
- a slice representing the linear memory on which this allocator operates.ptr
- pointer to the allocated chunk
Auto Trait Implementations
impl RefUnwindSafe for FreeingBumpHeapAllocator
impl Send for FreeingBumpHeapAllocator
impl Sync for FreeingBumpHeapAllocator
impl Unpin for FreeingBumpHeapAllocator
impl UnwindSafe for FreeingBumpHeapAllocator
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for T where
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
sourceimpl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
sourcepub fn unchecked_into(self) -> T
pub fn unchecked_into(self) -> T
The counterpart to unchecked_from
.