+/* Auxiliary functions for hashed table of struct name's. */
+
+static size_t
+name_hash (void const *entry, size_t n_buckets)
+{
+ struct name const *name = entry;
+ return hash_string (name->caname, n_buckets);
+}
+
+/* Compare two directories for equality of their names. */
+static bool
+name_compare (void const *entry1, void const *entry2)
+{
+ struct name const *name1 = entry1;
+ struct name const *name2 = entry2;
+ return strcmp (name1->caname, name2->caname) == 0;
+}
+
+\f
+/* Rebase 'name' member of CHILD and all its siblings to
+ the new PARENT. */
+static void
+rebase_child_list (struct name *child, struct name *parent)
+{
+ size_t old_prefix_len = child->parent->length;
+ size_t new_prefix_len = parent->length;
+ char *new_prefix = parent->name;
+
+ for (; child; child = child->sibling)
+ {
+ size_t size = child->length - old_prefix_len + new_prefix_len;
+ char *newp = xmalloc (size + 1);
+ strcpy (newp, new_prefix);
+ strcat (newp, child->name + old_prefix_len);
+ free (child->name);
+ child->name = newp;
+ child->length = size;
+
+ rebase_directory (child->directory,
+ child->parent->name, old_prefix_len,
+ new_prefix, new_prefix_len);
+ }
+}
+