Previous: Alien Coercion Operations, Up: Alien Operations [Contents][Index]
Dynamic Aliens are allocated using the malloc
library, so foreign code
can call free
on the result of make-alien
, and Lisp code can
call free-alien
on objects allocated by foreign code.
This macro returns a dynamically allocated Alien of the specified type (which is not evaluated.) The allocated memory is not initialized, and may contain arbitrary junk. If supplied, size is an expression to evaluate to compute the size of the allocated object. There are two major cases:
deref
to change the result to an array before you
can use deref
to read or write elements:
(defvar *foo* (make-alien (array char 10))) (type-of *foo*) ⇒ (alien (* (array (signed 8) 10))) (setf (deref (deref foo) 0) 10) ⇒ 10
If supplied, size is used as the first dimension for the array.
(make-alien int)
returns a (* int)
. If size
is specified, then a block of that many objects is allocated, with
the result pointing to the first one.
This function frees the storage for alien (which must have
been allocated with make-alien
or malloc
.)
See also with-alien
, which stack-allocates Aliens.
Previous: Alien Coercion Operations, Up: Alien Operations [Contents][Index]