diff --git a/kernel/src/allocator.rs b/kernel/src/allocator.rs index 8dcd3ed..6e162f6 100644 --- a/kernel/src/allocator.rs +++ b/kernel/src/allocator.rs @@ -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() }