10 Sep 23:32
foreign strings
From: Andy Chambers <achambers.home <at> googlemail.com>
Subject: foreign strings
Newsgroups: gmane.lisp.cffi.devel
Date: 2008-09-10 21:35:19 GMT
Subject: foreign strings
Newsgroups: gmane.lisp.cffi.devel
Date: 2008-09-10 21:35:19 GMT
Hi,
I'm still plugging away on sqlite
I've got a problem creating a binding for the following function
int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
I tried the following....
(defcfun ("sqlite3_bind_text" %sqlite-bind-text) :int
(stmt :pointer)
(index :int)
(value :string)
(len :int)
;; not really an int but cffi takes care of this for us
(destructor :int))
Everything is pretty straightforward apart from the last two
parameters. Length is supposed to be the length of the value being
passed in (or -1 if the value is null terminated).
The destructor is supposed to be a function that frees the memory
required by `value' after sqlite is finished with it. For destructor,
you can use the special value 0 if the memory
is in "unmanaged" space. So I have a few questions...
1. If you specify the type as :string, does cffi pass it through as a
null terminated string?
2. Does cffi take care of freeing a string once the C library is
finished with it or should I define a callback to use for the
(Continue reading)
RSS Feed