the memory_deallocated hook can make good use of knowing the size

This commit is contained in:
Ralf Jung 2018-10-29 20:40:19 +01:00
parent 2a5eae3ac7
commit d10304eeb5
2 changed files with 3 additions and 1 deletions

View file

@ -199,6 +199,7 @@ pub trait Machine<'a, 'mir, 'tcx>: Sized {
fn memory_deallocated(
_alloc: &mut Allocation<Self::PointerTag, Self::AllocExtra>,
_ptr: Pointer<Self::PointerTag>,
_size: Size,
) -> EvalResult<'tcx> {
Ok(())
}

View file

@ -232,7 +232,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
}
// Let the machine take some extra action
M::memory_deallocated(&mut alloc, ptr)?;
let size = Size::from_bytes(alloc.bytes.len() as u64);
M::memory_deallocated(&mut alloc, ptr, size)?;
// Don't forget to remember size and align of this now-dead allocation
let old = self.dead_alloc_map.insert(