+ isamc_p = isc_merge (hi->reg->isamc, 0, isamc_i);
+ hi->no_insertions++;
+ dict_insert (hi->reg->dict, this_name, sizeof(ISAMC_P), &isamc_p);
+ }
+ }
+ xfree (isamc_i);
+ xfree (hci.key);
+ return 0;
+}
+
+/* for debugging only */
+static void print_dict_item (ZebraMaps zm, const char *s)
+{
+ int reg_type = s[1];
+ char keybuf[IT_MAX_WORD+1];
+ char *to = keybuf;
+ const char *from = s + 2;
+
+ while (*from)
+ {
+ const char *res = zebra_maps_output (zm, reg_type, &from);
+ if (!res)
+ *to++ = *from++;
+ else
+ while (*res)
+ *to++ = *res++;
+ }
+ *to = '\0';
+ yaz_log (LOG_LOG, "%s", keybuf);
+}
+
+int heap_inpb (struct heap_info *hi)
+{
+ struct heap_cread_info hci;
+ ISAMC_I isamc_i = (ISAMC_I) xmalloc (sizeof(*isamc_i));
+
+ hci.key = (char *) 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]);
+ hi->no_diffs++;
+
+#if 0
+ print_dict_item (hi->reg->zebra_maps, hci.cur_name);
+#endif
+ if ((dict_info = dict_lookup (hi->reg->dict, hci.cur_name)))
+ {
+ memcpy (&isamc_p, dict_info+1, sizeof(ISAMC_P));
+ isamc_p2 = isamb_merge (hi->reg->isamb, isamc_p, isamc_i);
+ if (!isamc_p2)
+ {
+ hi->no_deletions++;
+ if (!dict_delete (hi->reg->dict, this_name))
+ abort();
+ }
+ else
+ {
+ hi->no_updates++;
+ if (isamc_p2 != isamc_p)
+ dict_insert (hi->reg->dict, this_name,
+ sizeof(ISAMC_P), &isamc_p2);
+ }
+ }
+ else
+ {
+ isamc_p = isamb_merge (hi->reg->isamb, 0, isamc_i);
+ hi->no_insertions++;
+ dict_insert (hi->reg->dict, this_name, sizeof(ISAMC_P), &isamc_p);