+struct heap_cread_info {
+ char prev_name[INP_NAME_MAX];
+ char cur_name[INP_NAME_MAX];
+ char *key;
+ struct heap_info *hi;
+ int mode;
+ int more;
+};
+
+int heap_cread_item (void *vp, char **dst, int *insertMode)
+{
+ struct heap_cread_info *p = vp;
+ struct heap_info *hi = p->hi;
+
+ if (p->mode == 1)
+ {
+ *insertMode = p->key[0];
+ memcpy (*dst, p->key+1, sizeof(struct it_key));
+ (*dst) += sizeof(struct it_key);
+ p->mode = 2;
+ return 1;
+ }
+ strcpy (p->prev_name, p->cur_name);
+ if (!(p->more = heap_read_one (hi, p->cur_name, p->key)))
+ return 0;
+ if (*p->cur_name && strcmp (p->cur_name, p->prev_name))
+ {
+ p->mode = 1;
+ return 0;
+ }
+ *insertMode = p->key[0];
+ memcpy (*dst, p->key+1, sizeof(struct it_key));
+ (*dst) += sizeof(struct it_key);
+ return 1;
+}
+
+int heap_inpc (struct heap_info *hi)
+{
+ struct heap_cread_info hci;
+ ISAMC_I isamc_i = xmalloc (sizeof(*isamc_i));
+
+ hci.key = xmalloc (KEY_SIZE);
+ hci.mode = 1;
+ hci.hi = hi;
+ hci.more = heap_read_one (hi, hci.cur_name, hci.key);
+
+ isamc_i->clientData = &hci;
+ isamc_i->read_item = heap_cread_item;
+
+ while (hci.more)
+ {
+ char this_name[INP_NAME_MAX];
+ ISAMC_P isamc_p, isamc_p2;
+ char *dict_info;
+
+ strcpy (this_name, hci.cur_name);
+ assert (hci.cur_name[1]);
+ no_diffs++;
+ if ((dict_info = dict_lookup (hi->dict, hci.cur_name)))
+ {
+ memcpy (&isamc_p, dict_info+1, sizeof(ISAMC_P));
+ isamc_p2 = isc_merge (hi->isamc, isamc_p, isamc_i);
+ if (!isamc_p2)
+ {
+ no_deletions++;
+ if (!dict_delete (hi->dict, this_name))
+ abort();
+ }
+ else
+ {
+ no_updates++;
+ if (isamc_p2 != isamc_p)
+ dict_insert (hi->dict, this_name,
+ sizeof(ISAMC_P), &isamc_p2);
+ }
+ }
+ else
+ {
+ isamc_p = isc_merge (hi->isamc, 0, isamc_i);
+ no_insertions++;
+ dict_insert (hi->dict, this_name, sizeof(ISAMC_P), &isamc_p);
+ }
+ }
+ xfree (isamc_i);
+ return 0;
+}
+
+int heap_inp (struct heap_info *hi)