Skip to content

Commit e477895

Browse files
committed
Auto merge of rust-lang#3578 - RalfJung:realloc, r=RalfJung
avoid code duplication between realloc and malloc
2 parents 629d57e + 82e2144 commit e477895

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/tools/miri/src/shims/alloc.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
124124
let new_align = this.min_align(new_size, kind);
125125
if this.ptr_is_null(old_ptr)? {
126126
// Here we must behave like `malloc`.
127-
if new_size == 0 {
128-
Ok(Pointer::null())
129-
} else {
130-
let new_ptr =
131-
this.allocate_ptr(Size::from_bytes(new_size), new_align, kind.into())?;
132-
Ok(new_ptr.into())
133-
}
127+
self.malloc(new_size, /*zero_init*/ false, kind)
134128
} else {
135129
if new_size == 0 {
136130
// C, in their infinite wisdom, made this UB.

0 commit comments

Comments
 (0)