about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJubilee <46493976+workingjubilee@users.noreply.github.com>2023-02-09 23:56:20 -0800
committerGitHub <noreply@github.com>2023-02-09 23:56:20 -0800
commit1af9b4f347c1ca725e43444e0068b5e520dde7e2 (patch)
tree1a1d09ced1ee4c5f88fc1038eae2fea10193d933
parenta6975734632c4771edd45ef10e7d4753541d0f3a (diff)
downloadrust-1af9b4f347c1ca725e43444e0068b5e520dde7e2.tar.gz
rust-1af9b4f347c1ca725e43444e0068b5e520dde7e2.zip
Clarify `new_size` for realloc means bytes
-rw-r--r--library/core/src/alloc/global.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/library/core/src/alloc/global.rs b/library/core/src/alloc/global.rs
index 1d80b8bf9ec..18da70451f2 100644
--- a/library/core/src/alloc/global.rs
+++ b/library/core/src/alloc/global.rs
@@ -203,7 +203,7 @@ 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
@@ -211,10 +211,11 @@ pub unsafe trait GlobalAlloc {
     /// 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