Clear memory on demand

This commit is contained in:
Jeremy Soller 2016-09-11 21:47:44 -06:00
parent 9796d21906
commit aa2915001e
3 changed files with 26 additions and 25 deletions

View file

@ -24,14 +24,16 @@ pub fn brk(address: usize) -> Result<usize> {
} else if address >= arch::USER_HEAP_OFFSET {
//TODO: out of memory errors
if let Some(ref mut heap) = context.heap {
heap.resize(address - arch::USER_HEAP_OFFSET, true);
heap.resize(address - arch::USER_HEAP_OFFSET, true, true);
return Ok(address);
}
context.heap = Some(context::memory::Memory::new(
VirtualAddress::new(arch::USER_HEAP_OFFSET),
address - arch::USER_HEAP_OFFSET,
entry::WRITABLE | entry::NO_EXECUTE | entry::USER_ACCESSIBLE
entry::WRITABLE | entry::NO_EXECUTE | entry::USER_ACCESSIBLE,
true,
true
));
Ok(address)