- struct idev *idev, *idev_next;
- struct hlist *hl;
-
- alloc_pool_t hlink_pool;
- alloc_pool_t idev_pool = the_file_list->hlink_pool;
-
- hlink_pool = pool_create(128 * 1024, sizeof (struct hlist), out_of_memory, POOL_INTERN);
-
- for (from = to = 0; from < hlink_count; from++) {
- start = from;
- for (file = FPTR(hlink_list[from]), idev = F_IDEV(file);
- from < hlink_count-1;
- file = file_next, idev = idev_next)
- {
- file_next = FPTR(hlink_list[from+1]);
- idev_next = F_IDEV(file_next);
- if (!LINKED(idev, idev_next))
+ struct ht_int32_node *node = NULL;
+ int32 gnum, gnum_next;
+
+ qsort(ndx_list, ndx_count, sizeof ndx_list[0],
+ (int (*)()) hlink_compare_gnum);
+
+ for (from = 0; from < ndx_count; from++) {
+ file = hlink_flist->sorted[ndx_list[from]];
+ gnum = F_HL_GNUM(file);
+ if (inc_recurse) {
+ node = hashtable_find(prior_hlinks, gnum, 1);
+ if (!node->data) {
+ node->data = new_array0(char, 5);
+ assert(gnum >= hlink_flist->ndx_start);
+ file->flags |= FLAG_HLINK_FIRST;
+ prev = -1;
+ } else if (CVAL(node->data, 0) == 0) {
+ struct file_list *flist;
+ struct file_struct *fp;
+ prev = IVAL(node->data, 1);
+ flist = flist_for_ndx(prev);
+ assert(flist != NULL);
+ fp = flist->files[prev - flist->ndx_start];
+ fp->flags &= ~FLAG_HLINK_LAST;
+ } else
+ prev = -1;
+ } else {
+ file->flags |= FLAG_HLINK_FIRST;
+ prev = -1;
+ }
+ for ( ; from < ndx_count-1; file = file_next, gnum = gnum_next, from++) { /*SHARED ITERATOR*/
+ file_next = hlink_flist->sorted[ndx_list[from+1]];
+ gnum_next = F_HL_GNUM(file_next);
+ if (gnum != gnum_next)