]> git.lizzy.rs Git - rust.git/commitdiff
move sallocx and excess into not null branch
authorgnzlbg <gonzalobg88@gmail.com>
Wed, 25 Oct 2017 12:46:02 +0000 (14:46 +0200)
committergnzlbg <gonzalobg88@gmail.com>
Wed, 25 Oct 2017 12:46:02 +0000 (14:46 +0200)
src/liballoc_jemalloc/lib.rs

index c10af35a94bb93f544efb12e12638e395592a379..09666bd0e62ee6f969fdf11fa4504c6ea191136f 100644 (file)
@@ -229,13 +229,14 @@ fn align_to_flags(align: usize) -> c_int {
 
         let flags = align_to_flags(new_align);
         let ptr = rallocx(ptr as *mut c_void, new_size, flags) as *mut u8;
-        let alloc_size = sallocx(ptr as *mut c_void, flags);
         if ptr.is_null() {
             let layout = Layout::from_size_align_unchecked(new_size, new_align);
             ptr::write(err as *mut AllocErr,
                        AllocErr::Exhausted { request: layout });
+        } else {
+            let alloc_size = sallocx(ptr as *mut c_void, flags);
+            *excess = alloc_size;
         }
-        *excess = alloc_size;
         ptr
     }