mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-03-15 06:20:50 +00:00
Fix the binding of string parameters
This commit is contained in:
parent
9564d9e6a6
commit
10e461e5e9
@ -1,5 +1,6 @@
|
||||
use ffi;
|
||||
use libc::{c_double, c_int};
|
||||
use libc::{c_double, c_int, c_void};
|
||||
use std::ffi::CString;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use {Cursor, Result, Type, Value};
|
||||
@ -161,7 +162,8 @@ impl<'l> Bindable for &'l str {
|
||||
debug_assert!(i > 0, "the indexing starts from 1");
|
||||
unsafe {
|
||||
ok!(statement.raw.1, ffi::sqlite3_bind_text(statement.raw.0, i as c_int,
|
||||
str_to_cstr!(*self).as_ptr(), -1, None));
|
||||
str_to_cstr!(*self).into_raw(), -1,
|
||||
Some(drop_cstring)));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -250,3 +252,7 @@ pub fn new<'l, T: AsRef<str>>(raw1: *mut ffi::sqlite3, statement: T) -> Result<S
|
||||
}
|
||||
Ok(Statement { raw: (raw0, raw1), phantom: PhantomData })
|
||||
}
|
||||
|
||||
extern "C" fn drop_cstring(pointer: *mut c_void) {
|
||||
let _ = unsafe { CString::from_raw(pointer as *mut _) };
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user