All Manuals > Foreign Language Interface User Guide and Reference Manual > 7 Function, Macro and Variable Reference

decf-pointer Function

Summary

Decreases the address held by a pointer.

Package

fli

Signature

decf-pointer pointer &optional delta => pointer

Arguments
pointer
A FLI pointer.
delta
An integer. The default is 1.
Values
pointer
The pointer passed.
Description

The function decf-pointer decreases the address held by pointer. If delta is not given the address is decreased by the size of the type pointed to by pointer. The address can be decreased by a multiple of the size of the type by specifying a value for delta. If the size of the type is 0 then an error is signalled.

The function decf-pointer is often used to move a pointer through an array of values.

Examples

In the following example an array with 10 entries is defined. A copy of the pointer to the array is made, and is incremented and decremented.

(setq array-obj
      (fli:allocate-foreign-object :type :int
        :nelems 10
        :initial-contents '(0 1 2 3 4 5 6 7 8 9)))
 
(setq point1 (fli:copy-pointer array-obj))
 
(dotimes (x 9) 
  (print (fli:dereference point1))
  (fli:incf-pointer point1))
 
(dotimes (x 9) 
  (fli:decf-pointer point1)
  (print (fli:dereference point1)))
See also

incf-pointer
3.4 An example of dynamic pointer allocation


Foreign Language Interface User Guide and Reference Manual - 01 Dec 2021 19:34:58