Skip to content

Commit dfc2422

Browse files
authored
Rollup merge of #107878 - workingjubilee:new-size-means-bytes, r=scottmcm
Clarify `new_size` for realloc means bytes Minor docs fix requested by #107875
2 parents 2228c86 + 1af9b4f commit dfc2422

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

library/core/src/alloc/global.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -203,18 +203,19 @@ pub unsafe trait GlobalAlloc {
203203
ptr
204204
}
205205

206-
/// Shrink or grow a block of memory to the given `new_size`.
206+
/// Shrink or grow a block of memory to the given `new_size` in bytes.
207207
/// The block is described by the given `ptr` pointer and `layout`.
208208
///
209209
/// If this returns a non-null pointer, then ownership of the memory block
210210
/// referenced by `ptr` has been transferred to this allocator.
211211
/// Any access to the old `ptr` is Undefined Behavior, even if the
212212
/// allocation remained in-place. The newly returned pointer is the only valid pointer
213213
/// for accessing this memory now.
214+
///
214215
/// The new memory block is allocated with `layout`,
215-
/// but with the `size` updated to `new_size`. This new layout must be
216-
/// used when deallocating the new memory block with `dealloc`. The range
217-
/// `0..min(layout.size(), new_size)` of the new memory block is
216+
/// but with the `size` updated to `new_size` in bytes.
217+
/// This new layout must be used when deallocating the new memory block with `dealloc`.
218+
/// The range `0..min(layout.size(), new_size)` of the new memory block is
218219
/// guaranteed to have the same values as the original block.
219220
///
220221
/// If this method returns null, then ownership of the memory

0 commit comments

Comments
 (0)