Sat, 22 Nov 2025 19:16:10 +0100
fix that cxTreeVisitorDispose() does not set the queue pointers to NULL
plus add coverage exclusion to tree.c
| src/tree.c | file | annotate | diff | comparison | revisions |
--- a/src/tree.c Sat Nov 22 19:03:04 2025 +0100 +++ b/src/tree.c Sat Nov 22 19:16:10 2025 +0100 @@ -566,7 +566,7 @@ ptrdiff_t loc_next ) { *cnode = cfunc(src, cdata); - if (*cnode == NULL) return 1; + if (*cnode == NULL) return 1; // LCOV_EXCL_LINE cx_tree_zero_pointers(*cnode, cx_tree_ptr_locations); void *match = NULL; @@ -627,7 +627,7 @@ // create the new node void *new_node = cfunc(elem, cdata); - if (new_node == NULL) return processed; + if (new_node == NULL) return processed; // LCOV_EXCL_LINE cx_tree_zero_pointers(new_node, cx_tree_ptr_locations); // start searching from current node @@ -731,7 +731,7 @@ void *node; if (tree->root == NULL) { node = tree->node_create(data, tree); - if (node == NULL) return 1; + if (node == NULL) return 1; // LCOV_EXCL_LINE cx_tree_zero_pointers(node, cx_tree_node_layout(tree)); tree->root = node; tree->size = 1; @@ -758,7 +758,7 @@ // use the first element from the iter to create the root node void **eptr = iter->current(iter); void *node = tree->node_create(*eptr, tree); - if (node == NULL) return 0; + if (node == NULL) return 0; // LCOV_EXCL_LINE cx_tree_zero_pointers(node, cx_tree_node_layout(tree)); tree->root = node; ins = 1; @@ -780,7 +780,7 @@ const void *data, size_t depth ) { - if (tree->root == NULL) return NULL; + if (tree->root == NULL) return NULL; // LCOV_EXCL_LINE void *found; if (0 == cx_tree_search_data( @@ -819,7 +819,7 @@ assert(search_data_func != NULL); CxTree *tree = cxMalloc(allocator, sizeof(CxTree)); - if (tree == NULL) return NULL; + if (tree == NULL) return NULL; // LCOV_EXCL_LINE tree->cl = &cx_tree_default_class; tree->allocator = allocator; @@ -857,7 +857,7 @@ assert(root != NULL); CxTree *tree = cxMalloc(allocator, sizeof(CxTree)); - if (tree == NULL) return NULL; + if (tree == NULL) return NULL; // LCOV_EXCL_LINE tree->cl = &cx_tree_default_class; // set the allocator anyway, just in case... @@ -893,7 +893,7 @@ int cxTreeAddChild(CxTree *tree, void *parent, const void *data) { void *node = tree->node_create(data, tree); - if (node == NULL) return 1; + if (node == NULL) return 1; // LCOV_EXCL_LINE cx_tree_zero_pointers(node, cx_tree_node_layout(tree)); cx_tree_link(parent, node, cx_tree_node_layout(tree)); tree->size++; @@ -1071,6 +1071,7 @@ cxFreeDefault(q); q = next; } + visitor->queue_next = visitor->queue_last = NULL; } CxTreeIterator cxTreeIterateSubtree(CxTree *tree, void *node, bool visit_on_exit) {