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
Allocate memory as described by the given layout
. Read more
sourceunsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)
Deallocate the block of memory at the given ptr
pointer with the given layout
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for LockedHeap
impl Send for LockedHeap
impl Sync for LockedHeap
impl Unpin for LockedHeap
impl UnwindSafe for LockedHeap
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more