summaryrefslogtreecommitdiff
path: root/src/cmark.c
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2014-11-17 21:41:10 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2014-11-17 21:43:47 -0800
commitc38944d4565b6266b3ab1fd6fd576710fdec420b (patch)
treed1f4b71d29f028fa16808009c8083754a840ec3b /src/cmark.c
parent3554759dbe4a0cb937556226d621bb71efd188e7 (diff)
Move cmark_free_nodes to node.c
Diffstat (limited to 'src/cmark.c')
-rw-r--r--src/cmark.c51
1 files changed, 0 insertions, 51 deletions
diff --git a/src/cmark.c b/src/cmark.c
index d114d1e..b20b84b 100644
--- a/src/cmark.c
+++ b/src/cmark.c
@@ -20,54 +20,3 @@ unsigned char *cmark_markdown_to_html(unsigned char *text, int len)
return result;
}
-// Utility function used by cmark_free_nodes
-static void splice_into_list(cmark_node* e, cmark_node* children) {
- cmark_node * tmp;
- if (children) {
- tmp = children;
- // Find last child
- while (tmp->next) {
- tmp = tmp->next;
- }
- // Splice children into list
- tmp->next = e->next;
- e->next = children;
- }
- return ;
-}
-
-// Free a cmark_node list and any children.
-void cmark_free_nodes(cmark_node *e)
-{
- cmark_node *next;
- while (e != NULL) {
- strbuf_free(&e->string_content);
- switch (e->type){
- case NODE_FENCED_CODE:
- strbuf_free(&e->as.code.info);
- break;
- case NODE_STRING:
- case NODE_INLINE_HTML:
- case NODE_INLINE_CODE:
- cmark_chunk_free(&e->as.literal);
- break;
- case NODE_LINK:
- case NODE_IMAGE:
- free(e->as.link.url);
- free(e->as.link.title);
- splice_into_list(e, e->as.link.label);
- break;
- default:
- break;
- }
- if (e->last_child) {
- // Splice children into list
- e->last_child->next = e->next;
- e->next = e->first_child;
- }
- next = e->next;
- free(e);
- e = next;
- }
-}
-