C Collections

cstring · Section 3

cstr_init

cstr_init - initialise a declared cstr with the default allocators

C Collections (libccollections, -lccollections)

#include <ccollections/cstring.h>
 
cstr_init(s, initial);

This macro initialises the cstr variable s with the content you give,
through cstring_create(). You must declare s first. If the creation
fails, the macro calls ccol__fatal_err().

s        cstr lvalue to initialise (you must declare it first); the macro
         assigns it once, after the string is created
initial  Initial content (C string or NULL for empty string)

A failed allocation ends in ccol__fatal_err(). If you want to handle an
error yourself, call cstring_create() directly

cstr_declare(s);
cstr_init(s, "hello");
cstr_destroy(s);

cstr_init_mp(3), cstr_construct(3), cstring_create(3)