#[repr(C)]pub struct MemoryCallbacks {
pub alloc: extern "C" fn(size: usize) -> *mut u8,
pub free: extern "C" fn(ptr: *mut u8, size: usize),
pub realloc: extern "C" fn(ptr: *mut u8, old_size: usize, new_size: usize) -> *mut u8,
}Expand description
Memory management callbacks
Fields§
§alloc: extern "C" fn(size: usize) -> *mut u8Allocate memory from the host
§Parameters
size: Number of bytes to allocate
§Returns
- Pointer to allocated memory, or null on failure
free: extern "C" fn(ptr: *mut u8, size: usize)Free memory previously allocated by alloc
§Parameters
ptr: Pointer to memory to freesize: Size of allocation (must match original alloc size)
realloc: extern "C" fn(ptr: *mut u8, old_size: usize, new_size: usize) -> *mut u8Reallocate memory
§Parameters
ptr: Current pointer (may be null)old_size: Current size (0 if ptr is null)new_size: Desired new size
§Returns
- Pointer to reallocated memory, or null on failure
Trait Implementations§
Source§impl Clone for MemoryCallbacks
impl Clone for MemoryCallbacks
Source§fn clone(&self) -> MemoryCallbacks
fn clone(&self) -> MemoryCallbacks
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for MemoryCallbacks
Auto Trait Implementations§
impl Freeze for MemoryCallbacks
impl RefUnwindSafe for MemoryCallbacks
impl Send for MemoryCallbacks
impl Sync for MemoryCallbacks
impl Unpin for MemoryCallbacks
impl UnsafeUnpin for MemoryCallbacks
impl UnwindSafe for MemoryCallbacks
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