Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit 68719e8

Browse files
authored
WAL hook functions now invoke generic T:WalHook methods (#603)
1 parent 88998dc commit 68719e8

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sqld-libsql-bindings/src/wal_hook.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,10 @@ pub extern "C" fn xSavepoint<T: WalHook>(wal: *mut Wal, wal_data: *mut u32) {
310310

311311
#[allow(non_snake_case)]
312312
pub extern "C" fn xSavepointUndo<T: WalHook>(wal: *mut Wal, wal_data: *mut u32) -> i32 {
313-
let orig_methods = unsafe { get_orig_methods::<T>(&mut *wal) };
314-
unsafe { (orig_methods.xSavepointUndo.unwrap())(wal, wal_data) }
313+
let wal = unsafe { &mut *wal };
314+
let orig_methods = get_orig_methods::<T>(wal);
315+
let orig_xsavepointundo = orig_methods.xSavepointUndo.unwrap();
316+
T::on_savepoint_undo(wal, wal_data, orig_xsavepointundo)
315317
}
316318

317319
#[allow(non_snake_case)]
@@ -353,21 +355,22 @@ pub extern "C" fn xCheckpoint<T: WalHook>(
353355
frames_in_wal: *mut c_int,
354356
backfilled_frames: *mut c_int,
355357
) -> i32 {
356-
let orig_methods = unsafe { get_orig_methods::<T>(&mut *wal) };
357-
unsafe {
358-
(orig_methods.xCheckpoint.unwrap())(
359-
wal,
360-
db,
361-
emode,
362-
busy_handler,
363-
busy_arg,
364-
sync_flags,
365-
n_buf,
366-
z_buf,
367-
frames_in_wal,
368-
backfilled_frames,
369-
)
370-
}
358+
let wal = unsafe { &mut *wal };
359+
let orig_methods = get_orig_methods::<T>(wal);
360+
let orig_xcheckpoint = orig_methods.xCheckpoint.unwrap();
361+
T::on_checkpoint(
362+
wal,
363+
db,
364+
emode,
365+
busy_handler,
366+
busy_arg,
367+
sync_flags,
368+
n_buf,
369+
z_buf,
370+
frames_in_wal,
371+
backfilled_frames,
372+
orig_xcheckpoint,
373+
)
371374
}
372375

373376
#[allow(non_snake_case)]

0 commit comments

Comments
 (0)