mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
kernel: mem: zero out memory as part of alloc()
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
db87a94960
commit
99d19866cf
1 changed files with 6 additions and 2 deletions
|
|
@ -218,7 +218,9 @@ impl MemoryManager {
|
||||||
if self.allocations[index] == 0 {
|
if self.allocations[index] == 0 {
|
||||||
self.allocations[index] = pid;
|
self.allocations[index] = pid;
|
||||||
self.last_ram_page = index + 1;
|
self.last_ram_page = index + 1;
|
||||||
return Ok(index * PAGE_SIZE + self.ram_start);
|
let page = (index * PAGE_SIZE + self.ram_start) as *mut usize;
|
||||||
|
unsafe { page.write_bytes(0, PAGE_SIZE / mem::size_of::<usize>()) };
|
||||||
|
return Ok(page as usize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for index in 0..self.last_ram_page {
|
for index in 0..self.last_ram_page {
|
||||||
|
|
@ -226,7 +228,9 @@ impl MemoryManager {
|
||||||
if self.allocations[index] == 0 {
|
if self.allocations[index] == 0 {
|
||||||
self.allocations[index] = pid;
|
self.allocations[index] = pid;
|
||||||
self.last_ram_page = index + 1;
|
self.last_ram_page = index + 1;
|
||||||
return Ok(index * PAGE_SIZE + self.ram_start);
|
let page = (index * PAGE_SIZE + self.ram_start) as *mut usize;
|
||||||
|
unsafe { page.write_bytes(0, PAGE_SIZE / mem::size_of::<usize>()) };
|
||||||
|
return Ok(page as usize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(xous::Error::OutOfMemory)
|
Err(xous::Error::OutOfMemory)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue