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
available bytes