On Oct 4, 2009, at 12:01 AM, jack wrote:
> I just setting out to learn how to use sqlite3 (3.6.18). Obviouly
> I'm missing some very important points.
>
> The very simple test app below is to open (and create) an sql
> datbase then close it
>
> Using windows XP. Using a precompiled .LIB. I confirmed the version
> number from the command line.
>
> It bombs!
>
> #include <iostream>
> #include "sqlite3.h"
> int main()
> {
> using namespace std;
> std::string dbName = "C:\\SQL DATABASES\\first_try.db";
> const char * c_dbName = dbName.c_str();
> sqlite3 **db;
> int rc;
>
> rc = sqlite3_open( "X", db );
The above causes SQLite to dereference pointer db, which is
uninitialized.
You want something like:
sqlite3 *db;
sqlite3_open("X", &db);
...
sqlite3_close(db);
> sqlite3_close( *db );
> return 0;
> }
>
>
> I tracked down in sqlite3.c where it bombed.
>
> #if !SQLITE_OS_WINCE && !defined(__CYGWIN__)
> int nByte;
> void *zConverted;
> char *zOut;
> UNUSED_PARAMETER(nFull);
> zConverted = convertUtf8Filename(zRelative);
> if( isNT() ){
> WCHAR *zTemp;
> nByte = GetFullPathNameW((WCHAR*)zConverted, 0, 0, 0) + 3;
> zTemp = malloc( nByte*sizeof(zTemp[0]) );
> if( zTemp==0 ){
> free(zConverted);
> return SQLITE_NOMEM; <<<<<******* GOT TO HERE THEN BOMBED
> }
> GetFullPathNameW((WCHAR*)zConverted, nByte, zTemp, 0);
> free(zConverted);
> zOut = unicodeToUtf8(zTemp);
> free(zTemp);
>
>
> Jack
>
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users