Introduce to_sqlite_error

643c0f699f
One small step to support creating loadable extension
This commit is contained in:
gwenn
2023-06-08 20:01:17 +02:00
parent 38bf316601
commit 687aeef3b0
5 changed files with 36 additions and 33 deletions

View File

@@ -6,4 +6,4 @@ 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::SqliteMallocString;
pub(crate) use sqlite_string::{alloc, SqliteMallocString};

View File

@@ -7,6 +7,12 @@ use std::marker::PhantomData;
use std::os::raw::{c_char, c_int};
use std::ptr::NonNull;
// Space to hold this string must be obtained
// from an SQLite memory allocation function
pub(crate) fn alloc(s: &str) -> *mut c_char {
SqliteMallocString::from_str(s).into_raw()
}
/// A string we own that's allocated on the SQLite heap. Automatically calls
/// `sqlite3_free` when dropped, unless `into_raw` (or `into_inner`) is called
/// on it. If constructed from a rust string, `sqlite3_malloc` is used.