pub struct LockedHeap<const ORDER: usize>(/* private fields */);Expand description
A locked version of Heap
§Usage
Create a locked heap and add a memory region to it:
use buddy_system_allocator::*;
// The max order of the buddy system is `ORDER - 1`.
// For example, to create a heap with a maximum block size of 2^32 bytes,
// you should define the heap with `ORDER = 33`.
let mut heap = LockedHeap::<33>::new();
unsafe {
heap.lock().init(begin, size);
// or
heap.lock().add_to_heap(begin, end);
}Implementations§
Trait Implementations§
Source§impl<const ORDER: usize> Default for LockedHeap<ORDER>
impl<const ORDER: usize> Default for LockedHeap<ORDER>
Source§fn default() -> LockedHeap<ORDER>
fn default() -> LockedHeap<ORDER>
Returns the “default value” for a type. Read more
Source§impl<const ORDER: usize> Deref for LockedHeap<ORDER>
Available on crate feature use_spin only.
impl<const ORDER: usize> Deref for LockedHeap<ORDER>
Available on crate feature
use_spin only.Source§impl<const ORDER: usize> GlobalAlloc for LockedHeap<ORDER>
Available on crate feature use_spin only.
impl<const ORDER: usize> GlobalAlloc for LockedHeap<ORDER>
Available on crate feature
use_spin only.Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
Allocates memory as described by the given
layout. Read moreAuto Trait Implementations§
impl<const ORDER: usize> !Freeze for LockedHeap<ORDER>
impl<const ORDER: usize> !RefUnwindSafe for LockedHeap<ORDER>
impl<const ORDER: usize> Send for LockedHeap<ORDER>
impl<const ORDER: usize> Sync for LockedHeap<ORDER>
impl<const ORDER: usize> Unpin for LockedHeap<ORDER>
impl<const ORDER: usize> UnwindSafe for LockedHeap<ORDER>
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