[cffi-devel] About double pointers and C & operator

Luís Oliveira luismbo at gmail.com
Mon Apr 19 19:09:04 UTC 2010


On Sun, Apr 18, 2010 at 7:17 PM, Alexandre Paes
<alex.paes at streetdogstudio.com> wrote:
> (defun release-capture (capture*)
>   (cffi:with-foreign-object (capture** :long)
>     (setf (cffi:mem-ref capture** :long)
>           (cffi:pointer-address capture*))
>     (%release-capture capture**)))
> It works but it doesn't feel all that nice, is this the best/correct way of
> achieving the same as the C code?

You should probably use the pointer type:

    (with-foreign-object (capture** :pointer)
      (setf (cffi:mem-ref capture** :pointer) capture*)
      (%release-capture capture**))

Enhancing with-foreign-object such that it accepts the same arguments
as foreign-alloc is in my wish list. That would help make this example
more concise.

HTH,

-- 
Luís Oliveira
http://r42.eu/~luis/




More information about the cffi-devel mailing list