Package: cffi
Function foreign-alloc
Lambda Listforeign-alloc (type &key initial-element initial-contents count null-terminated-p) ArgumentsDetails The foreign-alloc function allocates enough memory to hold count objects of type type and returns a pointer. This memory must be explicitly freed using foreign-free once it is no longer needed. If initial-element is supplied, it is used to initialize the count objects the newly allocated memory holds. If an initial-contents sequence is supplied, it must have a length less than or equal to count and each of its elements will be used to initialize the contents of the newly allocated memory. If count is omitted and initial-contents is specified, it will default to (length initial-contents). initial-element and initial-contents are mutually exclusive. When null-terminated-p is true, (1+ (max count (length initial-contents))) elements are allocated and the last one is set to NULL. Note that in this case type must be a pointer type (i.e. a type that canonicalizes to :pointer), otherwise an error is signaled. ExamplesCFFI> (foreign-alloc :char) => #<A Mac Pointer #x102D80> ; A pointer to 1 byte of memory. | See also |