mirror of
https://github.com/isar/rusqlite.git
synced 2025-03-23 22:08:31 +08:00
Dedup free_boxed_value
This commit is contained in:
parent
eeece2f0ee
commit
b42833138b
@ -6,13 +6,9 @@ use std::ptr;
|
||||
use std::slice;
|
||||
|
||||
use crate::ffi;
|
||||
use crate::util::free_boxed_value;
|
||||
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.cast::<T>()));
|
||||
}
|
||||
|
||||
impl Connection {
|
||||
/// Add or modify a collation.
|
||||
#[inline]
|
||||
|
@ -67,7 +67,7 @@ use crate::ffi::sqlite3_value;
|
||||
|
||||
use crate::context::set_result;
|
||||
use crate::types::{FromSql, FromSqlError, ToSql, ToSqlOutput, ValueRef};
|
||||
|
||||
use crate::util::free_boxed_value;
|
||||
use crate::{str_to_cstring, Connection, Error, InnerConnection, Result};
|
||||
|
||||
unsafe fn report_error(ctx: *mut sqlite3_context, err: &Error) {
|
||||
@ -84,10 +84,6 @@ 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.cast::<T>()));
|
||||
}
|
||||
|
||||
/// Context is a wrapper for the SQLite function
|
||||
/// evaluation context.
|
||||
pub struct Context<'a> {
|
||||
|
@ -7,3 +7,8 @@ pub(crate) use small_cstr::SmallCString;
|
||||
// Doesn't use any modern features or vtab stuff, but is only used by them.
|
||||
mod sqlite_string;
|
||||
pub(crate) use sqlite_string::{alloc, SqliteMallocString};
|
||||
|
||||
#[cfg(any(feature = "collation", feature = "functions", feature = "vtab"))]
|
||||
pub(crate) unsafe extern "C" fn free_boxed_value<T>(p: *mut std::ffi::c_void) {
|
||||
drop(Box::from_raw(p.cast::<T>()));
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ use crate::error::{error_from_sqlite_code, to_sqlite_error};
|
||||
use crate::ffi;
|
||||
pub use crate::ffi::{sqlite3_vtab, sqlite3_vtab_cursor};
|
||||
use crate::types::{FromSql, FromSqlError, ToSql, ValueRef};
|
||||
use crate::util::alloc;
|
||||
use crate::util::{alloc, free_boxed_value};
|
||||
use crate::{str_to_cstring, Connection, Error, InnerConnection, Result};
|
||||
|
||||
// let conn: Connection = ...;
|
||||
@ -927,11 +927,6 @@ pub fn parameter(c_slice: &[u8]) -> Result<(&str, &str)> {
|
||||
Err(Error::ModuleError(format!("illegal argument: '{arg}'")))
|
||||
}
|
||||
|
||||
// FIXME copy/paste from function.rs
|
||||
unsafe extern "C" fn free_boxed_value<T>(p: *mut c_void) {
|
||||
drop(Box::from_raw(p.cast::<T>()));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn rust_create<'vtab, T>(
|
||||
db: *mut ffi::sqlite3,
|
||||
aux: *mut c_void,
|
||||
|
Loading…
x
Reference in New Issue
Block a user