Skip to content

Commit

Permalink
correctly set transient
Browse files Browse the repository at this point in the history
  • Loading branch information
bhansconnect committed Dec 29, 2024
1 parent ac38e3e commit 9e48c86
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crates/roc_sqlite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,31 @@ pub fn bind(stmt: RocBox<()>, bindings: &RocList<SqliteBindings>) -> RocResult<(
},
SqliteValueDiscriminant::String => unsafe {
let str = binding.value.borrow_String().as_str();
let transient = std::mem::transmute::<
*const std::ffi::c_void,
unsafe extern "C" fn(*mut std::ffi::c_void),
>(-1isize as *const c_void);
libsqlite3_sys::sqlite3_bind_text64(
local_stmt,
index,
str.as_ptr() as *const c_char,
str.len() as u64,
None,
Some(transient),
libsqlite3_sys::SQLITE_UTF8 as u8,
)
},
SqliteValueDiscriminant::Bytes => unsafe {
let str = binding.value.borrow_Bytes().as_slice();
let transient = std::mem::transmute::<
*const std::ffi::c_void,
unsafe extern "C" fn(*mut std::ffi::c_void),
>(-1isize as *const c_void);
libsqlite3_sys::sqlite3_bind_blob64(
local_stmt,
index,
str.as_ptr() as *const c_void,
str.len() as u64,
None,
Some(transient),
)
},
SqliteValueDiscriminant::Null => unsafe {
Expand Down

0 comments on commit 9e48c86

Please sign in to comment.