In each of the examples below, does blob.0 or text need to be copied? How do you know?
Setup
import SQLite3
private let static_destructor = unsafeBitCast(0, to: sqlite3_destructor_type.self)
private let transient_destructor = unsafeBitCast(-1, to: sqlite3_destructor_type.self)
Examples
bind_blobfunc bind_blob(_ stmt: OpaquePointer, _ blob: (UnsafeRawPointer, Int32)) { sqlite3_bind_blob(stmt, 1, blob.0, blob.1, transient_destructor) }bind_blobsfunc bind_blobs(_ stmt: OpaquePointer, _ blobs: [(UnsafeRawPointer, Int32)]) { for (index, blob) in blobs.enumerated() { sqlite3_bind_blob(stmt, Int32(index+1), blob.0, blob.1, transient_destructor) } }bind_textfunc bind_text(_ stmt: OpaquePointer, _ text: String) { sqlite3_bind_text(stmt, 1, text, -1, transient_destructor) }bind_textsfunc bind_texts(_ stmt: OpaquePointer, _ texts: [String]) { for (index, text) in texts.enumerated() { sqlite3_bind_text(stmt, Int32(index+1), text, -1, transient_destructor) } }
Ie, should I use static_destructor instead of transient_destructor in any of the examples?
Related question: When to use SQLITE_TRANSIENT vs SQLITE_STATIC?