diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2014-11-13 09:29:51 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2014-11-13 09:29:51 -0800 |
commit | 91642ceee7a2a2c05d9561c0e22b2f15111ac603 (patch) | |
tree | 8c9832ff1ef76900ade55cc459c21a19a8c0e832 /src/ast.c | |
parent | 4467216e9fbf9eaa94ac4178b2400dc481c57ba0 (diff) |
Added ast.[c,h] for AST definitions and AST-manipulating functions.
Diffstat (limited to 'src/ast.c')
-rw-r--r-- | src/ast.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/ast.c b/src/ast.c new file mode 100644 index 0000000..1622568 --- /dev/null +++ b/src/ast.c @@ -0,0 +1,30 @@ +#include <stdbool.h> +#include <stdio.h> +#include "buffer.h" +#include "ast.h" +#include "inlines.h" +#include "references.h" + +// Free a node_block list and any children. +void cmark_free_nodes(node_block *e) +{ + node_block * next; + while (e != NULL) { + free_inlines(e->inline_content); + strbuf_free(&e->string_content); + if (e->tag == BLOCK_FENCED_CODE) { + strbuf_free(&e->as.code.info); + } else if (e->tag == BLOCK_DOCUMENT) { + reference_map_free(e->as.document.refmap); + } + if (e->last_child) { + // Splice children into list + e->last_child->next = e->next; + e->next = e->children; + } + next = e->next; + free(e); + e = next; + } +} + |