about summary refs log tree commit diff
path: root/src/libcore/alloc
diff options
context:
space:
mode:
authorTim Diekmann <21277928+TimDiekmann@users.noreply.github.com>2020-03-26 10:02:36 +0100
committerTim Diekmann <tim.diekmann@3dvision.de>2020-03-26 17:14:23 +0100
commit717e0c7b9d4b9fd8a1a3c7451255d30c194c7b3e (patch)
treeb5623efdabf10c29ef1545bae72cc3ad2a331d20 /src/libcore/alloc
parent03b055b0b4dcf304cd3c5e7a1c6e68fea91584a9 (diff)
downloadrust-717e0c7b9d4b9fd8a1a3c7451255d30c194c7b3e.tar.gz
rust-717e0c7b9d4b9fd8a1a3c7451255d30c194c7b3e.zip
Apply suggestions from code review
Co-Authored-By: Amanieu d'Antras <amanieu@gmail.com>
Diffstat (limited to 'src/libcore/alloc')
-rw-r--r--src/libcore/alloc/mod.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/libcore/alloc/mod.rs b/src/libcore/alloc/mod.rs
index cdb213fe104..d5e89f333f1 100644
--- a/src/libcore/alloc/mod.rs
+++ b/src/libcore/alloc/mod.rs
@@ -221,21 +221,22 @@ pub unsafe trait AllocRef {
     /// allocation referenced by `ptr` to fit the new layout. If the [`placement`] is
     /// [`InPlace`], the returned pointer is guaranteed to be the same as the passed `ptr`.
     ///
-    /// If this returns `Ok`, then ownership of the memory block referenced by `ptr` has been
-    /// transferred to this allocator. The memory may or may not have been freed, and should be
-    /// considered unusable (unless of course it was transferred back to the caller again via the
+    /// If `ReallocPlacement::MayMove` is used then ownership of the memory block referenced by `ptr`
+    /// is transferred to this allocator. The memory may or may not be freed, and should be
+    /// considered unusable (unless of course it is transferred back to the caller again via the
     /// return value of this method).
     ///
     /// If this method returns `Err`, then ownership of the memory block has not been transferred to
     /// this allocator, and the contents of the memory block are unaltered.
     ///
-    /// The behavior of how the allocator tries to grow the memory is specified by [`placement`].
-    /// After growing a memory block, the new memory can be separated into three regions:
-    ///   1. `0..layout.size()`. This region is preserved or copied as appropriate from `ptr`.
-    ///   2. `layout.size()..allocated_size` where `allocated_size` is the latest returned
-    ///       size of the allocator. The new content is implementation defined. Allocators may
-    ///       initialize it according to [`init`] or leave them as is.
-    ///   3. `allocated_size..returned_size` is initialized according to [`init`].
+    /// The memory block will contain the following contents after a successful call to `grow`:
+    ///   * Bytes `0..layout.size()` are preserved from the original allocation.
+    ///   * Bytes `layout.size()..old_size` will either be preserved or initialized according to
+    ///     [`init`], depending on the allocator implementation. `old_size` refers to the size of
+    ///     the `MemoryBlock` prior to the `grow` call, which may be larger than the size
+    ///     that was originally requested when it was allocated.
+    ///   * Bytes `old_size..new_size` are initialized according to [`init`]. `new_size` refers to
+    ///     the size of the `MemoryBlock` returned by the `grow` call.
     ///
     /// [`InPlace`]: ReallocPlacement::InPlace
     /// [`placement`]: ReallocPlacement