chiark / gitweb /
@@@ more tweak
authorMark Wooding <mdw@distorted.org.uk>
Fri, 28 Mar 2025 18:12:28 +0000 (18:12 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 28 Mar 2025 22:57:43 +0000 (22:57 +0000)
avl-splitjoin.c
bt-check.c
bt.h
rb-addrm.c
t/treetest.c

index 4a2377f93e5aba3dd0633cbba6e36d607c1ab15c..a66c4d04e33a3d86fdded872fb55df455a397126 100644 (file)
@@ -58,7 +58,7 @@ int xyla_avl_join(struct xyla_bt_nodecls *cls,
   struct xyla_bt_node **plink, **nlink, *root;
   xyla_bt_updfn *updfn = cls ? cls->ops->upd : 0;
   struct xyla_avl_path path;
-  unsigned bal, trail, f;
+  unsigned f, bal, trail;
   int ht, rc;
 
   /* The trail.  This is a similar idea to `xyla_avl_insert', except that we
@@ -141,8 +141,8 @@ int xyla_avl_join(struct xyla_bt_nodecls *cls,
       if (ht < rht) {                                                  \
        /* The subtree we're replacing is shorter than the right tree.  \
         * We can only get into this situation if its parent n was      \
-        * taller, so the n must be left-biased.  We have some balance  \
-        * annotations to adjust; and the parent's height has           \
+        * taller, so the node n must be left-biased.  We have some     \
+        * balance annotations to adjust; and the parent's height has   \
         * increased, so we'll have to ascend the tree.                 \
         *                                                              \
         *                                          n                   \
@@ -161,7 +161,7 @@ int xyla_avl_join(struct xyla_bt_nodecls *cls,
        n->avl.f = (n->avl.f&~XYLA_AVLF_BALMASK) | XYLA_AVLBAL_##RBIAS; \
        if (updfn) { updfn(cls, &m->bt); updfn(cls, &n->bt); }          \
       } else if (BAL(NODE) != XYLA_AVLBAL_##RBIAS) {                   \
-       /* The focus node not right-biased, and the subtree we're       \
+       /* The focus node was not right-biased, and the subtree we're   \
         * replacing is the same height as the right tree.  It's now    \
         * either evenly balanced, in which case we're done, or biased  \
         * to the right, in which case we must ascend.                  \
@@ -197,7 +197,7 @@ int xyla_avl_join(struct xyla_bt_nodecls *cls,
         * There must, in fact, be a parent node.  (If the right tree   \
         * has height h, then the focus node has height h + 1; if       \
         * that's the root, then we'd have done this the easy way.)  If \
-        * the parent was previously left-bias then it's now even and   \
+        * the parent was previously left-biased then it's now even and \
         * we're done; otherwise, we must ascend the tree.              \
         *                                                              \
         *                                           p                  \
index 2f6637c8306ab091f0d1f75def7fd9d3d9a763b9..d1898b3dc47d530927938d597f4a30b16725fbec 100644 (file)
@@ -473,7 +473,7 @@ int xyla_bt_chkorder(unsigned op, const struct xyla_bt_check *chk)
    */
 
   struct xyla_bt_nodecls *cls = chk->cls;
-  const struct xyla_bt_ordops *ops = (const struct xyla_bt_ordops *)cls->ops;
+  const struct xyla_bt_ordops *ops = ORDER_OPS(cls->ops);
   struct xyla_bt_ordinfo
     *parent_info = chk->parent_info,
     *node_info = chk->node_info;
diff --git a/bt.h b/bt.h
index e5fec4b54f22b4cbdb0ef854e02b8524cfdcc078..645cb037b9506b082c145db34816ba82298b68e6 100644 (file)
--- a/bt.h
+++ b/bt.h
@@ -873,8 +873,7 @@ typedef int xyla_bt_chkfn(unsigned /*op*/,
    */
 
 typedef void xyla_bt_idfn(struct xyla_bt_nodecls */*cls*/,
-                         const struct xyla_bt_node */*node*/,
-                         FILE */*fp*/);
+                         const struct xyla_bt_node */*node*/, FILE */*fp*/);
   /* Print a description of the NODE to the output stream FP. */
 
 struct xyla_bt_chkopslots {
index f2e68a40dd46795fc1ca89c9b9b35fb9d35e3205..89281481c0db80b037023141fe2bbf4dae877cd7 100644 (file)
@@ -147,7 +147,8 @@ int xyla_rb_insert(struct xyla_bt_nodecls *cls,
        p->bt.left = n->bt.right; n->bt.right = &p->bt;                 \
        n->rb.f &= ~XYLA_RBF_RED; p->rb.f |= XYLA_RBF_RED;              \
        if (updfn) {                                                    \
-         updfn(cls, &c->bt); updfn(cls, &p->bt); updfn(cls, &n->bt);   \
+         updfn(cls, &c->bt); updfn(cls, &p->bt);                       \
+         updfn(cls, &n->bt);                                           \
        }                                                               \
        *plink = &n->bt;                                                \
       } else {                                                         \
index e6cf84934b903f6fdf4115520210214f9e6b1d8a..7e323fd93f17f4e54a89f02f48591968c6e24135 100644 (file)
@@ -567,9 +567,10 @@ static int my_check(unsigned op, const struct xyla_bt_check *chk)
 
   /* Check that the ordering is respected. */
   subrc = xyla_bt_chkorder(op, chk);
-  if (subrc < rc) rc = subrc;
+    if (subrc) { rc = subrc; if (subrc != XYLA_RC_BAD) goto end; }
 
   /* Done. */
+end:
   return (rc);
 }
 
@@ -1435,7 +1436,7 @@ done:
    * from all of the trees we've been tracking.
    */
   if (nodes) {
-    puts("leaked nodes...");
+    fputs("leaked nodes...", out);
     for (node = nodes; node; node = node->next)
       fprintf(out, "\t#0x%08lx %lu\n", node->seq, node->k);
     bail(BCAT_BUG, "leaked nodes");