On 9/19/2013 5:43 PM, Igor Korot wrote:
If you do pass a non-NULL pointer as the last parameter, then SQLite would
allocate memory for it. You should then free said memory, or else you leak
it.

Yes, I understand that.
My question was more about re-using the variable between to calls to SQLite.

Well, you can reuse the variable *after* you free the memory it points to. Consider:

// OK
char* p = new char[42];
delete[] p;
p = new char[84];

// Not OK
char* p = new char[42];
p = new char[84];

Your situation is the same: sqlite3_exec effectively acts as a memory allocation routine. It's not reusing the variable per se that's a problem, it's losing a pointer to memory that was allocated but not yet freed.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to