Next: , Previous: Darray structure, Up: Dynamic arrays


12.2 Allocating and freeing darrays

— Function: Darray * da_create (size_t obj_size)
— Function: Darray * da_create_len (size_t obj_size, ssize_t len)

Uses ‘mem_alloc’ to allocate enough memory to store a Darray and initialises that memory as a darray which can store objects obj_size bytes long. The darray is initialised to contain zero elements (for ‘da_create’) or len elements (for ‘da_create_len’). Returns a reference to the allocated darray, or a null pointer if there was insufficient memory.

— Function: void da_destroy (Darray *da)

Finalises the internal data structures of da, and frees the memory referenced by da. da must have been allocated by ‘da_create’ or ‘da_create_len’.