diff options
| author | bors <bors@rust-lang.org> | 2024-05-06 08:06:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-05-06 08:06:16 +0000 |
| commit | e477895aaffb0f6d49aaea41baa863486ace08b5 (patch) | |
| tree | 7c08e84c41e98bdd69ae00531780120f95e7fbe3 /src | |
| parent | 629d57e7001cf5d23ebbb973f8355cfe8972a24a (diff) | |
| parent | 82e2144ed74648485dc27dbb67f594acd1b14916 (diff) | |
| download | rust-e477895aaffb0f6d49aaea41baa863486ace08b5.tar.gz rust-e477895aaffb0f6d49aaea41baa863486ace08b5.zip | |
Auto merge of #3578 - RalfJung:realloc, r=RalfJung
avoid code duplication between realloc and malloc
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/miri/src/shims/alloc.rs | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/src/tools/miri/src/shims/alloc.rs b/src/tools/miri/src/shims/alloc.rs index 79531598c00..61e639f76ed 100644 --- a/src/tools/miri/src/shims/alloc.rs +++ b/src/tools/miri/src/shims/alloc.rs @@ -124,13 +124,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> { let new_align = this.min_align(new_size, kind); if this.ptr_is_null(old_ptr)? { // Here we must behave like `malloc`. - if new_size == 0 { - Ok(Pointer::null()) - } else { - let new_ptr = - this.allocate_ptr(Size::from_bytes(new_size), new_align, kind.into())?; - Ok(new_ptr.into()) - } + self.malloc(new_size, /*zero_init*/ false, kind) } else { if new_size == 0 { // C, in their infinite wisdom, made this UB. |
