mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-25 19:01:38 +08:00
clippy:ptr_as_ptr
This commit is contained in:
parent
5be363e4cc
commit
43591154b2
@ -318,8 +318,7 @@ impl io::Read for Blob<'_> {
|
||||
if n <= 0 {
|
||||
return Ok(0);
|
||||
}
|
||||
let rc =
|
||||
unsafe { ffi::sqlite3_blob_read(self.blob, buf.as_mut_ptr() as *mut _, n, self.pos) };
|
||||
let rc = unsafe { ffi::sqlite3_blob_read(self.blob, buf.as_mut_ptr().cast(), n, self.pos) };
|
||||
self.conn
|
||||
.decode_result(rc)
|
||||
.map(|_| {
|
||||
|
@ -47,7 +47,7 @@ impl<'conn> Blob<'conn> {
|
||||
self.conn.decode_result(unsafe {
|
||||
ffi::sqlite3_blob_write(
|
||||
self.blob,
|
||||
buf.as_ptr() as *const _,
|
||||
buf.as_ptr().cast(),
|
||||
buf.len() as i32,
|
||||
write_start as i32,
|
||||
)
|
||||
@ -84,7 +84,7 @@ impl<'conn> Blob<'conn> {
|
||||
// Safety: this is safe because `raw_read_at` never stores uninitialized
|
||||
// data into `as_uninit`.
|
||||
let as_uninit: &mut [MaybeUninit<u8>] =
|
||||
unsafe { from_raw_parts_mut(buf.as_mut_ptr() as *mut _, buf.len()) };
|
||||
unsafe { from_raw_parts_mut(buf.as_mut_ptr().cast(), buf.len()) };
|
||||
self.raw_read_at(as_uninit, read_start).map(|s| s.len())
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ impl<'conn> Blob<'conn> {
|
||||
// We could return `Ok(&mut [])`, but it seems confusing that the
|
||||
// pointers don't match, so fabricate a empty slice of u8 with the
|
||||
// same base pointer as `buf`.
|
||||
let empty = unsafe { from_raw_parts_mut(buf.as_mut_ptr() as *mut u8, 0) };
|
||||
let empty = unsafe { from_raw_parts_mut(buf.as_mut_ptr().cast::<u8>(), 0) };
|
||||
return Ok(empty);
|
||||
}
|
||||
|
||||
@ -152,12 +152,12 @@ impl<'conn> Blob<'conn> {
|
||||
unsafe {
|
||||
self.conn.decode_result(ffi::sqlite3_blob_read(
|
||||
self.blob,
|
||||
buf.as_mut_ptr() as *mut _,
|
||||
buf.as_mut_ptr().cast(),
|
||||
read_len as i32,
|
||||
read_start as i32,
|
||||
))?;
|
||||
|
||||
Ok(from_raw_parts_mut(buf.as_mut_ptr() as *mut u8, read_len))
|
||||
Ok(from_raw_parts_mut(buf.as_mut_ptr().cast::<u8>(), read_len))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ use crate::{str_to_cstring, Connection, InnerConnection, Result};
|
||||
|
||||
// FIXME copy/paste from function.rs
|
||||
unsafe extern "C" fn free_boxed_value<T>(p: *mut c_void) {
|
||||
drop(Box::from_raw(p as *mut T));
|
||||
drop(Box::from_raw(p.cast::<T>()));
|
||||
}
|
||||
|
||||
impl Connection {
|
||||
@ -57,14 +57,14 @@ impl InnerConnection {
|
||||
C: Fn(&str, &str) -> Ordering,
|
||||
{
|
||||
let r = catch_unwind(|| {
|
||||
let boxed_f: *mut C = arg1 as *mut C;
|
||||
let boxed_f: *mut C = arg1.cast::<C>();
|
||||
assert!(!boxed_f.is_null(), "Internal error - null function pointer");
|
||||
let s1 = {
|
||||
let c_slice = slice::from_raw_parts(arg3 as *const u8, arg2 as usize);
|
||||
let c_slice = slice::from_raw_parts(arg3.cast::<u8>(), arg2 as usize);
|
||||
String::from_utf8_lossy(c_slice)
|
||||
};
|
||||
let s2 = {
|
||||
let c_slice = slice::from_raw_parts(arg5 as *const u8, arg4 as usize);
|
||||
let c_slice = slice::from_raw_parts(arg5.cast::<u8>(), arg4 as usize);
|
||||
String::from_utf8_lossy(c_slice)
|
||||
};
|
||||
(*boxed_f)(s1.as_ref(), s2.as_ref())
|
||||
@ -91,7 +91,7 @@ impl InnerConnection {
|
||||
self.db(),
|
||||
c_name.as_ptr(),
|
||||
flags,
|
||||
boxed_f as *mut c_void,
|
||||
boxed_f.cast::<c_void>(),
|
||||
Some(call_boxed_closure::<C>),
|
||||
Some(free_boxed_value::<C>),
|
||||
)
|
||||
|
@ -62,7 +62,7 @@ pub(super) unsafe fn set_result(ctx: *mut sqlite3_context, result: &ToSqlOutput<
|
||||
} else {
|
||||
ffi::sqlite3_result_blob(
|
||||
ctx,
|
||||
b.as_ptr() as *const c_void,
|
||||
b.as_ptr().cast::<c_void>(),
|
||||
length as c_int,
|
||||
ffi::SQLITE_TRANSIENT(),
|
||||
);
|
||||
|
@ -101,7 +101,7 @@ unsafe fn report_error(ctx: *mut sqlite3_context, err: &Error) {
|
||||
}
|
||||
|
||||
unsafe extern "C" fn free_boxed_value<T>(p: *mut c_void) {
|
||||
drop(Box::from_raw(p as *mut T));
|
||||
drop(Box::from_raw(p.cast::<T>()));
|
||||
}
|
||||
|
||||
/// Context is a wrapper for the SQLite function
|
||||
@ -198,7 +198,7 @@ impl Context<'_> {
|
||||
ffi::sqlite3_set_auxdata(
|
||||
self.ctx,
|
||||
arg,
|
||||
raw as *mut _,
|
||||
raw.cast(),
|
||||
Some(free_boxed_value::<AuxInner>),
|
||||
)
|
||||
};
|
||||
@ -477,7 +477,7 @@ impl InnerConnection {
|
||||
T: ToSql,
|
||||
{
|
||||
let r = catch_unwind(|| {
|
||||
let boxed_f: *mut F = ffi::sqlite3_user_data(ctx) as *mut F;
|
||||
let boxed_f: *mut F = ffi::sqlite3_user_data(ctx).cast::<F>();
|
||||
assert!(!boxed_f.is_null(), "Internal error - null function pointer");
|
||||
let ctx = Context {
|
||||
ctx,
|
||||
@ -509,7 +509,7 @@ impl InnerConnection {
|
||||
c_name.as_ptr(),
|
||||
n_arg,
|
||||
flags.bits(),
|
||||
boxed_f as *mut c_void,
|
||||
boxed_f.cast::<c_void>(),
|
||||
Some(call_boxed_closure::<F, T>),
|
||||
None,
|
||||
None,
|
||||
@ -539,7 +539,7 @@ impl InnerConnection {
|
||||
c_name.as_ptr(),
|
||||
n_arg,
|
||||
flags.bits(),
|
||||
boxed_aggr as *mut c_void,
|
||||
boxed_aggr.cast::<c_void>(),
|
||||
None,
|
||||
Some(call_boxed_step::<A, D, T>),
|
||||
Some(call_boxed_final::<A, D, T>),
|
||||
@ -570,7 +570,7 @@ impl InnerConnection {
|
||||
c_name.as_ptr(),
|
||||
n_arg,
|
||||
flags.bits(),
|
||||
boxed_aggr as *mut c_void,
|
||||
boxed_aggr.cast::<c_void>(),
|
||||
Some(call_boxed_step::<A, W, T>),
|
||||
Some(call_boxed_final::<A, W, T>),
|
||||
Some(call_boxed_value::<A, W, T>),
|
||||
@ -626,7 +626,7 @@ unsafe extern "C" fn call_boxed_step<A, D, T>(
|
||||
};
|
||||
|
||||
let r = catch_unwind(|| {
|
||||
let boxed_aggr: *mut D = ffi::sqlite3_user_data(ctx) as *mut D;
|
||||
let boxed_aggr: *mut D = ffi::sqlite3_user_data(ctx).cast::<D>();
|
||||
assert!(
|
||||
!boxed_aggr.is_null(),
|
||||
"Internal error - null aggregate pointer"
|
||||
@ -674,7 +674,7 @@ unsafe extern "C" fn call_boxed_inverse<A, W, T>(
|
||||
};
|
||||
|
||||
let r = catch_unwind(|| {
|
||||
let boxed_aggr: *mut W = ffi::sqlite3_user_data(ctx) as *mut W;
|
||||
let boxed_aggr: *mut W = ffi::sqlite3_user_data(ctx).cast::<W>();
|
||||
assert!(
|
||||
!boxed_aggr.is_null(),
|
||||
"Internal error - null aggregate pointer"
|
||||
@ -719,7 +719,7 @@ where
|
||||
};
|
||||
|
||||
let r = catch_unwind(|| {
|
||||
let boxed_aggr: *mut D = ffi::sqlite3_user_data(ctx) as *mut D;
|
||||
let boxed_aggr: *mut D = ffi::sqlite3_user_data(ctx).cast::<D>();
|
||||
assert!(
|
||||
!boxed_aggr.is_null(),
|
||||
"Internal error - null aggregate pointer"
|
||||
@ -764,7 +764,7 @@ where
|
||||
};
|
||||
|
||||
let r = catch_unwind(|| {
|
||||
let boxed_aggr: *mut W = ffi::sqlite3_user_data(ctx) as *mut W;
|
||||
let boxed_aggr: *mut W = ffi::sqlite3_user_data(ctx).cast::<W>();
|
||||
assert!(
|
||||
!boxed_aggr.is_null(),
|
||||
"Internal error - null aggregate pointer"
|
||||
|
22
src/hooks.rs
22
src/hooks.rs
@ -425,7 +425,7 @@ impl InnerConnection {
|
||||
F: FnMut() -> bool,
|
||||
{
|
||||
let r = catch_unwind(|| {
|
||||
let boxed_hook: *mut F = p_arg as *mut F;
|
||||
let boxed_hook: *mut F = p_arg.cast::<F>();
|
||||
(*boxed_hook)()
|
||||
});
|
||||
if let Ok(true) = r {
|
||||
@ -451,7 +451,7 @@ impl InnerConnection {
|
||||
ffi::sqlite3_commit_hook(
|
||||
self.db(),
|
||||
Some(call_boxed_closure::<F>),
|
||||
boxed_hook as *mut _,
|
||||
boxed_hook.cast(),
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -473,8 +473,8 @@ impl InnerConnection {
|
||||
where
|
||||
F: FnMut(),
|
||||
{
|
||||
let _ = catch_unwind(|| {
|
||||
let boxed_hook: *mut F = p_arg as *mut F;
|
||||
drop(catch_unwind(|| {
|
||||
let boxed_hook: *mut F = p_arg.cast::<F>();
|
||||
(*boxed_hook)();
|
||||
});
|
||||
}
|
||||
@ -492,7 +492,7 @@ impl InnerConnection {
|
||||
ffi::sqlite3_rollback_hook(
|
||||
self.db(),
|
||||
Some(call_boxed_closure::<F>),
|
||||
boxed_hook as *mut _,
|
||||
boxed_hook.cast(),
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -520,8 +520,8 @@ impl InnerConnection {
|
||||
F: FnMut(Action, &str, &str, i64),
|
||||
{
|
||||
let action = Action::from(action_code);
|
||||
let _ = catch_unwind(|| {
|
||||
let boxed_hook: *mut F = p_arg as *mut F;
|
||||
drop(catch_unwind(|| {
|
||||
let boxed_hook: *mut F = p_arg.cast::<F>();
|
||||
(*boxed_hook)(
|
||||
action,
|
||||
expect_utf8(p_db_name, "database name"),
|
||||
@ -544,7 +544,7 @@ impl InnerConnection {
|
||||
ffi::sqlite3_update_hook(
|
||||
self.db(),
|
||||
Some(call_boxed_closure::<F>),
|
||||
boxed_hook as *mut _,
|
||||
boxed_hook.cast(),
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -567,7 +567,7 @@ impl InnerConnection {
|
||||
F: FnMut() -> bool,
|
||||
{
|
||||
let r = catch_unwind(|| {
|
||||
let boxed_handler: *mut F = p_arg as *mut F;
|
||||
let boxed_handler: *mut F = p_arg.cast::<F>();
|
||||
(*boxed_handler)()
|
||||
});
|
||||
if let Ok(true) = r {
|
||||
@ -626,7 +626,7 @@ impl InnerConnection {
|
||||
"accessor (inner-most trigger or view)",
|
||||
),
|
||||
};
|
||||
let boxed_hook: *mut F = p_arg as *mut F;
|
||||
let boxed_hook: *mut F = p_arg.cast::<F>();
|
||||
(*boxed_hook)(auth_ctx)
|
||||
})
|
||||
.map(Authorization::into_raw)
|
||||
@ -666,7 +666,7 @@ impl InnerConnection {
|
||||
}
|
||||
|
||||
unsafe fn free_boxed_hook<F>(p: *mut c_void) {
|
||||
drop(Box::from_raw(p as *mut F));
|
||||
drop(Box::from_raw(p.cast::<F>()));
|
||||
}
|
||||
|
||||
unsafe fn expect_utf8<'a>(p_str: *const c_char, description: &'static str) -> &'a str {
|
||||
|
@ -208,7 +208,7 @@ impl InnerConnection {
|
||||
Ok(())
|
||||
} else {
|
||||
let message = super::errmsg_to_string(errmsg);
|
||||
ffi::sqlite3_free(errmsg as *mut ::std::os::raw::c_void);
|
||||
ffi::sqlite3_free(errmsg.cast::<::std::os::raw::c_void>());
|
||||
Err(error_from_sqlite_code(r, Some(message)))
|
||||
}
|
||||
}
|
||||
|
@ -258,10 +258,10 @@ fn str_to_cstring(s: &str) -> Result<SmallCString> {
|
||||
fn str_for_sqlite(s: &[u8]) -> Result<(*const c_char, c_int, ffi::sqlite3_destructor_type)> {
|
||||
let len = len_as_c_int(s.len())?;
|
||||
let (ptr, dtor_info) = if len != 0 {
|
||||
(s.as_ptr() as *const c_char, ffi::SQLITE_TRANSIENT())
|
||||
(s.as_ptr().cast::<c_char>(), ffi::SQLITE_TRANSIENT())
|
||||
} else {
|
||||
// Return a pointer guaranteed to live forever
|
||||
("".as_ptr() as *const c_char, ffi::SQLITE_STATIC())
|
||||
("".as_ptr().cast::<c_char>(), ffi::SQLITE_STATIC())
|
||||
};
|
||||
Ok((ptr, len, dtor_info))
|
||||
}
|
||||
|
@ -717,7 +717,7 @@ impl Statement<'_> {
|
||||
ffi::sqlite3_bind_blob(
|
||||
ptr,
|
||||
col as c_int,
|
||||
b.as_ptr() as *const c_void,
|
||||
b.as_ptr().cast::<c_void>(),
|
||||
length,
|
||||
ffi::SQLITE_TRANSIENT(),
|
||||
)
|
||||
@ -875,7 +875,7 @@ impl Statement<'_> {
|
||||
!text.is_null(),
|
||||
"unexpected SQLITE_TEXT column type with NULL data"
|
||||
);
|
||||
from_raw_parts(text as *const u8, len as usize)
|
||||
from_raw_parts(text.cast::<u8>(), len as usize)
|
||||
};
|
||||
|
||||
ValueRef::Text(s)
|
||||
@ -897,7 +897,7 @@ impl Statement<'_> {
|
||||
!blob.is_null(),
|
||||
"unexpected SQLITE_BLOB column type with NULL data"
|
||||
);
|
||||
ValueRef::Blob(unsafe { from_raw_parts(blob as *const u8, len as usize) })
|
||||
ValueRef::Blob(unsafe { from_raw_parts(blob.cast::<u8>(), len as usize) })
|
||||
} else {
|
||||
// The return value from sqlite3_column_blob() for a zero-length BLOB
|
||||
// is a NULL pointer.
|
||||
|
@ -228,7 +228,7 @@ impl<'a> ValueRef<'a> {
|
||||
!text.is_null(),
|
||||
"unexpected SQLITE_TEXT value type with NULL data"
|
||||
);
|
||||
let s = from_raw_parts(text as *const u8, len as usize);
|
||||
let s = from_raw_parts(text.cast::<u8>(), len as usize);
|
||||
ValueRef::Text(s)
|
||||
}
|
||||
ffi::SQLITE_BLOB => {
|
||||
@ -246,7 +246,7 @@ impl<'a> ValueRef<'a> {
|
||||
!blob.is_null(),
|
||||
"unexpected SQLITE_BLOB value type with NULL data"
|
||||
);
|
||||
ValueRef::Blob(from_raw_parts(blob as *const u8, len as usize))
|
||||
ValueRef::Blob(from_raw_parts(blob.cast::<u8>(), len as usize))
|
||||
} else {
|
||||
// The return value from sqlite3_value_blob() for a zero-length BLOB
|
||||
// is a NULL pointer.
|
||||
|
@ -120,7 +120,7 @@ impl SqliteMallocString {
|
||||
// `>` because we added 1.
|
||||
debug_assert!(len_to_alloc > 0);
|
||||
debug_assert_eq!((len_to_alloc - 1) as usize, src_len);
|
||||
NonNull::new(ffi::sqlite3_malloc(len_to_alloc) as *mut c_char)
|
||||
NonNull::new(ffi::sqlite3_malloc(len_to_alloc).cast::<c_char>())
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
use std::alloc::{handle_alloc_error, Layout};
|
||||
@ -138,7 +138,7 @@ impl SqliteMallocString {
|
||||
// Note: This call does not return.
|
||||
handle_alloc_error(layout);
|
||||
});
|
||||
let buf: *mut c_char = res_ptr.as_ptr() as *mut c_char;
|
||||
let buf: *mut c_char = res_ptr.as_ptr().cast::<c_char>();
|
||||
src_ptr.copy_to_nonoverlapping(buf, src_len);
|
||||
buf.add(src_len).write(0);
|
||||
debug_assert_eq!(std::ffi::CStr::from_ptr(res_ptr.as_ptr()).to_bytes(), bytes);
|
||||
|
@ -41,7 +41,7 @@ use crate::{Connection, Result};
|
||||
|
||||
// http://sqlite.org/bindptr.html
|
||||
|
||||
pub(crate) const ARRAY_TYPE: *const c_char = b"rarray\0" as *const u8 as *const c_char;
|
||||
pub(crate) const ARRAY_TYPE: *const c_char = (b"rarray\0" as *const u8).cast::<c_char>();
|
||||
|
||||
pub(crate) unsafe extern "C" fn free_array(p: *mut c_void) {
|
||||
let _: Array = Rc::from_raw(p as *const Vec<Value>);
|
||||
|
@ -699,7 +699,7 @@ impl InnerConnection {
|
||||
self.db(),
|
||||
c_name.as_ptr(),
|
||||
&module.base,
|
||||
boxed_aux as *mut c_void,
|
||||
boxed_aux.cast::<c_void>(),
|
||||
Some(free_boxed_value::<T::Aux>),
|
||||
)
|
||||
}
|
||||
@ -766,7 +766,7 @@ pub fn parse_boolean(s: &str) -> Option<bool> {
|
||||
|
||||
// FIXME copy/paste from function.rs
|
||||
unsafe extern "C" fn free_boxed_value<T>(p: *mut c_void) {
|
||||
let _: Box<T> = Box::from_raw(p as *mut T);
|
||||
drop(Box::from_raw(p.cast::<T>()));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn rust_create<'vtab, T>(
|
||||
@ -783,7 +783,7 @@ where
|
||||
use std::ffi::CStr;
|
||||
|
||||
let mut conn = VTabConnection(db);
|
||||
let aux = aux as *mut T::Aux;
|
||||
let aux = aux.cast::<T::Aux>();
|
||||
let args = slice::from_raw_parts(argv, argc as usize);
|
||||
let vec = args
|
||||
.iter()
|
||||
@ -795,7 +795,7 @@ where
|
||||
let rc = ffi::sqlite3_declare_vtab(db, c_sql.as_ptr());
|
||||
if rc == ffi::SQLITE_OK {
|
||||
let boxed_vtab: *mut T = Box::into_raw(Box::new(vtab));
|
||||
*pp_vtab = boxed_vtab as *mut ffi::sqlite3_vtab;
|
||||
*pp_vtab = boxed_vtab.cast::<ffi::sqlite3_vtab>();
|
||||
ffi::SQLITE_OK
|
||||
} else {
|
||||
let err = error_from_sqlite_code(rc, None);
|
||||
@ -835,7 +835,7 @@ where
|
||||
use std::ffi::CStr;
|
||||
|
||||
let mut conn = VTabConnection(db);
|
||||
let aux = aux as *mut T::Aux;
|
||||
let aux = aux.cast::<T::Aux>();
|
||||
let args = slice::from_raw_parts(argv, argc as usize);
|
||||
let vec = args
|
||||
.iter()
|
||||
@ -847,7 +847,7 @@ where
|
||||
let rc = ffi::sqlite3_declare_vtab(db, c_sql.as_ptr());
|
||||
if rc == ffi::SQLITE_OK {
|
||||
let boxed_vtab: *mut T = Box::into_raw(Box::new(vtab));
|
||||
*pp_vtab = boxed_vtab as *mut ffi::sqlite3_vtab;
|
||||
*pp_vtab = boxed_vtab.cast::<ffi::sqlite3_vtab>();
|
||||
ffi::SQLITE_OK
|
||||
} else {
|
||||
let err = error_from_sqlite_code(rc, None);
|
||||
@ -880,7 +880,7 @@ unsafe extern "C" fn rust_best_index<'vtab, T>(
|
||||
where
|
||||
T: VTab<'vtab>,
|
||||
{
|
||||
let vt = vtab as *mut T;
|
||||
let vt = vtab.cast::<T>();
|
||||
let mut idx_info = IndexInfo(info);
|
||||
match (*vt).best_index(&mut idx_info) {
|
||||
Ok(_) => ffi::SQLITE_OK,
|
||||
@ -904,8 +904,8 @@ where
|
||||
if vtab.is_null() {
|
||||
return ffi::SQLITE_OK;
|
||||
}
|
||||
let vtab = vtab as *mut T;
|
||||
let _: Box<T> = Box::from_raw(vtab);
|
||||
let vtab = vtab.cast::<T>();
|
||||
drop(Box::from_raw(vtab));
|
||||
ffi::SQLITE_OK
|
||||
}
|
||||
|
||||
@ -916,7 +916,7 @@ where
|
||||
if vtab.is_null() {
|
||||
return ffi::SQLITE_OK;
|
||||
}
|
||||
let vt = vtab as *mut T;
|
||||
let vt = vtab.cast::<T>();
|
||||
match (*vt).destroy() {
|
||||
Ok(_) => {
|
||||
let _: Box<T> = Box::from_raw(vt);
|
||||
@ -942,11 +942,11 @@ unsafe extern "C" fn rust_open<'vtab, T: 'vtab>(
|
||||
where
|
||||
T: VTab<'vtab>,
|
||||
{
|
||||
let vt = vtab as *mut T;
|
||||
let vt = vtab.cast::<T>();
|
||||
match (*vt).open() {
|
||||
Ok(cursor) => {
|
||||
let boxed_cursor: *mut T::Cursor = Box::into_raw(Box::new(cursor));
|
||||
*pp_cursor = boxed_cursor as *mut ffi::sqlite3_vtab_cursor;
|
||||
*pp_cursor = boxed_cursor.cast::<ffi::sqlite3_vtab_cursor>();
|
||||
ffi::SQLITE_OK
|
||||
}
|
||||
Err(Error::SqliteFailure(err, s)) => {
|
||||
@ -966,8 +966,8 @@ unsafe extern "C" fn rust_close<C>(cursor: *mut ffi::sqlite3_vtab_cursor) -> c_i
|
||||
where
|
||||
C: VTabCursor,
|
||||
{
|
||||
let cr = cursor as *mut C;
|
||||
let _: Box<C> = Box::from_raw(cr);
|
||||
let cr = cursor.cast::<C>();
|
||||
drop(Box::from_raw(cr));
|
||||
ffi::SQLITE_OK
|
||||
}
|
||||
|
||||
@ -1007,7 +1007,7 @@ unsafe extern "C" fn rust_eof<C>(cursor: *mut ffi::sqlite3_vtab_cursor) -> c_int
|
||||
where
|
||||
C: VTabCursor,
|
||||
{
|
||||
let cr = cursor as *mut C;
|
||||
let cr = cursor.cast::<C>();
|
||||
(*cr).eof() as c_int
|
||||
}
|
||||
|
||||
@ -1019,7 +1019,7 @@ unsafe extern "C" fn rust_column<C>(
|
||||
where
|
||||
C: VTabCursor,
|
||||
{
|
||||
let cr = cursor as *mut C;
|
||||
let cr = cursor.cast::<C>();
|
||||
let mut ctxt = Context(ctx);
|
||||
result_error(ctx, (*cr).column(&mut ctxt, i))
|
||||
}
|
||||
@ -1031,7 +1031,7 @@ unsafe extern "C" fn rust_rowid<C>(
|
||||
where
|
||||
C: VTabCursor,
|
||||
{
|
||||
let cr = cursor as *mut C;
|
||||
let cr = cursor.cast::<C>();
|
||||
match (*cr).rowid() {
|
||||
Ok(rowid) => {
|
||||
*p_rowid = rowid;
|
||||
@ -1065,7 +1065,7 @@ unsafe fn cursor_error<T>(cursor: *mut ffi::sqlite3_vtab_cursor, result: Result<
|
||||
#[cold]
|
||||
unsafe fn set_err_msg(vtab: *mut ffi::sqlite3_vtab, err_msg: &str) {
|
||||
if !(*vtab).zErrMsg.is_null() {
|
||||
ffi::sqlite3_free((*vtab).zErrMsg as *mut c_void);
|
||||
ffi::sqlite3_free((*vtab).zErrMsg.cast::<c_void>());
|
||||
}
|
||||
(*vtab).zErrMsg = alloc(err_msg);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user