[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

Re: [sqlite] sqlite3_free()

2009-11-11 Thread Simon Davies
2009/11/11 T : > > is this right way how to do it: > > sqlite_free (errmsg); > > ??? > > > or this: > > > sqlite3_free (NULL); >From http://www.sqlite.org/c3ref/free.html: "The sqlite3_free() routine is a no-op if is called with a NULL pointer." > > or how should i do

Re: [sqlite] sqlite3_free()

2009-11-11 Thread TTTTT
is this right way how to do it: sqlite_free (errmsg); ??? or this: sqlite3_free (NULL); or how should i do it? -- View this message in context: http://old.nabble.com/sqlite3_free%28%29-tp5188068p26302585.html Sent from the SQLite mailing list archive at Nabble.com.

Re: [sqlite] sqlite3_free()

2009-11-11 Thread TTTTT
jalburger wrote: > > > > > By "the same" I mean the same sequence of bytes. The error message > from sqlite3_exec() is always obtained from a malloc-like memory > allocator and must be freed using sqlite3_free(). The error message > returned by sqlite3_errmsg() is always a constant,

Re: [sqlite] sqlite3_free()

2006-07-05 Thread jason . ctr . alburger
Please respond to Subject [EMAIL PROTECTED] Re: [sqlite] sqlite3_free() te.org

Re: [sqlite] sqlite3_free()

2006-07-05 Thread drh
[EMAIL PROTECTED] wrote: > A few quick questions... > > If an error is returned by sqlite3_exec( ) , I believe the error message is > written in the (char **errmsg) provided in the 5 parameter of the function > call. > > 1. Is this the same error text that can be obtained by >

[sqlite] sqlite3_free()

2006-07-05 Thread jason . ctr . alburger
A few quick questions... If an error is returned by sqlite3_exec( ) , I believe the error message is written in the (char **errmsg) provided in the 5 parameter of the function call. 1. Is this the same error text that can be obtained by sqlite3_errmsg( ) ? 2. If this is the same

Re: [sqlite] sqlite3_free()

2006-06-28 Thread Kervin L. Pierre
Hello, --- Dennis Cote <[EMAIL PROTECTED]> wrote: > This really has nothing to do with the Windows DLL > system. It is simply Thanks for the explanation. Wondered what that bug reporter was talking about :) There's a lot Windows does wrong, we don't have to go around making up stuff :)

Re: [sqlite] sqlite3_free()

2006-06-27 Thread Christian Smith
Andrew Piskorski uttered: On Tue, Jun 27, 2006 at 04:14:37PM +0100, Christian Smith wrote: Anyway, it's not difficult to provide thread local storage. HP-UX's netdb.h functions (gethostbyname etc.) are fully re-entrant despite returning 'static' data, for example. Other UNIXs got hamstrung

Re: [sqlite] sqlite3_free()

2006-06-27 Thread Andrew Piskorski
On Tue, Jun 27, 2006 at 04:14:37PM +0100, Christian Smith wrote: > Anyway, it's not difficult to provide thread local storage. HP-UX's > netdb.h functions (gethostbyname etc.) are fully re-entrant despite > returning 'static' data, for example. Other UNIXs got hamstrung with > various

Re: [sqlite] sqlite3_free()

2006-06-27 Thread Christian Smith
Dennis Cote uttered: Christian Smith wrote: Yes, of course, Windows sticks it's oar in again. Going back to the previous DLL discussion, this alone is surely confirmation of why the Windows DLL system sucks. This really has nothing to do with the Windows DLL system. It is simply the case

Re: [sqlite] sqlite3_free()

2006-06-27 Thread Dennis Cote
Christian Smith wrote: Yes, of course, Windows sticks it's oar in again. Going back to the previous DLL discussion, this alone is surely confirmation of why the Windows DLL system sucks. This really has nothing to do with the Windows DLL system. It is simply the case that the main

Re: [sqlite] sqlite3_free()

2006-06-27 Thread Christian Smith
[EMAIL PROTECTED] uttered: Christian Smith <[EMAIL PROTECTED]> wrote: My own personal opinion on these coding style issues is if the API requires special handling of cleanup, then the API should do the cleanup. Returning an allocated string that requires special cleanup results in a

Re: [sqlite] sqlite3_free()

2006-06-27 Thread drh
Christian Smith <[EMAIL PROTECTED]> wrote: > > My own personal opinion on these coding style issues is if the API > requires special handling of cleanup, then the API should do the cleanup. > Returning an allocated string that requires special cleanup results in a > potentially generic

Re: [sqlite] sqlite3_free()

2006-06-27 Thread Christian Smith
[EMAIL PROTECTED] uttered: Two SQLite APIs, sqlite3_exec() and sqlite3_mprintf(), return strings in memory obtained from a malloc-like memory allocator. The documentation has always said that you need to use sqlite3_free() in order to free those strings. But, as it happens, it has until now

[sqlite] sqlite3_free()

2006-06-27 Thread drh
Two SQLite APIs, sqlite3_exec() and sqlite3_mprintf(), return strings in memory obtained from a malloc-like memory allocator. The documentation has always said that you need to use sqlite3_free() in order to free those strings. But, as it happens, it has until now worked to call plain old free().