On 15 May 2012, at 9:03pm, "Jay A. Kreibich" <j...@kreibi.ch> wrote:

>  That's missing the point.  You're never supposed to get there.
>  Having unaccounted for statements when you close the database is
>  essentially a memory leak.  You've got data structures the
>  application lost track of and didn't clean up.
> 
>  Yes, you can loop over the current statements and finalize them, but
>  this also frees the memory used by those statements, making it invalid.
>  That means one of two things MUST be true:
> 
>  1) Your application lost track of statements.  This is a
>     memory/resource leak.  You should fix the problem, not the
>     consequences.
> 
>  2) After the call to _close(), your application now has a non-NULL
>     pointer somewhere that it THINKS points to valid statement, but in
>     reality points to a random chunk of memory.  Attempting to do
>     *anything* with this pointer-- including another call to
>     _finalize()-- will likely crash the program.

Fair point.  You end up putting headers into the data structure to verify the 
fact that the memory you've been handed is a valid pointer.  And that way 
madness lies.  Okay I see why its not appropriate.  Better not to do any 
cleaning up, to report the non-zero result returned by _close() to the user, 
and quit.

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

Reply via email to