mirror of
https://github.com/isar/rusqlite.git
synced 2025-04-02 04:12:59 +08:00
Use C-string literals
This commit is contained in:
parent
e00b626e2b
commit
ed7434e958
@ -364,7 +364,7 @@ impl DatabaseName<'_> {
|
|||||||
fn as_cstring(&self) -> Result<SmallCString> {
|
fn as_cstring(&self) -> Result<SmallCString> {
|
||||||
use self::DatabaseName::{Attached, Main, Temp};
|
use self::DatabaseName::{Attached, Main, Temp};
|
||||||
match *self {
|
match *self {
|
||||||
Main => str_to_cstring("main"),
|
Main => str_to_cstring("main"), // TODO C-string literals
|
||||||
Temp => str_to_cstring("temp"),
|
Temp => str_to_cstring("temp"),
|
||||||
Attached(s) => str_to_cstring(s),
|
Attached(s) => str_to_cstring(s),
|
||||||
}
|
}
|
||||||
@ -1908,7 +1908,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_from_handle_owned() -> Result<()> {
|
fn test_from_handle_owned() -> Result<()> {
|
||||||
let mut handle: *mut ffi::sqlite3 = std::ptr::null_mut();
|
let mut handle: *mut ffi::sqlite3 = std::ptr::null_mut();
|
||||||
let r = unsafe { ffi::sqlite3_open(":memory:\0".as_ptr() as *const c_char, &mut handle) };
|
let r = unsafe { ffi::sqlite3_open(c":memory:".as_ptr(), &mut handle) };
|
||||||
assert_eq!(r, ffi::SQLITE_OK);
|
assert_eq!(r, ffi::SQLITE_OK);
|
||||||
let db = unsafe { Connection::from_handle_owned(handle) }?;
|
let db = unsafe { Connection::from_handle_owned(handle) }?;
|
||||||
db.execute_batch("PRAGMA VACUUM")?;
|
db.execute_batch("PRAGMA VACUUM")?;
|
||||||
|
@ -40,7 +40,7 @@ use crate::{Connection, Result};
|
|||||||
|
|
||||||
// http://sqlite.org/bindptr.html
|
// http://sqlite.org/bindptr.html
|
||||||
|
|
||||||
pub(crate) const ARRAY_TYPE: *const c_char = (b"rarray\0" as *const u8).cast::<c_char>();
|
pub(crate) const ARRAY_TYPE: *const c_char = c"rarray".as_ptr();
|
||||||
|
|
||||||
pub(crate) unsafe extern "C" fn free_array(p: *mut c_void) {
|
pub(crate) unsafe extern "C" fn free_array(p: *mut c_void) {
|
||||||
drop(Rc::from_raw(p as *const Vec<Value>));
|
drop(Rc::from_raw(p as *const Vec<Value>));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user