C Collections

cvector · Section 3

cvector_create

cvector_create - create a vector with default memory management

C Collections (libccollections, -lccollections)

#include <ccollections/cvector.h>
 
cvec cvector_create(size_t elem_size, char **err);

Creates a new vector for elements of the given size. It starts with the
minimum capacity of 4 elements and resizes itself as needed, using the
standard malloc and free for its memory.
 
It is a static inline wrapper around cvector_create_full() that passes
NULL for the memory management procedures.

elem_size  Size of each element in bytes (must be > 0, and must not
           exceed SIZE_MAX / 4)
err        Optional pointer that receives an error string on failure
           (pass NULL to ignore it)

A pointer to the new vector on success.
NULL on failure, with the error string set in *err if err was given.

The initial capacity is 4 elements. The capacity doubles when the vector
is full and halves when it is less than 1/4 full.
 
Destroy the vector with cvector_destroy() when you are done with it.

cvector_create_full(3), cvector_destroy(3), cvec_construct(3)