> This is not realy for this forum, but maybe somebody can tell me what I am
> doing wrong. I am using CppSQLite wrapper.
>
> Code 1 : With this code "Segmentation fault"
>
> const unsigned char* putBLOBInBinary(CppSQLite3DB &db, int &lengthBLOB) {
>     CppSQLite3Query q;
>     CppSQLite3Binary blobGet;
>
>     q=db.execQuery("select data from bindata where id=1;");
>     if (!q.eof()) {
>         blobGet.setEncoded((unsigned char*)q.fieldValue("data"));
>         lengthBLOB= blobGet.getBinaryLength();
>         cout<<"Retrieved binary Length: "<<lengthBLOB <<endl;
>     }
>     return blobGet.getBinary();
> }
>
> function call from main()
> const unsigned char* pBufferOut;
> pBufferOut = putBLOBInBinary(db, lengthBLOB);
>
> Code 2 : With this code is ok (if I dont use function)
>     CppSQLite3Query q;
>     CppSQLite3Binary blobGet;
>
>     q=db.execQuery("select data from bindata where id=1;");
>     if (!q.eof()) {
>         blobGet.setEncoded((unsigned char*)q.fieldValue("data"));
>         lengthBLOB= blobGet.getBinaryLength();
>         cout<<"Retrieved binary Length: "<<lengthBLOB <<endl;
>     }
>     pBufferOut=blobGet.getBinary();
>
> sorry if this is off topic,

This is completely off topic, it is a simple programming error, I am sure.
Your lengthBLOB outside of the function is fishy, you didn't show even
how and where you have declared it. Your example proofs that not the call to
blobGet.getBinaryLength() is the problem, but the assignment to
lengthBLOB, and lengthBLOB is a reference, to what?

Gerald

Gerald

Reply via email to