Clarify new_size for realloc means bytes

This commit is contained in:
Jubilee 2023-02-09 23:56:20 -08:00 committed by GitHub
parent a697573463
commit 1af9b4f347
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -203,7 +203,7 @@ pub unsafe trait GlobalAlloc {
ptr 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`. /// The block is described by the given `ptr` pointer and `layout`.
/// ///
/// If this returns a non-null pointer, then ownership of the memory block /// If this returns a non-null pointer, then ownership of the memory block
@ -211,10 +211,11 @@ pub unsafe trait GlobalAlloc {
/// Any access to the old `ptr` is Undefined Behavior, even if the /// 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 /// allocation remained in-place. The newly returned pointer is the only valid pointer
/// for accessing this memory now. /// for accessing this memory now.
///
/// The new memory block is allocated with `layout`, /// The new memory block is allocated with `layout`,
/// but with the `size` updated to `new_size`. This new layout must be /// but with the `size` updated to `new_size` in bytes.
/// used when deallocating the new memory block with `dealloc`. The range /// This new layout must be used when deallocating the new memory block with `dealloc`.
/// `0..min(layout.size(), new_size)` of the new memory block is /// The range `0..min(layout.size(), new_size)` of the new memory block is
/// guaranteed to have the same values as the original block. /// guaranteed to have the same values as the original block.
/// ///
/// If this method returns null, then ownership of the memory /// If this method returns null, then ownership of the memory