From: Mark Wooding Date: Sun, 30 Mar 2025 20:19:57 +0000 (+0100) Subject: chain.c: Separate representations of keys and nodes in `sgt234'. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/wordchain/commitdiff_plain/6a413efa07e7b571c69cd1b49b2f60d777258e08?ds=sidebyside chain.c: Separate representations of keys and nodes in `sgt234'. --- diff --git a/chain.c b/chain.c index 36bd852..77e9e63 100644 --- a/chain.c +++ b/chain.c @@ -439,6 +439,14 @@ static bool my_Tnextl(Tbl *t, const char **k_inout, size_t *sz_inout, static int node_cmp(void *a, void *b) { const struct word *wa = a, *wb = b; return (compare_words(wa, wb)); } +static int word_cmp(void *k, void *n) +{ + const struct word *word = k; + const struct node *node = n; + + return (compare_words(word, &node->w)); +} + # define DECLS \ tree234 *root; \ int i @@ -456,7 +464,7 @@ static int node_cmp(void *a, void *b) # define FOCUS do ; while (0) -# define LOOKUP find234(root, &word, 0) +# define LOOKUP find234(root, &word, word_cmp) # define FREE do { \ while (node = delpos234(root, 0), node) free(node); \