rename cxTreeRemove() to cxTreeRemoveSubtree()

Sat, 05 Oct 2024 14:42:14 +0200

author
Mike Becker <universe@uap-core.de>
date
Sat, 05 Oct 2024 14:42:14 +0200
changeset 908
f49f8a7060aa
parent 907
1f72fb9af87e
child 909
f4e00bb3f3b2

rename cxTreeRemove() to cxTreeRemoveSubtree()

relates to #437

src/cx/tree.h file | annotate | diff | comparison | revisions
src/tree.c file | annotate | diff | comparison | revisions
tests/test_tree.c file | annotate | diff | comparison | revisions
--- a/src/cx/tree.h	Sat Oct 05 14:22:42 2024 +0200
+++ b/src/cx/tree.h	Sat Oct 05 14:42:14 2024 +0200
@@ -1207,7 +1207,7 @@
  * @param node the node to remove
  */
 __attribute__((__nonnull__))
-void cxTreeRemove(CxTree *tree, void *node);
+void cxTreeRemoveSubtree(CxTree *tree, void *node);
 
 #ifdef __cplusplus
 } // extern "C"
--- a/src/tree.c	Sat Oct 05 14:22:42 2024 +0200
+++ b/src/tree.c	Sat Oct 05 14:42:14 2024 +0200
@@ -900,7 +900,15 @@
     return visitor.depth;
 }
 
-void cxTreeRemove(CxTree *tree, void *node) {
+int cxTreeRemove(CxTree *tree, void *node) {
+    if (node == tree->root) return 1;
+
+
+
+    return 0;
+}
+
+void cxTreeRemoveSubtree(CxTree *tree, void *node) {
     if (node == tree->root) {
         tree->root = NULL;
         tree->size = 0;
--- a/tests/test_tree.c	Sat Oct 05 14:22:42 2024 +0200
+++ b/tests/test_tree.c	Sat Oct 05 14:42:14 2024 +0200
@@ -1768,7 +1768,7 @@
         cxTreeAddChildNode(tree, cxTreeFind(tree, "/usr/"), share);
         CX_TEST_ASSERT(tree->size == 8);
 
-        cxTreeRemove(tree, foo);
+        cxTreeRemoveSubtree(tree, foo);
         CX_TEST_ASSERT(NULL == cxTreeFind(tree, "/home/foo/"));
         CX_TEST_ASSERT(NULL == cxTreeFind(tree, "/home/foo/bar/"));
         CX_TEST_ASSERT(NULL == cxTreeFind(tree, "/home/bar/"));
@@ -1811,7 +1811,7 @@
         };
         cxTreeInsertArray(tree, paths, sizeof(const char*), 6);
         void *root = tree->root;
-        cxTreeRemove(tree, root);
+        cxTreeRemoveSubtree(tree, root);
         CX_TEST_ASSERT(tree->size == 0);
         CX_TEST_ASSERT(tree->root == NULL);
         CX_TEST_ASSERT(cxTreeDepth(tree) == 0);

mercurial