+#if CF_OPTIMIZE_COMMIT
+ if (map_cache_add(m_p, p->vno[i], p->no[i]))
+ {
+ r = -1;
+ goto out;
+ }
+#else
+ if (mf_read(cf->block_mf, p->vno[i], 0, 0, cf->iobuf) != 1)
+ {
+ yaz_log (YLOG_FATAL, "read commit block");
+ r = -1;
+ goto out;
+ }
+ if (mf_write(cf->rmf, p->no[i], 0, 0, cf->iobuf))
+ {
+ yaz_log (YLOG_FATAL, "write commit block");
+ r = -1;
+ goto out;
+ }
+#endif
+ }
+ }
+ out:
+#if CF_OPTIMIZE_COMMIT
+ if (map_cache_del(m_p))
+ r = -1;
+#endif
+ xfree(p);
+ return r;
+}
+
+static int cf_commit_flat(CFile cf)
+{
+ zint *fp;
+ zint hno;
+ int i;
+ int r = 0;
+ zint vno = 0;
+
+#if CF_OPTIMIZE_COMMIT
+ struct map_cache *m_p;
+#endif
+
+
+#if CF_OPTIMIZE_COMMIT
+ m_p = map_cache_init (cf);
+#endif
+ fp = (zint *) xmalloc (HASH_BSIZE);
+ for (hno = cf->head.next_bucket; hno < cf->head.flat_bucket; hno++)
+ {
+ for (i = 0; i < (int) (HASH_BSIZE/sizeof(zint)); i++)
+ fp[i] = 0;
+ if (!mf_read (cf->hash_mf, hno, 0, 0, fp) &&
+ hno != cf->head.flat_bucket-1)
+ {
+ yaz_log (YLOG_FATAL, "read index block hno=" ZINT_FORMAT
+ " (" ZINT_FORMAT "-" ZINT_FORMAT ") commit",
+ hno, cf->head.next_bucket, cf->head.flat_bucket-1);
+ r = -1;
+ goto out;
+ }
+ for (i = 0; i < (int) (HASH_BSIZE/sizeof(zint)); i++)
+ {
+ if (fp[i])