CARIOTOGLOU MIKE wrote:
I am creating a Delphi wrapper for sqlite 3 API. I am having some trouble
interpeting the documentation and c header
files. specifically, I am not sure how to handle these:
int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n,
void(*)(void*));
int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n,
void(*)(void*));
with regard to the last parameter. I am reading it as being a pointer to a
function that takes a pointer and returns
nothing (a procedure). but, nowwhere is it mentioned what this function is
supposed to do...
also, the documentation in sqlite3.h mentions a parameter "eCopy", which
defines whether bound parameters are static or
volatile. but, I cannot see where this is declared and/or passed. I am
guessing that this has to do with this last
"weird" parameter. Could somebody, preferably DRH, step in and explain,
please ?
Another documentation bug....
The void(*)(void*) is indeed a pointer to a procedure that takes
a single void* argument. This is a pointer to a destructor for
the text or blob you pass in. SQLite will invoke the destrutor on
the text or blob passed in when SQLite has finished using it.
There are two special values for this destructor argument:
SQLITE_STATIC and SQLITE_TRANSIENT. If the destructor is set
to SQLITE_STATIC, then SQLite assumes that the string or blob
being passed in is permanently and statically allocated and
does not need to be destroyed, ever. If the argument is
SQLITE_TRANSIENT, then SQLite immediately makes its own private
copy of the string or blob before it returns and no destructor
is ever called on the original.
Example: If you have a string held in memory obtained from
malloc(), you can pass that string to sqlite3_bind_text() and
give it a pointer to free() as the destructor. Then SQLite
will free() the string when it has finished using it.
--
D. Richard Hipp -- [EMAIL PROTECTED] -- 704.948.4565