]> git.lizzy.rs Git - rust.git/commitdiff
More alloc docs tweaks
authorSimon Sapin <simon.sapin@exyr.org>
Fri, 1 Jun 2018 07:18:25 +0000 (09:18 +0200)
committerSimon Sapin <simon.sapin@exyr.org>
Mon, 11 Jun 2018 20:48:57 +0000 (13:48 -0700)
src/liballoc/alloc.rs
src/libcore/alloc.rs

index fef668d2365a80a57d96a0d33b99ba7ce7bd47ec..04c8063ffebc5dbc613fab0bfc48f9d35b80c16a 100644 (file)
@@ -184,8 +184,10 @@ pub(crate) unsafe fn box_free<T: ?Sized>(ptr: Unique<T>) {
 ///
 /// The default behavior of this function is to print a message to standard error
 /// and abort the process.
-/// It can be replaced with [`std::alloc::set_oom_hook`]
-/// and [`std::alloc::take_oom_hook`].
+/// It can be replaced with [`set_oom_hook`] and [`take_oom_hook`].
+///
+/// [`set_oom_hook`]: ../../std/alloc/fn.set_oom_hook.html
+/// [`take_oom_hook`]: ../../std/alloc/fn.take_oom_hook.html
 #[stable(feature = "global_alloc", since = "1.28.0")]
 #[rustc_allocator_nounwind]
 pub fn oom(layout: Layout) -> ! {
index b0ac43e50f5e66e817933abb7f25e01284fabab3..353688d1b85583bd3b2f18e23049aee16872e062 100644 (file)
@@ -494,6 +494,8 @@ pub unsafe trait GlobalAlloc {
     /// Clients wishing to abort computation in response to an
     /// allocation error are encouraged to call the [`oom`] function,
     /// rather than directly invoking `panic!` or similar.
+    ///
+    /// [`oom`]: ../../alloc/alloc/fn.oom.html
     #[stable(feature = "global_alloc", since = "1.28.0")]
     unsafe fn alloc(&self, layout: Layout) -> *mut u8;
 
@@ -529,6 +531,8 @@ pub unsafe trait GlobalAlloc {
     /// Clients wishing to abort computation in response to an
     /// allocation error are encouraged to call the [`oom`] function,
     /// rather than directly invoking `panic!` or similar.
+    ///
+    /// [`oom`]: ../../alloc/alloc/fn.oom.html
     #[stable(feature = "global_alloc", since = "1.28.0")]
     unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
         let size = layout.size();
@@ -587,6 +591,8 @@ unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
     /// Clients wishing to abort computation in response to a
     /// reallocation error are encouraged to call the [`oom`] function,
     /// rather than directly invoking `panic!` or similar.
+    ///
+    /// [`oom`]: ../../alloc/alloc/fn.oom.html
     #[stable(feature = "global_alloc", since = "1.28.0")]
     unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
         let new_layout = Layout::from_size_align_unchecked(new_size, layout.align());
@@ -727,8 +733,10 @@ pub unsafe trait Alloc {
     /// library that aborts on memory exhaustion.)
     ///
     /// Clients wishing to abort computation in response to an
-    /// allocation error are encouraged to call the `oom` function,
+    /// allocation error are encouraged to call the [`oom`] function,
     /// rather than directly invoking `panic!` or similar.
+    ///
+    /// [`oom`]: ../../alloc/alloc/fn.oom.html
     unsafe fn alloc(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocErr>;
 
     /// Deallocate the memory referenced by `ptr`.
@@ -837,6 +845,8 @@ fn usable_size(&self, layout: &Layout) -> (usize, usize) {
     /// Clients wishing to abort computation in response to a
     /// reallocation error are encouraged to call the [`oom`] function,
     /// rather than directly invoking `panic!` or similar.
+    ///
+    /// [`oom`]: ../../alloc/alloc/fn.oom.html
     unsafe fn realloc(&mut self,
                       ptr: NonNull<u8>,
                       layout: Layout,
@@ -881,6 +891,8 @@ unsafe fn realloc(&mut self,
     /// Clients wishing to abort computation in response to an
     /// allocation error are encouraged to call the [`oom`] function,
     /// rather than directly invoking `panic!` or similar.
+    ///
+    /// [`oom`]: ../../alloc/alloc/fn.oom.html
     unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocErr> {
         let size = layout.size();
         let p = self.alloc(layout);
@@ -907,6 +919,8 @@ unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocEr
     /// Clients wishing to abort computation in response to an
     /// allocation error are encouraged to call the [`oom`] function,
     /// rather than directly invoking `panic!` or similar.
+    ///
+    /// [`oom`]: ../../alloc/alloc/fn.oom.html
     unsafe fn alloc_excess(&mut self, layout: Layout) -> Result<Excess, AllocErr> {
         let usable_size = self.usable_size(&layout);
         self.alloc(layout).map(|p| Excess(p, usable_size.1))
@@ -929,6 +943,8 @@ unsafe fn alloc_excess(&mut self, layout: Layout) -> Result<Excess, AllocErr> {
     /// Clients wishing to abort computation in response to a
     /// reallocation error are encouraged to call the [`oom`] function,
     /// rather than directly invoking `panic!` or similar.
+    ///
+    /// [`oom`]: ../../alloc/alloc/fn.oom.html
     unsafe fn realloc_excess(&mut self,
                              ptr: NonNull<u8>,
                              layout: Layout,
@@ -1076,6 +1092,8 @@ unsafe fn shrink_in_place(&mut self,
     /// Clients wishing to abort computation in response to an
     /// allocation error are encouraged to call the [`oom`] function,
     /// rather than directly invoking `panic!` or similar.
+    ///
+    /// [`oom`]: ../../alloc/alloc/fn.oom.html
     fn alloc_one<T>(&mut self) -> Result<NonNull<T>, AllocErr>
         where Self: Sized
     {
@@ -1143,6 +1161,8 @@ unsafe fn dealloc_one<T>(&mut self, ptr: NonNull<T>)
     /// Clients wishing to abort computation in response to an
     /// allocation error are encouraged to call the [`oom`] function,
     /// rather than directly invoking `panic!` or similar.
+    ///
+    /// [`oom`]: ../../alloc/alloc/fn.oom.html
     fn alloc_array<T>(&mut self, n: usize) -> Result<NonNull<T>, AllocErr>
         where Self: Sized
     {
@@ -1188,6 +1208,8 @@ fn alloc_array<T>(&mut self, n: usize) -> Result<NonNull<T>, AllocErr>
     /// Clients wishing to abort computation in response to a
     /// reallocation error are encouraged to call the [`oom`] function,
     /// rather than directly invoking `panic!` or similar.
+    ///
+    /// [`oom`]: ../../alloc/alloc/fn.oom.html
     unsafe fn realloc_array<T>(&mut self,
                                ptr: NonNull<T>,
                                n_old: usize,