avoid closure to be dropped in release mode (#116)

This commit is contained in:
Ivan FB 2025-03-05 09:39:15 +01:00 committed by GitHub
parent 9c9900897e
commit 1d95d05dd7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -52,9 +52,9 @@ macro_rules! handle_ffi_call {
notify_clone.notify_one();
};
let mut closure = result_cb;
// Create trampoline and invoke the `waku_sys` function
let code = unsafe {
let mut closure = result_cb;
let cb = get_trampoline(&closure);
$waku_fn(
$ctx, // Pass the context

View File

@ -33,8 +33,8 @@ pub async fn waku_new(config: Option<WakuNodeConfig>) -> Result<WakuNodeContext>
result = r;
notify_clone.notify_one(); // Notify that the value has been updated
};
let mut closure = result_cb;
let obj_ptr = unsafe {
let mut closure = result_cb;
let cb = get_trampoline(&closure);
waku_sys::waku_new(config_ptr, cb, &mut closure as *mut _ as *mut c_void)
};