fix(napi): napi_adjust_external_memory should be hidden with wasm target (#2031)
This commit is contained in:
parent
5570d8b4f7
commit
e86e3add2b
2 changed files with 19 additions and 15 deletions
|
@ -141,23 +141,26 @@ impl<T: 'static> ToNapiValue for External<T> {
|
||||||
"Create external value failed"
|
"Create external value failed"
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let mut adjusted_external_memory_size = std::mem::MaybeUninit::new(0);
|
#[cfg(not(target_family = "wasm"))]
|
||||||
|
{
|
||||||
|
let mut adjusted_external_memory_size = std::mem::MaybeUninit::new(0);
|
||||||
|
|
||||||
if size_hint != 0 {
|
if size_hint != 0 {
|
||||||
check_status!(
|
check_status!(
|
||||||
unsafe {
|
unsafe {
|
||||||
sys::napi_adjust_external_memory(
|
sys::napi_adjust_external_memory(
|
||||||
env,
|
env,
|
||||||
size_hint,
|
size_hint,
|
||||||
adjusted_external_memory_size.as_mut_ptr(),
|
adjusted_external_memory_size.as_mut_ptr(),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
"Adjust external memory failed"
|
"Adjust external memory failed"
|
||||||
)?;
|
)?;
|
||||||
};
|
};
|
||||||
|
|
||||||
(Box::leak(unsafe { Box::from_raw(obj_ptr) })).adjusted_size =
|
(Box::leak(unsafe { Box::from_raw(obj_ptr) })).adjusted_size =
|
||||||
unsafe { adjusted_external_memory_size.assume_init() };
|
unsafe { adjusted_external_memory_size.assume_init() };
|
||||||
|
}
|
||||||
|
|
||||||
Ok(napi_value)
|
Ok(napi_value)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1407,6 +1407,7 @@ pub(crate) unsafe extern "C" fn raw_finalize<T>(
|
||||||
) {
|
) {
|
||||||
let tagged_object = finalize_data as *mut T;
|
let tagged_object = finalize_data as *mut T;
|
||||||
drop(unsafe { Box::from_raw(tagged_object) });
|
drop(unsafe { Box::from_raw(tagged_object) });
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
if !finalize_hint.is_null() {
|
if !finalize_hint.is_null() {
|
||||||
let size_hint = unsafe { *Box::from_raw(finalize_hint as *mut i64) };
|
let size_hint = unsafe { *Box::from_raw(finalize_hint as *mut i64) };
|
||||||
if size_hint != 0 {
|
if size_hint != 0 {
|
||||||
|
|
Loading…
Reference in a new issue