src/tree.c

changeset 907
1f72fb9af87e
parent 905
39aa4f106a71
child 908
f49f8a7060aa
--- a/src/tree.c	Sat Oct 05 14:16:01 2024 +0200
+++ b/src/tree.c	Sat Oct 05 14:22:42 2024 +0200
@@ -901,6 +901,11 @@
 }
 
 void cxTreeRemove(CxTree *tree, void *node) {
+    if (node == tree->root) {
+        tree->root = NULL;
+        tree->size = 0;
+        return;
+    }
     size_t subtree_size = cxTreeSubtreeSize(tree, node);
     cx_tree_unlink(node, cx_tree_node_layout(tree));
     tree->size -= subtree_size;

mercurial