What is the difference between these two cffi functions? The fine manual is rather terse about this and I haven't managed to make them do something different yet.
-a
-a
Discuss and learn Lisp programming of all dialects
This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.
3 posts · 1940 views
The mem-aref function is similar to mem-ref but will automatically calculate the offset from an index.To elaborate, the optional argument to those functions is treated differently, in mem-ref the offset is in bytes, but in mem-aref the offset is the index multiplied by the size of referenced type.
(defun mem-aref (ptr type &optional (index 0))
"Like MEM-REF except for accessing 1d arrays."
(mem-ref ptr type (* index (foreign-type-size type))))
Although there are compiler macros which implement optimizations if TYPE and/or INDEX are constant.