Better error handling for dealloc
This commit is contained in:
parent
9646f7de8b
commit
eef96dfc87
@ -27,16 +27,23 @@ lazy_static! {
|
||||
|
||||
pub fn deallocate_usable() -> Result<(), AllocError> {
|
||||
init_statics();
|
||||
let mut any_error: Option<AllocError> = None;
|
||||
let mut bytes_deallocated: u64 = 0;
|
||||
for entry in MEMMAP_RESPONSE.entries() {
|
||||
if (entry.entry_type == EntryType::USABLE) | (entry.entry_type == EntryType::BOOTLOADER_RECLAIMABLE) {
|
||||
deallocate(**entry)?;
|
||||
if let Err(error) = deallocate(**entry) {
|
||||
any_error = Some(error);
|
||||
}
|
||||
bytes_deallocated += entry.length;
|
||||
}
|
||||
}
|
||||
log_trace!("Deallocated 0x{:x} bytes", bytes_deallocated);
|
||||
if let Some(error) = any_error {
|
||||
Err(error)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn deallocate(entry: limine::memory_map::Entry) -> Result<(), AllocError> {
|
||||
@ -129,6 +136,7 @@ pub fn log_address() {
|
||||
);
|
||||
}
|
||||
|
||||
// Have to initialize all of these before reclaiming bootloader memory
|
||||
fn init_statics() {
|
||||
let _ = EXECUTABLE_FILE_RESPONSE;
|
||||
let _ = HHDM_RESPONSE;
|
||||
|
Loading…
Reference in New Issue
Block a user