[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-15 Thread Bart Smissaert
Thanks, nice and simple and helpful advice. RBS On 15 Dec 2015 1:45 pm, "Richard Hipp" wrote: > On 12/15/15, Bart Smissaert wrote: > > So I will need to use SQLITE_TRANSIENT then? > > > > Yes. Always use SQLITE_TRANSIENT, at least initially. All the other > options are optimizations. Do not

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-15 Thread Bart Smissaert
> I have no idea how VB6 implements local variables Pure local variables (declared in the actual procedure) are on the stack as well in VB6. VB6 hides all these kind of details, so I never think about this/deal with this. RBS On Tue, Dec 15, 2015 at 9:33 AM, Hick Gunter wrote: > >Thanks for

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-15 Thread Bart Smissaert
> If you are saying that you plan to obtain the character pointer by calling sqlite3_value_text, then pass that exact pointer to sqlite3_result_text, then I would suggest you use sqlite3_result_value instead But sqlite3_result_value has no option to only set the first X bytes, so it won't allow

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-15 Thread Bart Smissaert
> like sqlite3_malloc() or sqlite3_mprinft() to produce the string. OK, I won't be doing that. > I guess NO So I will need to use SQLITE_TRANSIENT then? > You should know where the memory used to store the string in your own code comes from and how to deal with it. It will nearly always be a

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-15 Thread Hick Gunter
>Thanks for clarifying that. > >> If the pointer refers to memory obtained from sqlite3_malloc >How do I know that is the case? >My callback procedure (the procedure that does the actual work, altering the >string) is in a VB6 ActiveX dll, so not in sqlite3.dll If you called an sqlite3 API

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-15 Thread Bart Smissaert
: sqlite-users-bounces at mailinglists.sqlite.org [mailto: > sqlite-users-bounces at mailinglists.sqlite.org] Im Auftrag von Bart > Smissaert > Gesendet: Montag, 14. Dezember 2015 20:22 > An: General Discussion of SQLite Database > Betreff: [sqlite] sqlite3_free needed when calling sql

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-15 Thread Bart Smissaert
> but the string "abc" is not 4 bytes long, no matter how you count. Yes, sorry to cause confusion there, the -2 got in there as in my testing setup there was always a space before the string to find. This is not really to do with the problem I am seeing though. RBS On Tue, Dec 15, 2015 at

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-15 Thread Richard Hipp
On 12/15/15, Bart Smissaert wrote: > So I will need to use SQLITE_TRANSIENT then? > Yes. Always use SQLITE_TRANSIENT, at least initially. All the other options are optimizations. Do not use the other options prematurely (that is to say, without first trying SQLITE_TRANSIENT and actually

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-15 Thread Hick Gunter
Nachricht- Von: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users-bounces at mailinglists.sqlite.org] Im Auftrag von Bart Smissaert Gesendet: Montag, 14. Dezember 2015 20:22 An: General Discussion of SQLite Database Betreff: [sqlite] sqlite3_free needed when calling

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-15 Thread Bart Smissaert
Maybe I shouldn't make Unicode strings but keep it all in UTF8. Not sure though how to get the position then of string2 in string1, lPos. RBS On Tue, Dec 15, 2015 at 12:42 AM, Bart Smissaert wrote: > Yes, str and str2 are Unicode string, 2 bytes per character. > lPos counts per character,

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-15 Thread Bart Smissaert
Yes, str and str2 are Unicode string, 2 bytes per character. lPos counts per character, not byte, so if the string in the database is abcde and I want to find the first position of d in that string then lPos will be 4. > You are converting in one direction (SQLite to VB), but not in the other I

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-14 Thread Bart Smissaert
OK, thanks, will have to study this carefully. So, if I understand you well then the way I do it now I would need sqlite3_free? Not sure it is helpful, but this is the callback procedure as I have it. It will find a specified string (second argument in SQL) in the supplied field value (first

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-14 Thread Igor Tandetnik
On 12/14/2015 7:42 PM, Bart Smissaert wrote: > Yes, str and str2 are Unicode string, 2 bytes per character. > lPos counts per character, not byte, so if the string in the database is > abcde and I want to find the first position > of d in that string then lPos will be 4. ... and then you pass

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-14 Thread Bart Smissaert
It could be either a pointer to sqlite3_value_text of sqlite3_value* or it could be a pointer to a locally declared variable, so that is declared in a procedure in a VB6 ActiveX dll. Do I need to run sqlite3_free in the first case and not in the second case? If do need to run it how do I do it? As

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-14 Thread Igor Tandetnik
On 12/14/2015 5:46 PM, Bart Smissaert wrote: > OK, thanks, will have to study this carefully. > So, if I understand you well then the way I do it now I would need > sqlite3_free? First, I don't know how you do it now - you've never described that. Second, I have not ever said you needed

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-14 Thread Bart Smissaert
Not sure if I need to call sqlite3_free after running sqlite3_result_text or if sqlite3_free should be an argument (last one) in sqlite3_result_text. Currently I am using SQLITE_TRANSIENT as the last argument, so that is after the number of bytes, but have feeling I might be doing this wrong.

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-14 Thread Igor Tandetnik
On 12/14/2015 3:09 PM, Bart Smissaert wrote: > It could be either a pointer to sqlite3_value_text of sqlite3_value* No it can't be. sqlite3_result_text takes a char*, not a sqlite3_value* or a const unsigned char*(*)(sqlite3_value*) If you are saying that you plan to obtain the character

[sqlite] sqlite3_free needed when calling sqlite3_result_text ?

2015-12-14 Thread Igor Tandetnik
On 12/14/2015 2:21 PM, Bart Smissaert wrote: > Not sure if I need to call sqlite3_free after running sqlite3_result_text or > if sqlite3_free should be an argument (last one) in sqlite3_result_text. That depends on how the memory was obtained that the second argument points to. -- Igor