use nallocx instead of sallocx

This commit is contained in:
gnzlbg 2017-10-25 20:22:08 +02:00
parent f39594d4bb
commit 45ef012699

View File

@ -67,10 +67,6 @@ mod contents {
target_os = "dragonfly", target_os = "windows", target_env = "musl"),
link_name = "je_nallocx")]
fn nallocx(size: size_t, flags: c_int) -> size_t;
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
target_os = "dragonfly", target_os = "windows", target_env = "musl"),
link_name = "je_sallocx")]
fn sallocx(ptr: *mut c_void, flags: c_int) -> size_t;
}
const MALLOCX_ZERO: c_int = 0x40;
@ -215,29 +211,18 @@ mod contents {
#[no_mangle]
#[linkage = "external"]
pub unsafe extern fn __rde_realloc_excess(ptr: *mut u8,
_old_size: usize,
old_size: usize,
old_align: usize,
new_size: usize,
new_align: usize,
excess: *mut usize,
err: *mut u8) -> *mut u8 {
if new_align != old_align {
ptr::write(err as *mut AllocErr,
AllocErr::Unsupported { details: "can't change alignments" });
return 0 as *mut u8
let p = __rde_realloc(ptr, old_size, old_align, new_size, new_align, err);
if !p.is_null() {
let flags = align_to_flags(new_align);
*excess = nallocx(new_size, flags) as usize;
}
let flags = align_to_flags(new_align);
let ptr = rallocx(ptr as *mut c_void, new_size, flags) as *mut u8;
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;
}
ptr
p
}
#[no_mangle]