Skip to content

Commit f39594d

Browse files
committed
move sallocx and excess into not null branch
1 parent e1a71e7 commit f39594d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/liballoc_jemalloc/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,14 @@ mod contents {
229229

230230
let flags = align_to_flags(new_align);
231231
let ptr = rallocx(ptr as *mut c_void, new_size, flags) as *mut u8;
232-
let alloc_size = sallocx(ptr as *mut c_void, flags);
233232
if ptr.is_null() {
234233
let layout = Layout::from_size_align_unchecked(new_size, new_align);
235234
ptr::write(err as *mut AllocErr,
236235
AllocErr::Exhausted { request: layout });
236+
} else {
237+
let alloc_size = sallocx(ptr as *mut c_void, flags);
238+
*excess = alloc_size;
237239
}
238-
*excess = alloc_size;
239240
ptr
240241
}
241242

0 commit comments

Comments
 (0)