Zeroed page allocation

memory-manager
Asya 2023-02-11 11:22:46 +03:00
parent cdbde8911d
commit 7d392b408a
Signed by: asya
GPG Key ID: 4679BF7DCC044783
1 changed files with 8 additions and 0 deletions

View File

@ -20,6 +20,14 @@ impl MemoryManager {
self.get_free_pages(order).map(|addr| addr as *mut u8)
}
pub fn zallocate_pages(&mut self, order: usize) -> Option<*mut u8> {
let ptr = self.allocate_pages(order)?;
unsafe {
ptr.write_bytes(0, PAGE_SIZE << order);
}
Some(ptr)
}
/// # Safety
/// This method assumes that `address` is in range of this allocator
pub unsafe fn deallocate_pages(&mut self, address: *mut u8, order: usize) {