chiark / gitweb /
chain.c: Separate representations of keys and nodes in `sgt234'.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 30 Mar 2025 20:19:57 +0000 (21:19 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 30 Mar 2025 21:48:44 +0000 (22:48 +0100)
chain.c

diff --git a/chain.c b/chain.c
index 36bd8525e98f4155c920c762dc38723d012839bd..77e9e638f5d17ea48e2efc40f483eac28b47f0d6 100644 (file)
--- 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);             \