-typedef void (*traverse_callback_t)(int n, unsigned long mask, struct name_entry *entry, const char *base);
-
-static void traverse_trees(int n, struct tree_desc *t, const char *base, traverse_callback_t callback)
-{
- struct name_entry *entry = xmalloc(n*sizeof(*entry));
-
- for (;;) {
- struct name_entry entry[3];
- unsigned long mask = 0;
- int i, last;
-
- last = -1;
- for (i = 0; i < n; i++) {
- if (!t[i].size)
- continue;
- entry_extract(t+i, entry+i);
- if (last >= 0) {
- int cmp = entry_compare(entry+i, entry+last);
-
- /*
- * Is the new name bigger than the old one?
- * Ignore it
- */
- if (cmp > 0)
- continue;
- /*
- * Is the new name smaller than the old one?
- * Ignore all old ones
- */
- if (cmp < 0)
- mask = 0;
- }
- mask |= 1ul << i;
- last = i;
- }
- if (!mask)
- break;
-
- /*
- * Update the tree entries we've walked, and clear
- * all the unused name-entries.
- */
- for (i = 0; i < n; i++) {
- if (mask & (1ul << i)) {
- update_tree_entry(t+i);
- continue;
- }
- entry_clear(entry + i);
- }
- callback(n, mask, entry, base);
- }
- free(entry);
-}
-