Hello there.
I've re-read your mail a few times, however you seem to have forgotten
to actually *ask the question.*
On a sidenote, though: You're storing the database connection in a local
variable (sqlSt) instead of returning it - so when you return from the
function, you've opened a connection but have lost the reference to it
so you have no way to close it, thus you've created a memory leak. Is
that what you want?
Joanne Pham wrote:
Sorry! Resend an email because no subject in previous email.
Again. Your help is greatly appreciated.
Thanks,
JP
----- Original Message ----
From: Joanne Pham <[EMAIL PROTECTED]>
To: General Discussion of SQLite Database <sqlite-users@sqlite.org>
Sent: Thursday, August 21, 2008 11:54:13 AM
Subject: [sqlite] (no subject)
Hi All,
I have a question related toSQLite db handle(pDb in my codes).
I have the function below to open the database connection. I have to call
sqlite3_close(sqlite3 *)(sqlite3_close(pDb) in my case)
before open another database connection( by calling openDb) for releasing the
memory which is used by previous sqlite3_open_v2(openDb). Otherwise the
protential memory leak will be in the codes.
Your response is greatly appreciated.
JP
MonDb::openDb(const char *dbName){
int sqlSt;
const char* errMsg;
strcpy(name, dbName); //copy database name to the private name field
sqlSt = sqlite3_open_v2( name, &pDb, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
if(sqlSt != SQLITE_OK){
errMsg = sqlite3_errmsg(pDb);
// print out the error message
sqlite3_free((char*) errMsg);
return false;
}
/* Set database properties for better performance */
setDbProperties();
return true;
}
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
--
Multumesc,
Mihai Limbasan
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users