[Cffi-devel] cffi idioms: with-foreign-pointer

Luís Oliveira luismbo at gmail.com
Mon Feb 16 12:59:30 UTC 2015


On Sun, Feb 8, 2015 at 12:55 AM, Mirko Vukovic <mirko.vukovic at gmail.com> wrote:
>      (let ((num-channel-groups* (foreign-alloc :uint)))
>         (ddc-get-num-channel-groups file-handle* num-channel-groups*)
>         (prog1 (mem-ref num-channel-groups* :uint)
>           (foreign-free num-channel-groups*)))
>
>
> Is with-foreign-pointer the idiomatic way to accomplish the same thing?

Yes. with-foreign-object is even more convenient since it takes a type
rather than a size. with-foreign-object and with-foreign-pointer will
also perform stack allocation on implementations that support it.

Cheers,

-- 
Luís Oliveira
http://kerno.org/~luis/




More information about the cffi-devel mailing list