> should I end the function > > sqlite3_result_blob(ctx,blob,50,SQLITE_TRANSIENT); > free(blob); > > or > > sqlite3_result_blob(ctx,blob,50,free); > > While the latter would save sqlite having to create a copy of the blob I'm a bit worried about the function being called multiple times in the same sql statement e.g. > > select fct(..), fct(..), fct(..), fct(..), fct(..); > and the frees building up. Am I worrying about nothing? Either of those two is correct. The difference in performance is most likely too small to worry about, unless your application is super performance-critical. No need to worry about the "frees building up" either. Using SQLITE_TRANSIENT might make the code easier to grok, but I think it's a matter of taste more than anything. > Also, is the use of SQLITE_TRANSIENT a necessity if the memory will be automatically freed at the end of the function? e.g. in the case of > char blob[50]={...}; It is, yes. Otherwise SQLite will try to use the buffer after it has been automatically freed.