cvector · Section 3
cvector_create
NAME
cvector_create - create a vector with default memory management
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/cvector.h> cvec cvector_create(size_t elem_size, char **err);
DESCRIPTION
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.
PARAMETERS
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)
RETURN VALUE
A pointer to the new vector on success. NULL on failure, with the error string set in *err if err was given.
NOTES
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.
SEE ALSO
cvector_create_full(3), cvector_destroy(3), cvec_construct(3)