Skip to content

Commit d10304e

Browse files
committed
the memory_deallocated hook can make good use of knowing the size
1 parent 2a5eae3 commit d10304e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/librustc_mir/interpret/machine.rs

+1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ pub trait Machine<'a, 'mir, 'tcx>: Sized {
199199
fn memory_deallocated(
200200
_alloc: &mut Allocation<Self::PointerTag, Self::AllocExtra>,
201201
_ptr: Pointer<Self::PointerTag>,
202+
_size: Size,
202203
) -> EvalResult<'tcx> {
203204
Ok(())
204205
}

src/librustc_mir/interpret/memory.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
232232
}
233233

234234
// Let the machine take some extra action
235-
M::memory_deallocated(&mut alloc, ptr)?;
235+
let size = Size::from_bytes(alloc.bytes.len() as u64);
236+
M::memory_deallocated(&mut alloc, ptr, size)?;
236237

237238
// Don't forget to remember size and align of this now-dead allocation
238239
let old = self.dead_alloc_map.insert(

0 commit comments

Comments
 (0)