cyaml · Section 3
cyaml_destroy
NAME
cyaml_destroy - recursively free a DOM tree and null the handle
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/cyaml.h> cyaml_destroy(node);
DESCRIPTION
When node is not NULL, the macro frees the whole DOM subtree under node, each node with the allocator that it stores, and then sets node to NULL. Everything below node goes: The children of each list, the values of each dictionary and the string copies. Destroying the same handle a second time is safe, because the variable is NULL after the first destroy. That is also why node must be an assignable lvalue. You cannot pass a plain NULL literal or any other expression that is not an lvalue.
PARAMETERS
node The cyaml variable to destroy. The macro sets the variable
itself to NULL.
NOTES
The macro evaluates node exactly once, so an expression with a side effect, such as handles[i++], destroys and clears one element. node must be a modifiable lvalue, such as a variable or an array element.
EXAMPLES
cyaml root = cyaml_parse("a: 1\n", NULL); /* ... use root ... */ cyaml_destroy(root); /* root is now NULL */