about summary refs log tree commit diff
path: root/src/liballoc/alloc.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-03-03 10:18:57 +0000
committerbors <bors@rust-lang.org>2020-03-03 10:18:57 +0000
commita5de254862477924bcd8b9e1bff7eadd6ffb5e2a (patch)
tree6d30e786044c654a5478545b69a9f8792e856655 /src/liballoc/alloc.rs
parent9381e8178b49636d4604e4ec0f1263960691c958 (diff)
parente453a0cc49ad83fbb54fb22f9bba7545f5a92c68 (diff)
downloadrust-a5de254862477924bcd8b9e1bff7eadd6ffb5e2a.tar.gz
rust-a5de254862477924bcd8b9e1bff7eadd6ffb5e2a.zip
Auto merge of #69666 - JohnTitor:rollup-6nt3op0, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #69213 (Improve documentation on iterators length)
 - #69609 (Remove `usable_size` APIs)
 - #69619 (more cleanups)
 - #69620 (doc(librustc_error_codes): add long error explanation for E0719)
 - #69626 (Toolstate: don't duplicate nightly tool list.)
 - #69628 (Fix a leak in `DiagnosticBuilder::into_diagnostic`.)
 - #69633 (Update my mailmap entry)
 - #69634 (clean up E0378 explanation)
 - #69637 (Don't convert Results to Options just for matching.)

Failed merges:

r? @ghost
Diffstat (limited to 'src/liballoc/alloc.rs')
-rw-r--r--src/liballoc/alloc.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/liballoc/alloc.rs b/src/liballoc/alloc.rs
index f41404bf8ca..73e8121868a 100644
--- a/src/liballoc/alloc.rs
+++ b/src/liballoc/alloc.rs
@@ -165,8 +165,8 @@ pub unsafe fn alloc_zeroed(layout: Layout) -> *mut u8 {
 #[unstable(feature = "allocator_api", issue = "32838")]
 unsafe impl AllocRef for Global {
     #[inline]
-    unsafe fn alloc(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocErr> {
-        NonNull::new(alloc(layout)).ok_or(AllocErr)
+    unsafe fn alloc(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
+        NonNull::new(alloc(layout)).ok_or(AllocErr).map(|p| (p, layout.size()))
     }
 
     #[inline]
@@ -180,13 +180,13 @@ unsafe impl AllocRef for Global {
         ptr: NonNull<u8>,
         layout: Layout,
         new_size: usize,
-    ) -> Result<NonNull<u8>, AllocErr> {
-        NonNull::new(realloc(ptr.as_ptr(), layout, new_size)).ok_or(AllocErr)
+    ) -> Result<(NonNull<u8>, usize), AllocErr> {
+        NonNull::new(realloc(ptr.as_ptr(), layout, new_size)).ok_or(AllocErr).map(|p| (p, new_size))
     }
 
     #[inline]
-    unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocErr> {
-        NonNull::new(alloc_zeroed(layout)).ok_or(AllocErr)
+    unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
+        NonNull::new(alloc_zeroed(layout)).ok_or(AllocErr).map(|p| (p, layout.size()))
     }
 }
 
@@ -201,7 +201,7 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
     } else {
         let layout = Layout::from_size_align_unchecked(size, align);
         match Global.alloc(layout) {
-            Ok(ptr) => ptr.as_ptr(),
+            Ok((ptr, _)) => ptr.as_ptr(),
             Err(_) => handle_alloc_error(layout),
         }
     }