
The functions allocate-dynamic-foreign-object, allocate-foreign-object, alloca, and malloc can take the keyword arguments :type and :pointer-type . It is important to understand the difference between these two arguments.
The :type argument is used to specify the name of the FLI type to allocate. Once such an object has been allocated a foreign pointer of type (:pointer type ) is return, which points to the allocated type. Without this pointer it would not be possible to refer to the object.
The :pointer-type argument is used to specify an FLI pointer type. If it is used a pointer type of the form (:pointer type ) must be specified with it. The function then allocates an object of type type , and a pointer to the object of type type is returned.
In this first example you can see how to allocate an integer in C, and in LispWorks using the :type and the :pointer-type arguments.
C > (int *)malloc(sizeof(int))FLI > (fli:allocate-foreign-object :type :int)
=> #<Pointer to type :INT = #x007E1A60>
FLI > (fli:allocate-foreign-objects
:pointer-type '(:pointer :int))
=> #<Pointer to type :INT = #x007E1A60>