A bound blob or string is destroyed "after SQLite has finished with it". This should be the case when sqlite3_clear_bindings() is called. Are you sure it is not deleted then? Code reading suggests it should be.
Other times are when the parameter is re-bound, or the statement finalized. -----Ursprüngliche Nachricht----- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Dave Milter Gesendet: Dienstag, 09. Jänner 2018 16:36 An: sqlite-users@mailinglists.sqlite.org Betreff: [EXTERNAL] [sqlite] bind blob lifetime I have cycle like this: ```c const char sql[] = "INSERT INTO test (pk, geom) VALUES (?, ?)"; sqlite3_stmt *stmt; sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL); for (...) { sqlite3_reset (stmt); sqlite3_clear_bindings (stmt); int blob_size = ..; unsigned char *blob = malloc(blob_size); sqlite3_bind_int64 (stmt, 1, pk); sqlite3_bind_blob (stmt, 2, blob, blob_size, free); sqlite3_step (stmt); } //sqlite3_finalize ``` I wonder is it necessary to allocate memory on every cycle? I know that I can pass SQLITE_TRANSIENT, but in this case code would be exactly the same, just allocation on every cycle happens inside sqlite. According to documentation it is not clear when sqlite call destructor of blob (in our case "free"), is it happens after: sqlite3_reset sqlite3_clear_bindings sqlite3_bind_blob step sqlite3_reset sqlite3_clear_bindings sqlite3_bind_blob << here previous memory was freed??? step ? _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___________________________________________ Gunter Hick | Software Engineer | Scientific Games International GmbH | Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 1 80100 - 0 May be privileged. May be confidential. Please delete if not the addressee. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users