MCPcopy Create free account
hub / github.com/asg017/sqlite-loadable-rs / compare_function_wrapper

Function compare_function_wrapper

src/collation.rs:19–33  ·  view source on GitHub ↗
(
        func: *mut std::os::raw::c_void,
        a_size: std::os::raw::c_int,
        a_pointer: *const std::os::raw::c_void,
        b_size: std::os::raw::c_int,
        b_pointer: *const ::std::os

Source from the content-addressed store, hash-verified

17 let function_pointer: *mut F = Box::into_raw(Box::new(x_func));
18
19 unsafe extern "C" fn compare_function_wrapper<F>(
20 func: *mut std::os::raw::c_void,
21 a_size: std::os::raw::c_int,
22 a_pointer: *const std::os::raw::c_void,
23 b_size: std::os::raw::c_int,
24 b_pointer: *const ::std::os::raw::c_void,
25 ) -> i32
26 where
27 F: Fn(&[u8], &[u8]) -> i32,
28 {
29 let boxed_function: *mut F = func.cast::<F>();
30 let a = std::slice::from_raw_parts(a_pointer as *const u8, a_size as usize);
31 let b = std::slice::from_raw_parts(b_pointer as *const u8, b_size as usize);
32 (*boxed_function)(a, b)
33 }
34 let cname = CString::new(name)?;
35 let result = unsafe {
36 sqlite3ext_collation_v2(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected