avoid closure to be dropped in release mode

This commit is contained in:
Ivan Folgueira Bande 2025-03-04 12:12:57 +01:00
parent 9c9900897e
commit 4c0c6e66ac
No known key found for this signature in database
GPG Key ID: 3C117481F89E24A7
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)
};