The with-foreign-pointer
macro, binds var to size
bytes of foreign memory during body. The pointer in var
is invalid beyond the dynamic extend of body and may be
stack-allocated if supported by the implementation.
If size-var is supplied, it will be bound to size during body.
CFFI> (with-foreign-pointer (string 4 size) (setf (mem-ref string :char (1- size)) 0) (lisp-string-to-foreign "Popcorns" string size) (loop for i from 0 below size collect (code-char (mem-ref string :char i)))) => (#\P #\o #\p #\Null)