fix dump
[m6w6/ext-psi] / tests / sqlite / sqlite.psi
index 4fea4c661fbaa53750765a20075b8eceb89b876a..b2beb5cd6d4be0b5ade4d28fdf8a1a36e7addd3a 100644 (file)
@@ -23,15 +23,13 @@ typedef sqlite_int64 sqlite3_int64;
 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);
@@ -44,13 +42,6 @@ function sqlite3\open(string $uri, object &$db) : int {
 
 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);
@@ -67,4 +58,5 @@ function sqlite3\exec(object $db, string $sql, callable $cb, mixed $cd, string &
        let errmsg = &NULL;
        return to_int(sqlite3_exec);
        set $error = to_string(*errmsg);
+       free sqlite3_free(*errmsg);
 }