The Blob Example [1] contains code [2] in which, if sqlite3_prepare()  
fails, the subsequent call to sqlite3_finalize() is skipped.  Is this  
OK?  Does sqlite3_prepare() free up any memory it may have allocated  
if it fails?

I've read the documentation for these two functions but still don't  
know.

Thanks,

Jerry Krinock

[1] http://www.sqlite.org/cvstrac/wiki?p=BlobExample

[2]:
static int writeBlob(
   sqlite3 *db,
   const char *zKey,
   const unsigned char *zBlob,
   int nBlob) {
   const char *zSql = "INSERT INTO blobs(key, value) VALUES(?, ?)";
   sqlite3_stmt *pStmt;
   int rc;

   do {
     rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);
     if( rc!=SQLITE_OK ){
       return rc;
     }

     sqlite3_bind_text(pStmt, 1, zKey, -1, SQLITE_STATIC);
     sqlite3_bind_blob(pStmt, 2, zBlob, nBlob, SQLITE_STATIC);

     rc = sqlite3_step(pStmt);
     assert( rc!=SQLITE_ROW );

     rc = sqlite3_finalize(pStmt);

   } while( rc==SQLITE_SCHEMA );

   return rc;
}

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

Reply via email to