SQLite Forum

Freeing memory used in sqlite£-result_blob
If a referenced memory object never goes away and keeps its value, use SQLITE_STATIC.

e.g.: static const char id[] = "";

If a referenced memory object goes away or looses its value, use SQLITE_TRANSIENT.

e.g. examples 1 (malloc & free in user function) and 3 (stack variable) in the original post

Otherwise, pass a destructor function.

e.g. example 2 (malloc, pass destructor) in the original post