I’d like to introduce you to a bit of API which belongs to libdbi which belongs in the “Mommy, who cut my crack with washing powder?” box…
dbi_driver_quote_string(dbi_driver Driver, char
Encloses the target string in the types of quotes that the database expects,
and escapes any special characters. The original string will be freed and will
point to a newly allocated one (which you still must free on your own).
Driver: The target driver.
orig: A pointer to the string to quote and escape.
The new string’s length.
Now what on earth posesses someone to think that such an API is better
than, for example:
char *dbi_driver_quote_string(dbi_Driver Driver, const char *orig)
NULL if it had a problem?
Now I have to get a string out of Lua,
it, only to have it
free()d when the quote function gets a hold of it.
But hey, malloc churn is fast, right?