C Collections

cyaml · Section 3

cyaml_create_string_mp, cyaml_create_string

cyaml_create_string_mp, cyaml_create_string - allocate a YAML string node

C Collections (libccollections, -lccollections)

#include <ccollections/cyaml.h>
 
cyaml cyaml_create_string_mp(const char *val, ccol_memmgmt_procs *mp);
cyaml cyaml_create_string(const char *val);

Allocates a DOM node of type CYAML_STRING that holds its own heap copy
of val.  A NULL val gives a CYAML_NULL node, so a NULL val never makes
this function return NULL.
 
val must be well-formed UTF-8.  A string that is not is refused and
the function returns NULL, and it never rewrites such a string.
Every Unicode character is accepted, including the ones that a YAML
document may hold only as an escape (a C0 control, DEL, a C1
control, U+FFFE and U+FFFF), because cyaml_serialize(3) writes a
string that contains one in double quotes with an escape, and the
output parses back to the same text.
cyaml_create_string() passes NULL for mp.

val  Null-terminated, well-formed UTF-8 source string, or NULL for a
     null node.
mp   Custom allocator, or NULL for the default.
     The library keeps its own copy of the struct, so the caller may
     release or reuse the struct once this call returns.  The
     functions that it names must stay callable until the last node
     built with them is destroyed.  A process can use at most 64
     distinct sets of four functions, and a call that would need a
     65th fails and returns NULL.

A new cyaml node on success, or NULL when val is not well-formed
UTF-8, when the allocation fails, or when the allocator table is full
(see mp).

cyaml_str_val(3), cyaml_destroy(3)