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

allocate-dynamic-foreign-object

alloca Functions

Summary

Allocates memory for an instance of a foreign object within the scope of a with-dynamic-foreign-objects macro.

Package

fli

Signatures

allocate-dynamic-foreign-object &key type pointer-type initial-element initial-contents fill nelems size-slot => pointer

alloca &key type pointer-type initial-element initial-contents fill nelems size-slot => pointer

Arguments
type
A FLI type specifying the type of the object to be allocated. If type is supplied, pointer-type must not be supplied.
pointer-type
A FLI pointer type specifying the type of the pointer object to be allocated. If pointer-type is supplied, type must not be supplied.
initial-element
The initial value of the newly allocated objects.
initial-contents
A list of values to initialize the contents of the newly allocated objects.
fill
An integer between 0 to 255.
nelems
An integer specifying how many copies of the object should be allocated. The default value is 1.
size-slot
A symbol naming a slot in the object.
Values
pointer
A pointer to the specified type or pointer-type.
Description

The function allocate-dynamic-foreign-object allocates memory for a new instance of an object of type type or an instance of a pointer object of type pointer-type within the scope of the body of the macro with-dynamic-foreign-objects.

initial-element, initial-contents, fill, nelems and size-slot initialize the allocated instance as if by allocate-foreign-object.

Once this macro has executed, the memory allocated using allocate-dynamic-foreign-object is therefore automatically freed for other uses.

The function alloca is a synonym for allocate-dynamic-foreign-object.

Examples

A full example using with-dynamic-foreign-objects and allocate-dynamic-foreign-object is given in 1.4 An example of dynamic memory allocation.

See also

allocate-foreign-object
with-dynamic-foreign-objects
1.4 An example of dynamic memory allocation
3.5 More examples of allocation and pointer allocation
5.2.4 Modifying a string in a C function


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