typedef sqlite_uint64 sqlite3_uint64;
extern void sqlite3_free(void *ptr);
-function sqlite3\free(object $object) : void {
- let ptr = objval($object);
- return void(sqlite3_free);
-}
extern int sqlite3_close(sqlite3 *db);
-function sqlite3\close(object $db) : int {
+function sqlite3\close(object &$db) : int {
let db = objval($db);
return to_int(sqlite3_close);
+ // unset($db) as safe-guard
+ set $db = void(db);
}
extern int sqlite3_open(const char *filename, sqlite3 **db_ptr);
typedef int (*sqlite3_callback)(void *data, int argc, char** argv, char** cols);
-/*
- * C calls into us, so we have to have a way to define how the callback
- * arguments have to be marshaled for the userland callback, i.e. from
- * native C types to ZE zvals /and/ how the userland return value has
- * to be marshaled to a native type. All in all, the opposite of function impls.
- */
-
extern int sqlite3_exec(sqlite3 *db, const char *sql, sqlite3_callback callback, void *data, char **errmsg);
function sqlite3\exec(object $db, string $sql, callable $cb, mixed $cd, string &$error = null) : int {
let db = objval($db);
let errmsg = &NULL;
return to_int(sqlite3_exec);
set $error = to_string(*errmsg);
+ free sqlite3_free(*errmsg);
}