Hello,

I'm cooking up some blob reading code based on the following example ->

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

The author prepares a statement and reads the blob value in the following
manner ->

   *if*( rc==SQLITE_ROW ){**
     *pnBlob =
sqlite3_column_bytes<http://www.sqlite.org/capi3ref.html#sqlite3_column_bytes>
(pStmt, 0);
     *pzBlob = (unsigned char *)malloc(*pnBlob);
     memcpy(*pzBlob,
sqlite3_column_blob<http://www.sqlite.org/capi3ref.html#sqlite3_column_blob>
(pStmt, 0), *pnBlob);
   }
   ...
   rc = sqlite3_finalize<http://www.sqlite.org/capi3ref.html#sqlite3_finalize>
(pStmt);

At the point prior to the call to sqlite3_finalize, the blob is going to
more stored twice in memory. In my application, however, memory is very
tight. Is there an easy way I can get around sqlite3_finalize freeing the
blob data? Deferring the finalize until I am done processing the blob really
isn't a palatable option....

On a similar note, are there any hacks available to write a blob to a file
using a limited memory buffer? As far as I can tell, the sqlite API requires
that a blob be read in its entirety, which is rather unfortunate when the
blob is bigger than memory...

Thanks,
-Stan

Reply via email to