Skip to content

Commit

Permalink
Clarify new_size for realloc means bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
workingjubilee authored Feb 10, 2023
1 parent a697573 commit 1af9b4f
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 1af9b4f

Please sign in to comment.