[cffi-devel] with-pointer-to-vector-data
David Lichteblau
david at lichteblau.com
Tue Sep 12 12:37:34 UTC 2006
Quoting rpgoldman at sift.info (rpgoldman at sift.info):
> a pointer for the C code to use, the important thing is to avoid
> having the lisp gc move the byte vector around, which is accomplished
> by the use of register-lisp-value.
Are you sure? I believe r-l-v just returns an integer index into a
global table that can later be used to retrieve the object again. That
keeps it from being garbage collected, but not from movement in memory.
What I am "using" (not well-tested) is this:
(defun make-shareable-byte-vector (size)
(make-array size
:element-type '(unsigned-byte 8)
:allocation :static-reclaimable))
(defmacro with-pointer-to-vector-data ((ptr-var vector) &body body)
`(let ((,ptr-var ,vector))
, at body))
(The old discussion of whether this kind of thing is worth supporting at
all notwithstanding.)
d.
More information about the cffi-devel
mailing list