#if USE_XYLA || TREE == SGT_TREE234 || USE_LIBAVL
-static int compare_words(const struct word *a, const struct word *b)
+static int compare_words(const char *a, size_t alen,
+ const char *b, size_t blen)
{
- size_t alen = a->n, blen = b->n;
int ord;
- ord = memcmp(a->p, b->p, alen <= blen ? alen : blen);
+ ord = memcmp(a, b, alen <= blen ? alen : blen);
if (!ord) ord = alen < blen ? -1 : alen > blen ? +1 : 0;
return (ord);
}
const struct word *k = arg;
const struct node *node = (struct node *)nn;
- return (compare_words(k, &node->w));
+ return (compare_words(k->p, k->n, WORDPTR(node), WORDLEN(node)));
}
# define DECLS \
#elif TREE == SGT_TREE234
static int node_cmp(void *a, void *b)
- { const struct word *wa = a, *wb = b; return (compare_words(wa, wb)); }
+{
+ const struct node *na = a, *nb = b;
+
+ return (compare_words(WORDPTR(na), WORDLEN(na),
+ WORDPTR(nb), WORDLEN(nb)));
+}
static int word_cmp(void *k, void *n)
{
const struct word *word = k;
const struct node *node = n;
- return (compare_words(word, &node->w));
+ return (compare_words(word->p, word->n, WORDPTR(node), WORDLEN(node)));
}
# define DECLS \
#elif USE_LIBAVL
static int node_cmp(const void *a, const void *b, void *arg)
- { const struct word *wa = a, *wb = b; return (compare_words(wa, wb)); }
+{
+ const struct word *wa = a, *wb = b;
+
+ return (compare_words(wa->p, wa->n, wb->p, wb->n));
+}
static void free_node(void *n, void *arg) { free(n); }