mirror of
https://github.com/isar/rusqlite.git
synced 2025-10-18 21:53:33 +08:00
Fix up conventions around unsafe in internal functions
This commit is contained in:
@@ -53,10 +53,10 @@ unsafe extern "C" fn unlock_notify_cb(ap_arg: *mut *mut c_void, n_arg: c_int) {
|
||||
}
|
||||
|
||||
#[cfg(feature = "unlock_notify")]
|
||||
pub fn is_locked(db: *mut ffi::sqlite3, rc: c_int) -> bool {
|
||||
pub unsafe fn is_locked(db: *mut ffi::sqlite3, rc: c_int) -> bool {
|
||||
rc == ffi::SQLITE_LOCKED_SHAREDCACHE
|
||||
|| (rc & 0xFF) == ffi::SQLITE_LOCKED
|
||||
&& unsafe { ffi::sqlite3_extended_errcode(db) } == ffi::SQLITE_LOCKED_SHAREDCACHE
|
||||
&& ffi::sqlite3_extended_errcode(db) == ffi::SQLITE_LOCKED_SHAREDCACHE
|
||||
}
|
||||
|
||||
/// This function assumes that an SQLite API call (either `sqlite3_prepare_v2()`
|
||||
@@ -72,16 +72,14 @@ pub fn is_locked(db: *mut ffi::sqlite3, rc: c_int) -> bool {
|
||||
/// this case the caller should not retry the operation and should roll
|
||||
/// back the current transaction (if any).
|
||||
#[cfg(feature = "unlock_notify")]
|
||||
pub fn wait_for_unlock_notify(db: *mut ffi::sqlite3) -> c_int {
|
||||
pub unsafe fn wait_for_unlock_notify(db: *mut ffi::sqlite3) -> c_int {
|
||||
let mut un = UnlockNotification::new();
|
||||
/* Register for an unlock-notify callback. */
|
||||
let rc = unsafe {
|
||||
ffi::sqlite3_unlock_notify(
|
||||
db,
|
||||
Some(unlock_notify_cb),
|
||||
&mut un as *mut UnlockNotification as *mut c_void,
|
||||
)
|
||||
};
|
||||
let rc = ffi::sqlite3_unlock_notify(
|
||||
db,
|
||||
Some(unlock_notify_cb),
|
||||
&mut un as *mut UnlockNotification as *mut c_void,
|
||||
);
|
||||
debug_assert!(
|
||||
rc == ffi::SQLITE_LOCKED || rc == ffi::SQLITE_LOCKED_SHAREDCACHE || rc == ffi::SQLITE_OK
|
||||
);
|
||||
@@ -92,12 +90,12 @@ pub fn wait_for_unlock_notify(db: *mut ffi::sqlite3) -> c_int {
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "unlock_notify"))]
|
||||
pub fn is_locked(_db: *mut ffi::sqlite3, _rc: c_int) -> bool {
|
||||
pub unsafe fn is_locked(_db: *mut ffi::sqlite3, _rc: c_int) -> bool {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "unlock_notify"))]
|
||||
pub fn wait_for_unlock_notify(_db: *mut ffi::sqlite3) -> c_int {
|
||||
pub unsafe fn wait_for_unlock_notify(_db: *mut ffi::sqlite3) -> c_int {
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user