From d8e3557dbae23283f81d7bc45200413dd93ced4a Mon Sep 17 00:00:00 2001 From: Tim Diekmann Date: Tue, 3 Mar 2020 00:08:24 +0100 Subject: Remove `usable_size` APIs --- src/liballoc/alloc.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/liballoc/alloc.rs') 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, AllocErr> { - NonNull::new(alloc(layout)).ok_or(AllocErr) + unsafe fn alloc(&mut self, layout: Layout) -> Result<(NonNull, 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, layout: Layout, new_size: usize, - ) -> Result, AllocErr> { - NonNull::new(realloc(ptr.as_ptr(), layout, new_size)).ok_or(AllocErr) + ) -> Result<(NonNull, 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, AllocErr> { - NonNull::new(alloc_zeroed(layout)).ok_or(AllocErr) + unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<(NonNull, 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), } } -- cgit 1.4.1-3-g733a5