C Collections

cvector · Section 3

cvector_create_full

cvector_create_full - create a vector with custom memory management

C Collections (libccollections, -lccollections)

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

Creates a new vector for elements of the given size, with every memory
management option set by the caller. The vector manages its capacity by
itself.

elem_size     Size of each element in bytes (must be > 0, and must not
              exceed SIZE_MAX / 4)
mmgmt_procs   Custom memory management procedures, or NULL for the
              default malloc/free
err           Optional pointer that receives an error string on failure

A pointer to the new vector on success.
NULL on failure, which includes an elem_size of 0 and an elem_size large
enough that allocating the first 4-element backing buffer overflows.

The first capacity is 4 elements, which is also the minimum. The capacity
doubles when the vector is full and halves when it is less than 1/4 full.

cvector_create(3), cvector_destroy(3)