Initialise both links for new node. Caught with valgrind.
authorNot Zed <notzed@gmail.com>
Tue, 23 Jul 2024 09:23:01 +0000 (18:53 +0930)
committerNot Zed <notzed@gmail.com>
Tue, 23 Jul 2024 09:23:01 +0000 (18:53 +0930)
ez-tree.c

index 6fcfb08..04a3529 100644 (file)
--- a/ez-tree.c
+++ b/ez-tree.c
@@ -285,8 +285,9 @@ void *ez_tree_put(ez_tree *tree, void *node) {
        struct ez_tree_scan_info *sp = stack, *se = sp + EZ_TREE_MAX_DEPTH - 1;
        ez_cmp_fn node_cmp = tree->node_cmp;
 
+       // Initialise incoming node
        k->link[0] = BALANCE0; // balance=0
-       node_set_link(k, 1, 0);
+       k->link[1] = BALANCE0;
 
        if (!tree->root.link[1]) {
                tree->root.link[1] = (intptr_t)k;