Question about sqlite_free_table

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Question about sqlite_free_table

Massimo Gaspari

Dear All,

Consider the following code


if ( sqlite3_get_table(sqlite3,sql,resultp,nrow,ncolumn,errmsg) ==
SQLITE_OK)
 {
 do.......
 do....
 do...

 sqlite3_free_table(result);
 return;
 } else {
         return;
        }


The question is:

Is it right to not call the sqlite3_free_table() function if the
sqlite3_get_table()
returns an error?
Or must I call  sqlite3_free_table() in any case?

The documentation says



After the calling function has finished using the result, it should pass
the result data pointer to sqlite3_free_table()
in order to release the memory that was malloc-ed. Because of the way the
malloc() happens, the calling function
must not try to call malloc() directly.
Only sqlite3_free_table() is able to release the memory properly and
safely.


and it is not clear (to me) if a call sqlite3_free_table() is required in
case of errors.



Regards

Massimo