src/tree.c

changeset 1318
12fa1d37fe48
parent 1314
25108c15e2d4
child 1319
aa1f580f8f59
--- a/src/tree.c	Thu May 15 15:43:30 2025 +0200
+++ b/src/tree.c	Thu May 15 16:02:54 2025 +0200
@@ -326,7 +326,7 @@
                     // invalidate the iterator and free the node stack
                     iter->node = iter->node_next = NULL;
                     iter->stack_capacity = iter->depth = 0;
-                    free(iter->stack);
+                    cxFree(cxDefaultAllocator, iter->stack);
                     iter->stack = NULL;
                 } else {
                     // the parent node can be obtained from the top of stack
@@ -386,7 +386,7 @@
     iter.node = root;
     if (root != NULL) {
         iter.stack_capacity = 16;
-        iter.stack = malloc(sizeof(void *) * 16);
+        iter.stack = cxMalloc(cxDefaultAllocator, sizeof(void *) * 16);
         iter.stack[0] = root;
         iter.counter = 1;
         iter.depth = 1;
@@ -416,7 +416,7 @@
     node = tree_next(node);
     while (node != NULL) {
         struct cx_tree_visitor_queue_s *q;
-        q = malloc(sizeof(struct cx_tree_visitor_queue_s));
+        q = cxMalloc(cxDefaultAllocator, sizeof(struct cx_tree_visitor_queue_s));
         q->depth = iter->queue_last->depth;
         q->node = node;
         iter->queue_last->next = q;
@@ -445,7 +445,7 @@
     }
     if (children != NULL) {
         struct cx_tree_visitor_queue_s *q;
-        q = malloc(sizeof(struct cx_tree_visitor_queue_s));
+        q = cxMalloc(cxDefaultAllocator, sizeof(struct cx_tree_visitor_queue_s));
         q->depth = iter->depth + 1;
         q->node = children;
         if (iter->queue_last == NULL) {
@@ -474,7 +474,7 @@
             assert(iter->queue_last == q);
             iter->queue_last = NULL;
         }
-        free(q);
+        cxFree(cxDefaultAllocator, q);
     }
 
     // increment the node counter

mercurial