Struct linked_list_allocator::LockedHeap
source · [−]pub struct LockedHeap(_);
Implementations
sourceimpl LockedHeap
impl LockedHeap
sourcepub const fn empty() -> LockedHeap
pub const fn empty() -> LockedHeap
Creates an empty heap. All allocate calls will return None
.
sourcepub unsafe fn new(heap_bottom: *mut u8, heap_size: usize) -> LockedHeap
pub unsafe fn new(heap_bottom: *mut u8, heap_size: usize) -> LockedHeap
Creates a new heap with the given bottom
and size
.
The heap_bottom
pointer is automatically aligned, so the bottom()
method might return a pointer that is larger than heap_bottom
after construction.
The given heap_size
must be large enough to store the required
metadata, otherwise this function will panic. Depending on the
alignment of the hole_addr
pointer, the minimum size is between
2 * size_of::<usize>
and 3 * size_of::<usize>
.
Safety
The bottom address must be valid and the memory in the
[heap_bottom, heap_bottom + heap_size)
range must not be used for anything else.
This function is unsafe because it can cause undefined behavior if the given address
is invalid.
The provided memory range must be valid for the 'static
lifetime.
Trait Implementations
sourceimpl Deref for LockedHeap
impl Deref for LockedHeap
sourceimpl GlobalAlloc for LockedHeap
impl GlobalAlloc for LockedHeap
sourceunsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
layout
. Read more