diff --git a/src/vtab/array.rs b/src/vtab/array.rs index 9cb6a6f..8d53a1b 100644 --- a/src/vtab/array.rs +++ b/src/vtab/array.rs @@ -62,11 +62,7 @@ impl Module for ArrayModule { self.0 } - unsafe fn connect( - db: *mut ffi::sqlite3, - _aux: Option<&()>, - _args: &[&[u8]], - ) -> Result { + fn connect(db: &mut ffi::sqlite3, _aux: Option<&()>, _args: &[&[u8]]) -> Result { let vtab = ArrayTab { base: Default::default(), }; diff --git a/src/vtab/csvtab.rs b/src/vtab/csvtab.rs index 6d49be3..ebdc290 100644 --- a/src/vtab/csvtab.rs +++ b/src/vtab/csvtab.rs @@ -84,7 +84,7 @@ impl Module for CSVModule { self.0 } - unsafe fn connect(db: *mut ffi::sqlite3, _aux: Option<&()>, args: &[&[u8]]) -> Result { + fn connect(db: &mut ffi::sqlite3, _aux: Option<&()>, args: &[&[u8]]) -> Result { if args.len() < 4 { return Err(Error::ModuleError("no CSV file specified".to_owned())); } diff --git a/src/vtab/mod.rs b/src/vtab/mod.rs index bde9252..12b24a7 100644 --- a/src/vtab/mod.rs +++ b/src/vtab/mod.rs @@ -50,8 +50,8 @@ pub trait Module { /// Create a new instance of a virtual table in response to a CREATE VIRTUAL TABLE statement. /// The `db` parameter is a pointer to the SQLite database connection that is executing /// the CREATE VIRTUAL TABLE statement. - unsafe fn create( - db: *mut ffi::sqlite3, + fn create( + db: &mut ffi::sqlite3, aux: Option<&Self::Aux>, args: &[&[u8]], ) -> Result { @@ -59,8 +59,8 @@ pub trait Module { } /// Similar to `create`. The difference is that `connect` is called to establish a new connection /// to an _existing_ virtual table whereas `create` is called to create a new virtual table from scratch. - unsafe fn connect( - db: *mut ffi::sqlite3, + fn connect( + db: &mut ffi::sqlite3, aux: Option<&Self::Aux>, args: &[&[u8]], ) -> Result; @@ -353,9 +353,9 @@ impl InnerConnection { } /// Declare the schema of a virtual table. -pub unsafe fn declare_vtab(db: *mut ffi::sqlite3, sql: &str) -> Result<()> { +pub fn declare_vtab(db: &mut ffi::sqlite3, sql: &str) -> Result<()> { let c_sql = try!(CString::new(sql)); - let rc = ffi::sqlite3_declare_vtab(db, c_sql.as_ptr()); + let rc = unsafe { ffi::sqlite3_declare_vtab(db, c_sql.as_ptr()) }; if rc == ffi::SQLITE_OK { Ok(()) } else { @@ -572,7 +572,7 @@ macro_rules! create_or_connect { .iter() .map(|&cs| CStr::from_ptr(cs).to_bytes()) // FIXME .to_str() -> Result<&str, Utf8Error> .collect::>(); - match $module::$module_func(db, aux.as_ref(), &vec[..]) { + match $module::$module_func(db.as_mut().expect("non null db pointer"), aux.as_ref(), &vec[..]) { Ok(vtab) => { let boxed_vtab: *mut $vtab = Box::into_raw(Box::new(vtab)); *pp_vtab = boxed_vtab as *mut ffi::sqlite3_vtab; diff --git a/src/vtab/series.rs b/src/vtab/series.rs index 68562eb..c088a40 100644 --- a/src/vtab/series.rs +++ b/src/vtab/series.rs @@ -45,11 +45,7 @@ impl Module for Series { self.0 } - unsafe fn connect( - db: *mut ffi::sqlite3, - _aux: Option<&()>, - _args: &[&[u8]], - ) -> Result { + fn connect(db: &mut ffi::sqlite3, _aux: Option<&()>, _args: &[&[u8]]) -> Result { let vtab = SeriesTab { base: Default::default(), };