C Collections

cstring · Section 3

cstring_copy

cstring_copy - create an independent copy of a string

C Collections (libccollections, -lccollections)

#include <ccollections/cstring.h>
 
cstr cstring_copy(cstr s, char **err);

This function allocates a new cstring with the same content as s. After
the call the two strings are fully independent of each other.

s     String to copy
err   Optional pointer to receive an error string on failure

A new cstring on success
NULL when an allocation fails; the details then go to *err when err is
not NULL

You must destroy the returned cstring once you are done with it
Asserts if s is NULL

cstring_substring(3), cstring_create(3)