Skip to content

Commit ff38a95

Browse files
reallocate_ptr comment
Co-authored-by: Ralf Jung <[email protected]>
1 parent 4955d23 commit ff38a95

File tree

1 file changed

+3
-0
lines changed
  • compiler/rustc_const_eval/src/interpret

1 file changed

+3
-0
lines changed

compiler/rustc_const_eval/src/interpret/memory.rs

+3
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
291291

292292
// For simplicities' sake, we implement reallocate as "alloc, copy, dealloc".
293293
// This happens so rarely, the perf advantage is outweighed by the maintenance cost.
294+
// If requested, we zero-init the entire allocation, to ensure that a growing
295+
// allocation has its new bytes properly set. For the part that is copied,
296+
// `mem_copy` below will de-initialize things as necessary.
294297
let new_ptr = self.allocate_ptr(new_size, new_align, kind, init)?;
295298
let old_size = match old_size_and_align {
296299
Some((size, _align)) => size,

0 commit comments

Comments
 (0)