From: Mark Wooding Date: Fri, 28 Mar 2025 18:12:28 +0000 (+0000) Subject: @@@ more tweak X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/xyla/commitdiff_plain/356f2050fd5b988cbc04b429b714b4cde636620f?ds=inline @@@ more tweak --- diff --git a/avl-splitjoin.c b/avl-splitjoin.c index 4a2377f..a66c4d0 100644 --- a/avl-splitjoin.c +++ b/avl-splitjoin.c @@ -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 \ diff --git a/bt-check.c b/bt-check.c index 2f6637c..d1898b3 100644 --- a/bt-check.c +++ b/bt-check.c @@ -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 e5fec4b..645cb03 100644 --- 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 { diff --git a/rb-addrm.c b/rb-addrm.c index f2e68a4..8928148 100644 --- a/rb-addrm.c +++ b/rb-addrm.c @@ -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 { \ diff --git a/t/treetest.c b/t/treetest.c index e6cf849..7e323fd 100644 --- a/t/treetest.c +++ b/t/treetest.c @@ -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");