diff options
| author | Ralf Jung <post@ralfj.de> | 2018-10-29 20:40:19 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2018-10-29 20:40:19 +0100 |
| commit | d10304eeb5c9e63597b9ee1094aca0f63c4f31ca (patch) | |
| tree | dfa7be6625b7a5123d6fc45703e24befc455bc71 | |
| parent | 2a5eae3ac78a63196c119c8ca5f8f0bd99227971 (diff) | |
the memory_deallocated hook can make good use of knowing the size
| -rw-r--r-- | src/librustc_mir/interpret/machine.rs | 1 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/memory.rs | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs index 7aeadfa408a..e9d181479e5 100644 --- a/src/librustc_mir/interpret/machine.rs +++ b/src/librustc_mir/interpret/machine.rs @@ -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(()) } diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 91f3813e2b1..a9ef35845fc 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -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( |
