Skip to content

Commit 45ef012

Browse files
committed
use nallocx instead of sallocx
1 parent f39594d commit 45ef012

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

src/liballoc_jemalloc/lib.rs

+6-21
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ mod contents {
6767
target_os = "dragonfly", target_os = "windows", target_env = "musl"),
6868
link_name = "je_nallocx")]
6969
fn nallocx(size: size_t, flags: c_int) -> size_t;
70-
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
71-
target_os = "dragonfly", target_os = "windows", target_env = "musl"),
72-
link_name = "je_sallocx")]
73-
fn sallocx(ptr: *mut c_void, flags: c_int) -> size_t;
7470
}
7571

7672
const MALLOCX_ZERO: c_int = 0x40;
@@ -215,29 +211,18 @@ mod contents {
215211
#[no_mangle]
216212
#[linkage = "external"]
217213
pub unsafe extern fn __rde_realloc_excess(ptr: *mut u8,
218-
_old_size: usize,
214+
old_size: usize,
219215
old_align: usize,
220216
new_size: usize,
221217
new_align: usize,
222218
excess: *mut usize,
223219
err: *mut u8) -> *mut u8 {
224-
if new_align != old_align {
225-
ptr::write(err as *mut AllocErr,
226-
AllocErr::Unsupported { details: "can't change alignments" });
227-
return 0 as *mut u8
228-
}
229-
230-
let flags = align_to_flags(new_align);
231-
let ptr = rallocx(ptr as *mut c_void, new_size, flags) as *mut u8;
232-
if ptr.is_null() {
233-
let layout = Layout::from_size_align_unchecked(new_size, new_align);
234-
ptr::write(err as *mut AllocErr,
235-
AllocErr::Exhausted { request: layout });
236-
} else {
237-
let alloc_size = sallocx(ptr as *mut c_void, flags);
238-
*excess = alloc_size;
220+
let p = __rde_realloc(ptr, old_size, old_align, new_size, new_align, err);
221+
if !p.is_null() {
222+
let flags = align_to_flags(new_align);
223+
*excess = nallocx(new_size, flags) as usize;
239224
}
240-
ptr
225+
p
241226
}
242227

243228
#[no_mangle]

0 commit comments

Comments
 (0)