>
>Subject: RE: [sqlite] Do _ErrMsg strings have to be freed?
>   From: "steve" <[EMAIL PROTECTED]>
>   Date: Mon, 7 Feb 2005 19:31:23 -0800
>     To: <[email protected]>
>
>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? 

The possible need for amending the documentation crossed my mind as 
well. 

As I mentioned, I've been studying a number of Delphi implementations
of SQLite, and the more I learn the leakier some of them are looking. 

I know little about C, which is why I will doubtless ask questions
to which the answers seem obvious for some. Nevertheless, if you mean
the code at


  rc = sqlite3_open(argv[1], &db);
  if( rc ){
    fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
    sqlite3_close(db);
    exit(1);
  }
  rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
  if( rc!=SQLITE_OK ){
    fprintf(stderr, "SQL error: %s\n", zErrMsg);
  }
  sqlite3_close(db);
  return 0;
}

it looks like it has the "_Close even when a _Open is not SQLITE_OK"
part right, per the docs, but I'd have to ask about the zErrMsg part 
not being freed as well. 

Nathan


Reply via email to