pub struct BumpAllocator {
pub start: usize,
pub len: usize,
}Expand description
A bump allocator over the SVM heap region.
This is the same single-pass, never-frees design the Solana SDK and
Pinocchio use: the first word of the heap stores the current cursor,
allocations bump it downward from the top of the region, and
dealloc is a no-op. It is the right allocator for the cold paths of
a program that wants alloc (e.g. a Vec while building a CPI) while
keeping the hot path zero-allocation. For programs that must never
allocate, prefer no_allocator! so any stray allocation traps.
Install it with default_allocator!.
Fields§
§start: usizeHeap region start address.
len: usizeHeap region length in bytes.
Trait Implementations§
Source§impl GlobalAlloc for BumpAllocator
impl GlobalAlloc for BumpAllocator
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 Freeze for BumpAllocator
impl RefUnwindSafe for BumpAllocator
impl Send for BumpAllocator
impl Sync for BumpAllocator
impl Unpin for BumpAllocator
impl UnsafeUnpin for BumpAllocator
impl UnwindSafe for BumpAllocator
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