C Collections

cstring · Section 3

cstring_reserve

cstring_reserve - pre-allocate capacity for at least min_capacity bytes

C Collections (libccollections, -lccollections)

#include <ccollections/cstring.h>
 
bool cstring_reserve(cstr s, size_t min_capacity);

This function makes sure that the internal buffer has room for at least
min_capacity bytes, the null terminator included. The requested size is
rounded up to the nearest power of two (at least 16), and when the
capacity is already large enough the function does nothing.

s              String to change
min_capacity   Minimum number of bytes to reserve (including null terminator)

true on success, and also when the capacity was already large enough
false when the reallocation fails or the requested size is too large

Asserts if s is NULL

cstring_create_full(3)