a FLI type specifying the type of the object to be allocated. If type is supplied, pointer-type must not be supplied.
A FLI pointer type specifying the type of the pointer object to be allocated. If pointer-type is supplied, type must not be supplied.
A keyword setting the initial value of every element in the newly allocated object to initial-element.
A list of forms which initialize the contents of each element in the newly allocated object.
An integer between 0 to 255.
An integer specifying how many copies of the object should be allocated. The default value is 1.
A symbol naming a slot in the object.
A keyword, either
If allocation is
:static then memory is allocated in the C heap and must be explicitly freed using free-foreign-object once the object is no longer needed.
If allocation is
allocate-foreign-object allocates memory for the object and pointer within the scope of the body of with-dynamic-foreign-objects. This is equivalent to using allocate-dynamic-foreign-object.
If initial-contents is supplied and its length is greater than nelems, then the length of initial-contents overrides nelems. This is a common case where initial-contents is supplied and nelems is omitted (and hence defaults to 1).
A supplied value of size-slot applies if the type is a struct or union type. The slot size-slot is set to the size of the object in bytes. This occurs after the fill, initial-element and initial-contents arguments are processed. If nelems is greater than 1, then the slot size-slot is initialized in each element. If size-slot is not supplied, then no such setting occurs.
In the following example a structure is defined and an instance with a specified initial value of 10 is created with memory allocated using
allocate-foreign-object. The dereference function is then used to get the value that
point points to, and finally it is freed.
(fli:define-c-typedef LONG :long)
LispWorks Foreign Language Interface User Guide and Reference Manual - 16 Feb 2015