pub struct MipsMcuHeap { /* private fields */ }
Implementations§
Source§impl MipsMcuHeap
impl MipsMcuHeap
Sourcepub const fn empty() -> MipsMcuHeap
pub const fn empty() -> MipsMcuHeap
Create a new UNINITIALIZED heap allocator.
You must initialize this heap using the
init
method before using the allocator.
Sourcepub fn init(&self)
pub fn init(&self)
Initialize heap with heap start location from linker and a defined initial size.
Sourcepub fn free(&self) -> usize
pub fn free(&self) -> usize
Returns the amount of bytes currently available.
This method does not consider possible heap extensions
Sourcepub fn headroom(&self) -> usize
pub fn headroom(&self) -> usize
Returns the current distance to the bottom of the stack.
This is an estimate amount of memory that could be added to the heap by
automatic extension. An estimate of the total available free heap memory
is the sum of free()
and headroom()
.
Sourcepub unsafe fn reserve(&self, free_bytes: usize) -> Result<(), Error>
pub unsafe fn reserve(&self, free_bytes: usize) -> Result<(), Error>
Try to extend the stack so that it has at least an amount of
free_bytes
available.
Fails if there is not enough headroom. Does nothing if there are already enough free bytes.
§Safety
This method is considered unsafe because it increases the likelihood of heap/stack collisions.
Trait Implementations§
Source§impl GlobalAlloc for MipsMcuHeap
impl GlobalAlloc for MipsMcuHeap
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
layout
. Read more