On Apr 14, 2009, at 12:48 PM, Richard Dauben wrote: > After successfully reading from a blob sequentially to a buffer in > Objective C > the buffer seems to be altered such that it can no longer be > accessed from > memory.... Is there some kind of special buffer type that I should > be using? > Here is sample of my code: > > int success; > NSData *inBuffer; > success = sqlite3_blob_read(blobData, inBuffer, intByteCount, > intOffsetInBlob); > > After running this code, success == SQLITE_OK. Prior to reading the > blob, > inBuffer behaves normally. Afterward, it no longer behaves like a > buffer, and I > cannot get any valid data from it. I have set intByteCount to make > sure it is > smaller than the number of bytes in the Blob, and intOffsetInBlob = 0
sqlite3_blob_read expects a valid pointer pointing to an allocated buffer, but you're passing it an uninitialized NSData pointer. Something like this ought to work: int success; NSMutableData *inBuffer = [NSMutableData dataWithLength:intByteCount]; if (inBuffer) success = sqlite3_blob_read(blobData, [inBuffer mutableBytes], intBytesCount, intOffsetInBlob); You'll probably also need to dispose of the NSMutableData object when you're through with it. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users