Re: [sqlite] Re: Callback issue - using pointer as argument

2008-01-30 Thread David HAUTBOIS

It works better.

Thanks.

David.

Igor Tandetnik wrote:

David Hautbois <[EMAIL PROTECTED]> wrote:


char * get_config_value (sqlite3 * db, char * config_name) {

   TabResult res;

   rc= sqlite3_exec( db, query, exec_get_config_value_cb , ,
);


Strings passed to the callback are valid only within the callback. As 
soon as the callback returns, the memory may be deallocated or reused 
for other purposes. If the callback wants to keep some strings around 
beyond a single call, it should allocate its own memory and copy the 
value over.


Better still, stop using sqlite3_exec and switch over to 
sqlite3_prepare / sqlite3_step / sqlite3_finalize interface.


Igor Tandetnik

- 


To unsubscribe, send email to [EMAIL PROTECTED]
- 





--
http://david.hautbois.free.fr
http://slugplayer.free.fr


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Re: Callback issue - using pointer as argument

2008-01-29 Thread Igor Tandetnik

David Hautbois <[EMAIL PROTECTED]> wrote:


char * get_config_value (sqlite3 * db, char * config_name) {

   TabResult res;

   rc= sqlite3_exec( db, query, exec_get_config_value_cb , ,
);


Strings passed to the callback are valid only within the callback. As 
soon as the callback returns, the memory may be deallocated or reused 
for other purposes. If the callback wants to keep some strings around 
beyond a single call, it should allocate its own memory and copy the 
value over.


Better still, stop using sqlite3_exec and switch over to sqlite3_prepare 
/ sqlite3_step / sqlite3_finalize interface.


Igor Tandetnik 



-
To unsubscribe, send email to [EMAIL PROTECTED]
-