src/cx/tree.h

changeset 902
5ed7f634f046
parent 901
109567325fe7
child 903
a018f5916d3b
--- a/src/cx/tree.h	Wed Oct 02 19:11:40 2024 +0200
+++ b/src/cx/tree.h	Thu Oct 03 15:38:05 2024 +0200
@@ -701,14 +701,14 @@
     /**
      * Allocator to allocate new nodes.
      */
-    CxAllocator *allocator;
+    const CxAllocator *allocator;
 
     /**
      * A pointer to the root node.
      *
      * Will be \c NULL when \c size is 0.
      */
-    struct cx_tree_node_base_s *root;
+    void *root;
 
     /**
      * A function to create new nodes.
@@ -872,7 +872,7 @@
  * The specified \p allocator will be used for creating the tree struct
  * and SHALL be used by \p create_func to allocate memory for the nodes.
  *
- * \note This function will also register a simple destructor which
+ * \note This function will also register an advanced destructor which
  * will free the nodes with the allocator's free() method.
  *
  * @param allocator the allocator that shall be used
@@ -907,8 +907,8 @@
  * member (or at least respect the default offsets specified in the tree
  * struct) and they MUST be allocated with the default stdlib allocator.
  *
- * \note This function will also register a simple destructor which
- * will free the nodes with the default stdlib allocator.
+ * \note This function will also register an advanced destructor which
+ * will free the nodes with the #cxDefaultAllocator.
  *
  * @param create_func a function that creates new nodes
  * @param search_func a function that compares two nodes
@@ -1081,6 +1081,16 @@
 }
 
 /**
+ * Determines the size of the specified subtree.
+ *
+ * @param tree the tree
+ * @param subtree_root the root node of the subtree
+ * @return the number of nodes in the specified subtree
+ */
+__attribute__((__nonnull__))
+size_t cxTreeSubtreeSize(CxTree *tree, void *subtree_root);
+
+/**
  * Creates a depth-first iterator for the specified tree.
  *
  * @param tree the tree to iterate

mercurial