On 2/2/2017 4:28 AM, x wrote:
For a while I got away with this
sqlite3_stmt *stmt;
if (sqlite3_prepare16_v2(DB, L”sql statement”, -1, &stmt, NULL) !=
SQLITE_OK)
throw exception(“.....”);
// use stmt
sqlite3_reset(stmt);
if (sqlite3_prepare16_v2(DB, L”different sql statement”, -1, &stmt,
NULL) != SQLITE_OK)
throw exception(“.....”);
// use stmt again
sqlite3_finalize(stmt);
You are simply leaking a statement. You prepare one, never finalize it,
prepare another, and finalize the latter. The fact that you use the same
variable to store both handles is irrelevant (apart from the fact that
it makes it easier to leak). It's no different than, say,
char* p;
p = new char[42];
p = new char[84]; // previous allocation leaked.
delete[] p; // second allocation freed
Just finalize the first statement before reusing the variable for the
second one.
--
Igor Tandetnik
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users