-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jean-Christophe Deschamps wrote: > a) is it allowable for a scalar function to modify (in place) an input > argument
No. > b) same question for unmodified arguments: is it possible to avoid > duplication > of an argument if the function determines it is to be returned > verbatim? > As I read it the function to use is sqlite3_result_value but it > duplicates. Yes use sqlite3_result_value - see ifnullFunc in the sqlite source for an example. There is no issue with it duplicating (the code is not performance critical, C is not garbage collected or reference counted etc). If you disagree with this then make a patched version and run a benchmark showing the difference. > c) is it true that the following return methods are both acceptable, > with method > 2 being better by not forcing an immediate dupplication of the > returned value > and a byte count of the string? > > 1) [result r obtained from sqlite3_malloc] > ... > sqlite3_result_text(context, r, -1, SQLITE_TRANSIENT); > sqlite3_free(r); > } > > 2) [result r obtained from sqlite3_malloc] > ... > sqlite3_result_text(context, r, effective_byte_length, > sqlite3_free); > } Correct 1 requires a copy while 2 takes ownership of the string. You are trying really hard to overthink things :-) Roger -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkrenJEACgkQmOOfHg372QRj/ACfVAQG1HDfFLtL9JcHklyU0K82 2OkAoLLDdaTAxdgeWYfxM4SzDNTtNRIB =B7Vq -----END PGP SIGNATURE----- _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users