1
0
Fork 0
forked from AbleOS/ableos

Zero memory on allocation

This commit is contained in:
Erin 2023-10-08 11:24:55 +02:00 committed by ondra05
parent ada43910d2
commit ebfc9c1c4e

View file

@ -150,7 +150,8 @@ impl Heap {
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
trace!("Allocating {:?}", ptr); trace!("Allocating {:?}", ptr);
} }
// FIXME: zero out memory to prevent leaking data
unsafe { core::ptr::write_bytes(ptr, 0, size) };
assert!(ptr.is_aligned_to(alignment)); assert!(ptr.is_aligned_to(alignment));
NonNull::new(ptr) NonNull::new(ptr)
@ -168,6 +169,7 @@ impl Heap {
self.bitmap_set_range(start, size, false); self.bitmap_set_range(start, size, false);
self.allocated_chunks -= size; self.allocated_chunks -= size;
// FIXME: zero out memory to prevent leaking data // FIXME: zero out memory to prevent leaking data
// REPLY: When we zero on alloc, do we really need it?
} }
/// Finds first hole that can fit an allocation of `size` chunks, returns the start of the /// Finds first hole that can fit an allocation of `size` chunks, returns the start of the