MCPcopy Create free account
hub / github.com/commonmark/cmark / cmark_node_prepend_child

Function cmark_node_prepend_child

src/node.c:777–799  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

775}
776
777int cmark_node_prepend_child(cmark_node *node, cmark_node *child) {
778 if (!S_can_contain(node, child)) {
779 return 0;
780 }
781
782 S_node_unlink(child);
783
784 cmark_node *old_first_child = node->first_child;
785
786 child->next = old_first_child;
787 child->prev = NULL;
788 child->parent = node;
789 node->first_child = child;
790
791 if (old_first_child) {
792 old_first_child->prev = child;
793 } else {
794 // Also set last_child if node previously had no children.
795 node->last_child = child;
796 }
797
798 return 1;
799}
800
801int cmark_node_append_child(cmark_node *node, cmark_node *child) {
802 if (!S_can_contain(node, child)) {

Callers 1

create_treeFunction · 0.85

Calls 2

S_can_containFunction · 0.85
S_node_unlinkFunction · 0.85

Tested by

no test coverage detected