Skip to content

Commit

Permalink
Rollup merge of #107878 - workingjubilee:new-size-means-bytes, r=scot…
Browse files Browse the repository at this point in the history
…tmcm

Clarify `new_size` for realloc means bytes

Minor docs fix requested by #107875
  • Loading branch information
Dylan-DPC authored Feb 11, 2023
2 parents 2228c86 + 1af9b4f commit dfc2422
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 dfc2422

Please sign in to comment.