I also read the documentation that you quoted below. If one must always free the char * using sqlite3_free, then doesn't that mean that in the example provided at http://www.sqlite.org/quickstart.html 'zErrMsg' is actually a memory leak waiting to happen? And why isn't sqlite3_exec listed under sqlite3_free as one of the routines to use it to free the memory from?
-----Original Message----- From: Ulrik Petersen [mailto:[EMAIL PROTECTED] Sent: Monday, February 07, 2005 6:44 PM To: [email protected] Subject: Re: [sqlite] Do _ErrMsg strings have to be freed? Hi Nathan, [EMAIL PROTECTED] wrote: >Does this > >var > pMsg: PChar; > >.. > pMsg := SQLite3_ErrMsg(aDB); > >necessitate this? > > if pMsg <> nil then SQLite3_Free(pMsg); > > You'd have to read the docs of your Delphi wrapper, but if this were the plain C interface, then, yes, you would need to free the memory. From: http://www.sqlite.org/capi3ref.html#sqlite3_exec Comes this: "If an error occurs while parsing or evaluating the SQL (but not while executing the callback) then an appropriate error message is written into memory obtained from malloc() and *errmsg is made to point to that message. The calling function is responsible for freeing the memory that holds the error message. Use sqlite3_free <http://www.sqlite.org/capi3ref.html#sqlite3_free>() for this. If errmsg==NULL, then no error message is ever written." And now a meta-comment about asking questions in a technical forum. It is fine to ask questions, and newbies are certainly welcome, but... Your best bet is to check the www.sqlite.org site first, then check your Delphi wrapper documentation, then if that doesn't anwer your questions, you're more than welcome to ask questions here. One of the first rules of asking questions in a technical forum is to try to answer the question yourself from the docs before asking the question. It may not save you some time, but if a forum has many readers, the time saved collectively if you find the answer yourself is perhaps greater than the time it takes you to find the answer yourself. That's what documentation is for, after all. Plus you'll likely learn something in the process which WILL save you some time later down the road. I would encourage you to read through the SQLite3 C reference. It doesn't take that long, and will be a rewarding experience: http://www.sqlite.org/capi3ref.html And if that doesn't answer your questions, as I said, you're more than welcome to ask questions here, I am sure. This forum is really outstanding in its helpfulness, and we have much to be thankful for to a bunch of people. The tone of this forum is also unexpectedly pleasant most of the time. Kudos to everyone on this list who answers questions with kindness and insight. HTH Ulrik Petersen -- Ulrik Petersen, Denmark MA, B.Sc

