summaryrefslogtreecommitdiff
path: root/test_napi/src
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-05-03 00:36:33 +0200
committerGitHub <noreply@github.com>2023-05-03 00:36:33 +0200
commit798c1ad0f1de80ff0e7196b6140a3f74e31fe111 (patch)
tree44233e68b9846ee3335b68b3ddaff00bec76d91f /test_napi/src
parentadcda4fa640939682076e793f12a5b22e3de1f50 (diff)
perf: use jemalloc as global allocator (#18957)
Follow up to https://github.com/denoland/deno/pull/18875 that enables `jemalloc` as a global allocator for the Deno CLI.
Diffstat (limited to 'test_napi/src')
-rw-r--r--test_napi/src/async.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/test_napi/src/async.rs b/test_napi/src/async.rs
index 51e6edac9..970d34ce1 100644
--- a/test_napi/src/async.rs
+++ b/test_napi/src/async.rs
@@ -49,7 +49,6 @@ unsafe extern "C" fn complete(
ptr::null(),
&mut _result
));
-
assert_napi_ok!(napi_delete_reference(env, baton.func));
assert_napi_ok!(napi_delete_async_work(env, baton.task));
}
@@ -73,7 +72,7 @@ extern "C" fn test_async_work(
&mut resource_name,
));
- let mut async_work: napi_async_work = ptr::null_mut();
+ let async_work: napi_async_work = ptr::null_mut();
let mut func: napi_ref = ptr::null_mut();
assert_napi_ok!(napi_create_reference(env, args[0], 1, &mut func));
@@ -82,6 +81,8 @@ extern "C" fn test_async_work(
func,
task: async_work,
});
+ let mut async_work = baton.task;
+ let baton_ptr = Box::into_raw(baton) as *mut c_void;
assert_napi_ok!(napi_create_async_work(
env,
@@ -89,9 +90,12 @@ extern "C" fn test_async_work(
resource_name,
Some(execute),
Some(complete),
- Box::into_raw(baton) as *mut c_void,
+ baton_ptr,
&mut async_work,
));
+ let mut baton = unsafe { Box::from_raw(baton_ptr as *mut Baton) };
+ baton.task = async_work;
+ Box::into_raw(baton);
assert_napi_ok!(napi_queue_async_work(env, async_work));
ptr::null_mut()