Merge pull request #1483 from gwenn/c-string-literals

Use C-string literals
This commit is contained in:
gwenn 2024-03-24 08:14:38 +01:00 committed by GitHub
commit b41bd80571
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -364,7 +364,7 @@ impl DatabaseName<'_> {
fn as_cstring(&self) -> Result<SmallCString> {
use self::DatabaseName::{Attached, Main, Temp};
match *self {
Main => str_to_cstring("main"),
Main => str_to_cstring("main"), // TODO C-string literals
Temp => str_to_cstring("temp"),
Attached(s) => str_to_cstring(s),
}
@ -1908,7 +1908,7 @@ mod test {
#[test]
fn test_from_handle_owned() -> Result<()> {
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);
let db = unsafe { Connection::from_handle_owned(handle) }?;
db.execute_batch("PRAGMA VACUUM")?;

View File

@ -40,7 +40,7 @@ use crate::{Connection, Result};
// 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) {
drop(Rc::from_raw(p as *const Vec<Value>));