diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2018-04-04 18:09:39 +0200 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2018-04-12 22:53:14 +0200 |
| commit | 747cc749430d66bd2fca8e81fd8a1c994e36dcf1 (patch) | |
| tree | ba50ae6ca9a8e021439f2c643a0fc785d42c58c3 /src/liballoc_system | |
| parent | c957e99b305ecee113442a7ce0edd6b565200ca9 (diff) | |
| download | rust-747cc749430d66bd2fca8e81fd8a1c994e36dcf1.tar.gz rust-747cc749430d66bd2fca8e81fd8a1c994e36dcf1.zip | |
Conversions between Result<*mut u8, AllocErr>> and *mut Void
Diffstat (limited to 'src/liballoc_system')
| -rw-r--r-- | src/liballoc_system/lib.rs | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index 7b788a5f989..6ffbd029281 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -139,22 +139,12 @@ macro_rules! alloc_methods_based_on_global_alloc { () => { #[inline] unsafe fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> { - let ptr = GlobalAlloc::alloc(*self, layout); - if !ptr.is_null() { - Ok(ptr as *mut u8) - } else { - Err(AllocErr) - } + GlobalAlloc::alloc(*self, layout).into() } #[inline] unsafe fn alloc_zeroed(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> { - let ptr = GlobalAlloc::alloc_zeroed(*self, layout); - if !ptr.is_null() { - Ok(ptr as *mut u8) - } else { - Err(AllocErr) - } + GlobalAlloc::alloc_zeroed(*self, layout).into() } #[inline] @@ -167,12 +157,7 @@ macro_rules! alloc_methods_based_on_global_alloc { ptr: *mut u8, old_layout: Layout, new_size: usize) -> Result<*mut u8, AllocErr> { - let ptr = GlobalAlloc::realloc(*self, ptr as *mut Void, old_layout, new_size); - if !ptr.is_null() { - Ok(ptr as *mut u8) - } else { - Err(AllocErr) - } + GlobalAlloc::realloc(*self, ptr as *mut Void, old_layout, new_size).into() } } } |
