Thanks for your reply Richard

> >* 1. Is the memory for sqlite3_temp_directory ever cleaned up?
*> >>
> Not by SQLite.  That memory is the responsibility of the application that
> allocated it.

Given the memory may be cleaned up by sqlite itself in some cases:
1. Freeing it after calling shutdown (ie when we're certain sqlite is not
going to use it anymore) using sqlite3_temp_directory itself wouldn't work,
since sqlite3_temp_directory seems to be set to null after calling shutdown
2. Keeping a copy of the pointer to free it later could result in a double
free [quote: the pragma may attempt to free that memory...]
3. Freeing it just before calling shutdown seems to me like a race
condition (I haven't done any tests in this regard, though)

How would you suggest to implement the cleanup for sqlite3_temp_directory?

> I will add text encouraging people to NOT use this interface.

Is there a better alternative to dynamically set a temp path?

Cheers

----------------------

>* Is the memory used by sqlite3_temp_directory freed by sqlite or should it
*>* be freed by the user?
*>>* From the documentation for sqlite3_temp_directory:
*>>* ** the [temp_store_directory pragma] always assumes that any string
*>* ** that this variable points to is held in memory obtained from
*>* ** [sqlite3_malloc] and the pragma may attempt to free that memory
*>* ** using [sqlite3_free].
*>>* From this I understand that the memory ownership gets transferred to
*>* sqlite, so the responsibility for clean up should be sqlite's (presumably
*>* in the sqlite3_shutdown function). This doesn't seem to be the case,
*>* though.
*>>* 1. Is the memory for sqlite3_temp_directory ever cleaned up?
*>
Not by SQLite.  That memory is the responsibility of the application that
allocated it.



>* 2. If not, should it be?
*>
No.  To do so would break legacy applications that clean it up themselves.


>* 3. Could the information about the memory ownership be added to the
*>* documentation? I believe this would also apply to other extern-definitions
*>* as well.
*>
I will add text encouraging people to NOT use this interface.  yes.


>>* Cheers
*>>* Nicolás Brailovsky
*>* - Tech blog http://monoinfinito.wordpress.com
<http://monoinfinito.wordpress.com>
*>* _______________________________________________
*>* sqlite-users mailing list
*>* sqlite-users at sqlite.org
<http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users>
*>* http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
<http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users>
*>


-- 
D. Richard Hippdrh at 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

Reply via email to