MCPcopy Index your code
hub / github.com/commonmark/cmark / cmark_node_insert_after

Function cmark_node_insert_after

src/node.c:736–767  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

734}
735
736int cmark_node_insert_after(cmark_node *node, cmark_node *sibling) {
737 if (node == NULL || sibling == NULL) {
738 return 0;
739 }
740
741 if (!node->parent || !S_can_contain(node->parent, sibling)) {
742 return 0;
743 }
744
745 S_node_unlink(sibling);
746
747 cmark_node *old_next = node->next;
748
749 // Insert 'sibling' between 'node' and 'old_next'.
750 if (old_next) {
751 old_next->prev = sibling;
752 }
753 sibling->next = old_next;
754 sibling->prev = node;
755 node->next = sibling;
756
757 // Set new parent.
758 cmark_node *parent = node->parent;
759 sibling->parent = parent;
760
761 // Adjust last_child of parent if inserted as last child.
762 if (parent && !old_next) {
763 parent->last_child = sibling;
764 }
765
766 return 1;
767}
768
769int cmark_node_replace(cmark_node *oldnode, cmark_node *newnode) {
770 if (!cmark_node_insert_before(oldnode, newnode)) {

Callers 1

create_treeFunction · 0.85

Calls 2

S_can_containFunction · 0.85
S_node_unlinkFunction · 0.85

Tested by

no test coverage detected