pub fn deallocate_local(&mut self, local: Option<Value>) -> EvalResult<'tcx> {
if let Some(Value::ByRef(ptr)) = local {
trace!("deallocating local");
+ let ptr = ptr.to_ptr()?;
self.memory.dump_alloc(ptr.alloc_id);
- match self.memory.deallocate(ptr) {
+ match self.memory.deallocate(ptr, None) {
// We could alternatively check whether the alloc_id is static before calling
// deallocate, but this is much simpler and is probably the rare case.
Ok(()) | Err(EvalError::DeallocatedStaticMemory) => {},
if let Some((name, value)) = new {
// +1 for the null terminator
let value_copy = self.memory.allocate((value.len() + 1) as u64, 1)?;
- self.memory.write_bytes(value_copy, &value)?;
- self.memory.write_bytes(value_copy.offset(value.len() as u64, self.memory.layout)?, &[0])?;
+ self.memory.write_bytes(PrimVal::Ptr(value_copy), &value)?;
+ self.memory.write_bytes(PrimVal::Ptr(value_copy.offset(value.len() as u64, self.memory.layout)?), &[0])?;
if let Some(var) = self.env_vars.insert(name.to_owned(), value_copy) {
- self.memory.deallocate(var)?;
+ self.memory.deallocate(var, None)?;
}
self.write_primval(dest, PrimVal::Bytes(0), dest_ty)?;
} else {