Thank you guys for the responses. Great info to consider. I was quite confused but the fact that by waiting some length of time after startup of the app, that everything appeared to work. I repeated ran the troublesome call (without stopping the app), and it would work the 6-7 times of making the call.
Bob Moran On Fri, Sep 5, 2014 at 10:15 AM, Nelson, Erik - 2 < erik.l.nel...@bankofamerica.com> wrote: > Bob Moran wrote on: Friday, September 05, 2014 12:07 AM > > On Wed, Sep 3, 2014 at 1:29 PM, Nelson, Erik - 2 < > > erik.l.nel...@bankofamerica.com> wrote: > > > > > Bob Moran wrote on Wednesday, September 03, 2014 12:45 PM > > > > > > > > One added note: My GUI is using QT4, where in this case the SQL > > text > > > > goes something like: > > > > > > > > QString qstr = "select id, step, temp from protocols where id > > > > = %1"; > > > > qstr = qstr.arg(id); > > > > char * str = (char*)qPrintable(qstr); > > > > sqlite3_prepare_v2( db, str, qstr.Length+1, &stmt, NULL) > > > > > > > > > > That's pretty different than the pseudocode you presented earlier. > > > > > > From the docs for qPrintable > > > http://qt-project.org/doc/qt-4.8/qtglobal.html#qPrintable > > > > > > ********************** > > > Returns str as a const char *. This is equivalent to > > > str.toLocal8Bit().constData(). > > > > > > The char pointer will be invalid after the statement in which > > > qPrintable() is used. This is because the array returned by > > > toLocal8Bit() will fall out of scope. > > > **************************** > > > > > > Your str is likely pointing to memory that has been freed? > > > > > Are you implying that I must copy the text returned by qPrintable(sql) > > to a safe location before calling a method that uses it? I thought that > > the string would be valid until I return from the routine. > > Based on my reading of the documentation, yes. > > The char pointer will be invalid after the *statement* in which > qPrintable() is used. > > You've already provided additional evidence that your string is pointing > to unallocated memory... you previously wrote > > >Bob Moran wrote on 03. September 2014 06:25 > >>I discovered that a malloc call for 500+ bytes was returning a pointer 8 > bytes below my SQL string > > On the face of it, I'd suggest that indicates that the memory pointed by > your char* has been reallocated since it was returned to the free store. > > Also, as Alessandro mentioned, the length you're using is likely > unreliable. > > Erik > > ---------------------------------------------------------------------- > This message, and any attachments, is for the intended recipient(s) only, > may contain information that is privileged, confidential and/or proprietary > and subject to important terms and conditions available at > http://www.bankofamerica.com/emaildisclaimer. If you are not the > intended recipient, please delete this message. > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users