cvector · Section 3
cvector_create_full
NAME
cvector_create_full - create a vector with custom memory management
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/cvector.h>
cvec cvector_create_full(size_t elem_size,
ccol_memmgmt_procs *mmgmt_procs,
char **err);
DESCRIPTION
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.
PARAMETERS
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
RETURN VALUE
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.
NOTES
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.