| Allegro CL version 8.2 Unrevised from 8.1 to 8.2. 8.1 version |
Arguments: type &optional allocation size
This function allocates an object of the given type in the heap area described by the allocation argument. If the size argument is given, then it is the minimum size (in bytes) of the data portion of the object that will be allocated. The function sizeof-fobject, which returns the size of an object of the given foreign type, might be useful in determining possible values for size.
The valid allocation argument values are as follows (default is :foreign). type should be a type defined with def-foreign-type.
aclmalloc
). Unlike other objects allocated in
static space, these objects are automatically gc'ed (the C
aclfree
function is called on them) when the last
pointer to them in the Lisp heap disappears. The advantage of this
allocation type over :foreign
is that the object
doesn't move. This makes it very useful when the object must be passed
to a C foreign-function that releases the heap (e.g. most functions in
the Windows package).
:lisp
and then call read-sequence to read the data from
the binary file into the foreign object. Note, however, that read-sequence will also work for
:foreign
allocated objects.
There is one tricky case for 32-bit Lisps (it is not an issue on 64-bit Lisps): if the foreign structure requires 8 byte alignment (e.g. it begins with a double float) then the first four bytes of the lisp array allocated will not be used by fslot-value-typed. If you read-sequence into such an array, then your data will be displaced 4 bytes from where fslot-value-typed thinks it is.
:lisp
type
described just above, except that the data is held in a
short-array. (short-arrays are a new data type corresponding to the
older array type in Allegro CL. See Arrays and short arrays section in
implementation.htm.) Except for using a
short-array, this type is the same as :lisp
.
:aligned
- This is just like :c
except that it returns an aligned pointer. Objects allocated
in :aligned
mode should be freed with
free-fobject-aligned.
See ftype.htm for information on foreign types in Allegro CL and foreign-functions.htm for general information on foreign functions in Allegro CL.
Copyright (c) 1998-2016, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.1 page.
Created 2010.1.21.
| Allegro CL version 8.2 Unrevised from 8.1 to 8.2. 8.1 version |