pub struct BumpAllocator<G = ()> { /* private fields */ }Expand description
Bump allocator that grows upward from HEAP_START.
Generic parameter G allows for optional global state storage at the heap start.
Use G = () (the default) for no global state.
§Safety
Only one instance should exist per program, and it must be set as the global allocator. Creating multiple instances or using alongside another allocator is undefined behavior.
Implementations§
Source§impl<G> BumpAllocator<G>
impl<G> BumpAllocator<G>
Sourcepub const unsafe fn new() -> Self
pub const unsafe fn new() -> Self
Creates a new allocator.
§Safety
- Only one BumpAllocator instance should exist per program
- It must be set as the global allocator
- Multiple instances or using alongside another allocator leads to undefined behavior
- The Rialo runtime must have zero-initialized the heap region (guaranteed by spec)
Trait Implementations§
Source§impl<G: Zeroable> GlobalAlloc for BumpAllocator<G>
impl<G: Zeroable> GlobalAlloc for BumpAllocator<G>
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
Allocates memory as described by the given
layout. Read moreAuto Trait Implementations§
impl<G> Freeze for BumpAllocator<G>
impl<G> RefUnwindSafe for BumpAllocator<G>where
G: RefUnwindSafe,
impl<G> Send for BumpAllocator<G>where
G: Send,
impl<G> Sync for BumpAllocator<G>where
G: Sync,
impl<G> Unpin for BumpAllocator<G>where
G: Unpin,
impl<G> UnsafeUnpin for BumpAllocator<G>
impl<G> UnwindSafe for BumpAllocator<G>where
G: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more