pub struct Arena { /* private fields */ }Expand description
Memory arena for FFI allocations
All memory allocated from this arena is freed when the arena is dropped.
Implementations§
Source§impl Arena
impl Arena
Sourcepub fn alloc(&mut self, size: usize) -> *mut u8
pub fn alloc(&mut self, size: usize) -> *mut u8
Allocate memory from the arena
Returns null on allocation failure
Sourcepub fn alloc_zeroed(&mut self, size: usize) -> *mut u8
pub fn alloc_zeroed(&mut self, size: usize) -> *mut u8
Allocate and zero-initialize memory from the arena
Sourcepub fn alloc_type<T>(&mut self) -> *mut T
pub fn alloc_type<T>(&mut self) -> *mut T
Allocate memory for a type T
Sourcepub fn copy_bytes(&mut self, bytes: &[u8]) -> *mut u8
pub fn copy_bytes(&mut self, bytes: &[u8]) -> *mut u8
Allocate and copy bytes into the arena
Sourcepub fn allocation_count(&self) -> usize
pub fn allocation_count(&self) -> usize
Get the number of allocations
Sourcepub fn total_size(&self) -> usize
pub fn total_size(&self) -> usize
Get the total allocated size
Trait Implementations§
Auto Trait Implementations§
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