summaryrefslogtreecommitdiff
path: root/posts/dbi-crap-api.mdwn
diff options
context:
space:
mode:
Diffstat (limited to 'posts/dbi-crap-api.mdwn')
-rw-r--r--posts/dbi-crap-api.mdwn30
1 files changed, 30 insertions, 0 deletions
diff --git a/posts/dbi-crap-api.mdwn b/posts/dbi-crap-api.mdwn
new file mode 100644
index 0000000..adf0ebd
--- /dev/null
+++ b/posts/dbi-crap-api.mdwn
@@ -0,0 +1,30 @@
+[[!meta title="APIs don't matter, do they?"]]
+[[!meta author="Daniel Silverstone"]]
+[[!meta date="2005-07-07 17:20:45 +0100"]]
+[[!tag tech]]
+
+I’d like to introduce you to a bit of API which belongs to
+[libdbi](http://libdbi.sourceforge.net/) which belongs in the “Mommy,
+who cut my crack with washing powder?” box…
+
+<tt style="white-space: nowrap;">int
+dbi\_driver\_quote\_string(dbi\_driver Driver, char
+\*\*orig)<br><br>&\#160;&\#160;Encloses the target string in the types
+of quotes that the database expects,<br>&\#160;&\#160;and escapes any
+special characters. The original string will be freed and
+will<br>&\#160;&\#160;point to a newly allocated one (which you still
+must free on your own).<br><br>Arguments<br>&\#160;&\#160;Driver: The
+target driver.<br>&\#160;&\#160;orig: A pointer to the string to quote
+and escape.<br><br>Returns<br>&\#160;&\#160;The new string’s
+length.</tt>
+
+Now what on earth posesses someone to think that such an API is better
+than, for example:
+`char&#160;*dbi_driver_quote_string(dbi_Driver&#160;Driver,&#160;const&#160;char&#160;*orig)`
+returning, ooh `NULL` if it had a problem?
+
+Now I have to get a string out of [Lua](http://www.lua.org/), `strdup()`
+it, only to have it `free()`d when the quote function gets a hold of it.
+But hey, malloc churn is fast, right?
+
+— <em>Bletch</em>