ALLOCATOR: misc

master
able 2023-05-28 02:01:11 -05:00
parent 7f3e01d0a2
commit 2fc3502073
1 changed files with 10 additions and 4 deletions

View File

@ -150,7 +150,8 @@ impl Heap {
#[cfg(debug_assertions)]
trace!("Allocating {:?}", ptr);
}
// FIXME: zero or scrub memory?
// FIXME: zero out memory to prevent leaking data
assert!(ptr.is_aligned_to(alignment));
NonNull::new(ptr)
}
@ -166,7 +167,7 @@ impl Heap {
let size = unsafe { (*header).size_in_chunks };
self.bitmap_set_range(start, size, false);
self.allocated_chunks -= size;
// FIXME: zero or scrub memory?
// FIXME: zero out memory to prevent leaking data
}
/// Finds first hole that can fit an allocation of `size` chunks, returns the start of the
@ -248,7 +249,10 @@ impl Heap {
return Some(start_of_free_chunks);
}
}
trace!("No first fit found");
#[cfg(debug_assertions)]
{
trace!("No first fit found");
}
None
}
@ -334,6 +338,8 @@ impl Heap {
unsafe impl Send for Heap {}
#[alloc_error_handler]
fn alloc_error_handler(_layout: alloc::alloc::Layout) -> ! {
fn alloc_error_handler(layout: alloc::alloc::Layout) -> ! {
log::error!("allocation error: {:?}", layout);
// Todo: Maybe panic here instead
crate::arch::sloop()
}