Struct buddy_alloc::buddy_alloc::BuddyAlloc
source · pub struct BuddyAlloc { /* private fields */ }
Implementations§
source§impl BuddyAlloc
impl BuddyAlloc
sourcepub unsafe fn new(param: BuddyAllocParam) -> Self
pub unsafe fn new(param: BuddyAllocParam) -> Self
Safety
The base_addr..(base_addr + len)
must be allocated before using,
and must guarantee no others write to the memory range, to avoid undefined behaviors.
The new function panic if memory space not enough for initialize BuddyAlloc.
pub fn malloc(&mut self, nbytes: usize) -> *mut u8
pub fn free(&mut self, p: *mut u8)
sourcepub fn available_bytes(&self) -> usize
pub fn available_bytes(&self) -> usize
Returns the bytes currently available for allocation. Note due to the buddy allocation algorithm, the available bytes can’t be allocated at once. https://github.com/jjyr/buddy-alloc/issues/7
Auto Trait Implementations§
impl RefUnwindSafe for BuddyAlloc
impl !Send for BuddyAlloc
impl !Sync for BuddyAlloc
impl Unpin for BuddyAlloc
impl UnwindSafe for BuddyAlloc
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