Zero memory on allocation

pull/11/head
ondra05 2023-10-08 11:24:55 +02:00
parent 99323e8d1f
commit f22b3fd34f
No known key found for this signature in database
GPG Key ID: 0DA6D2BB2285E881
1 changed files with 3 additions and 1 deletions

View File

@ -150,7 +150,8 @@ impl Heap {
#[cfg(debug_assertions)]
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));
NonNull::new(ptr)
@ -168,6 +169,7 @@ impl Heap {
self.bitmap_set_range(start, size, false);
self.allocated_chunks -= size;
// 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