From a6c0a1e8b3d2f3456972dad61a435684cac52cb5 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 17 Nov 2014 21:35:39 -0800 Subject: Make parse_inlines add directly to parent. Previously parse_inlines returned a list of parsed inlines. This had to be added to the parent, and fix_parents had to be called to manually add the 'parent' links to the children, and the 'last_child' link to the parent. Now parse_inlines takes the parent block as a parameter, and uses cmark_node_append_child to add the children, so that the pointers should be properly managed. This avoids the need for the fix_parents pass. --- src/blocks.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'src/blocks.c') diff --git a/src/blocks.c b/src/blocks.c index 0e68259..58162b5 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -283,19 +283,6 @@ typedef struct BlockStack { cmark_node *next_sibling; } block_stack; -static void fix_parents(cmark_node *node) { - cmark_node *cur = node->first_child; - if (cur == NULL) { - return; - } - while (cur->next != NULL) { - cur->parent = node; - cur = cur->next; - } - cur->parent = node; - node->last_child = cur; -} - // Walk through cmark_node and all children, recursively, parsing // string content into inline content where appropriate. static void process_inlines(cmark_node* cur, reference_map *refmap) @@ -308,8 +295,7 @@ static void process_inlines(cmark_node* cur, reference_map *refmap) case NODE_PARAGRAPH: case NODE_ATX_HEADER: case NODE_SETEXT_HEADER: - cur->first_child = parse_inlines(&cur->string_content, refmap); - fix_parents(cur); + parse_inlines(cur, refmap); break; default: -- cgit v1.2.3