cmark

My personal build of CMark ✏️

Commit
c38944d4565b6266b3ab1fd6fd576710fdec420b
Parent
3554759dbe4a0cb937556226d621bb71efd188e7
Author
Nick Wellnhofer <wellnhofer@aevum.de>
Date

Move cmark_free_nodes to node.c

Diffstat

2 files changed, 51 insertions, 51 deletions

Status File Name N° Changes Insertions Deletions
Modified src/cmark.c 51 0 51
Modified src/node.c 51 51 0
diff --git 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;
-	}
-}
-
diff --git a/src/node.c b/src/node.c
@@ -233,4 +233,55 @@ cmark_node_append_child(cmark_node *node, cmark_node *child)
 	return 1;
 }
 
+// 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;
+	}
+}
+