The function
foreign-array-pointer
returns a pointer to a specified element in an array. The value pointed to can then be obtained by dereferencing the pointer returned, or set to a specific value using
(setf dereference)
.
In this example a 3 by 2 array of integers is created, and a pointer to the element at position
2 0
is returned using
foreign-array-pointer
.
(setq array1 (fli:allocate-foreign-object
:type '(:c-array :int 3 2)))
(setq array-ptr (fli:foreign-array-pointer array1 2 0))
The
(setf dereference)
function can now be used to set the value pointed to by
array-ptr
.
(setf (fli:dereference array-ptr) 42)