On Sun, Jun 20, 2010 at 7:37 PM, Simon Slavin <[email protected]> wrote:
> > On 21 Jun 2010, at 12:33am, Roger Binns wrote: > > > On 06/20/2010 03:07 PM, Simon Slavin wrote: > >> The ppDb value is about allocating memory. It's possible that the file > might be open and no memory allocated. Or that memory was allocated and the > file not opened. I forget which. > >> > >> Instead check the return value. If you get SQLITE_OK then you need to > close the connection. If you don't, you don't. > > > > That is bad advice! The return code of open is irrelevant. If ppDb is > set > > to non-NULL then you need to call sqlite3_close on it. ppDb will almost > > always be set to something. One example of when it is not is if there is > no > > memory left in which case it will be set to NULL. > > > > Even if the open failed (ie SQLITE_OK not returned) memory is allocated > for > > the error message and code so you do need to call close to free that up. > > That is ... weird. Okay. I expected _open to clear up after itself if it > failed to open the file. Just like any other library function should clear > up after itself if it fails. Can this please be fixed in the new proposed > version of _open ? > > The database connection object carries the error message. So we create it anyway so that the application can get access to the error message. > Simon. > _______________________________________________ > sqlite-users mailing list > [email protected] > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > -- --------------------- D. Richard Hipp [email protected] _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

