ALLOCATOR: misc

This commit is contained in:
able 2023-05-28 02:01:11 -05:00
parent bb3c1b6120
commit 8eebd50179

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);
}
}
#[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()
}