-----Oorspronkelijk bericht-----
Van: Kiril Dzolev [mailto:[EMAIL PROTECTED]
Verzonden: woensdag 2 augustus 2006 13:54
Aan: [email protected]
Onderwerp: Re: [sqlite] reading BLOB - Segmentation fault
There is no warning. But as I can see the problem is here
If erase this line
lengthBLOB=blobGet.getBinaryLength();
end just print it like
cout<<"Retrieved binary Length: "<<blobGet.getBinaryLength()<<endl;
that everything is ok. But I need this integer that
blobGet.getBinaryLength() is returning, to keep it as a value.
Kiril
On 02/08/06, Martin Jenkins <[EMAIL PROTECTED]> wrote:
>
> Kiril Dzolev wrote:
>
> You're calling blobGet(), but blobGet is an unitialised variable of
> type "CppSQLite3Binary" (whatever that is). Doesn't your compiler warn
> you about that?
>
> Martin
>
> > const unsigned char* putBLOBInBinary([...])
> > {
> > [...]
> > CppSQLite3Binary blobGet;
> >
> > [...]
> > if (!q.eof()) {
> > blobGet.setEncoded((unsigned char*)q.fieldValue("data"));
>
>
> > 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,
> > Kiril
> >
>
>
Are you using pBufferOut later in main()? I think you can't pass a pointer
to a member object because that object is invalid outside your function,
unless ofcourse if the object isn't responsible for cleanup.
Merijn