Skip to content

Commit

Permalink
Rollup merge of rust-lang#107878 - workingjubilee:new-size-means-byte…
Browse files Browse the repository at this point in the history
…s, r=scottmcm

Clarify `new_size` for realloc means bytes

Minor docs fix requested by rust-lang#107875
  • Loading branch information
matthiaskrgr committed Feb 10, 2023
2 parents 80d96b2 + 1af9b4f commit 3c8d9c5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions library/core/src/alloc/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,19 @@ pub unsafe trait GlobalAlloc {
ptr
}

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

0 comments on commit 3c8d9c5

Please sign in to comment.