+ p->buf = xmalloc (b->file[cat].head.block_size);
+
+ if (!b->file[cat].head.free_list)
+ {
+ int block_no;
+ block_no = b->file[cat].head.last_block++;
+ p->pos = block_no * 4 + cat;
+ }
+ else
+ {
+ p->pos = b->file[cat].head.free_list;
+ if (!get_block (b, p->pos, p->buf, 0))
+ {
+ yaz_log (b->log_io, "bf_read: new_block");
+ if (!bf_read (b->file[cat].bf, p->pos/4, 0, 0, p->buf))
+ {
+ yaz_log (LOG_FATAL, "read failure for pos=%ld block=%ld",
+ (long) p->pos/4, (long) p->pos/4);
+ abort ();
+ }
+ }
+ yaz_log (b->log_freelist, "got block %d from freelist %d:%d", p->pos,
+ cat, p->pos/4);
+ memcpy (&b->file[cat].head.free_list, p->buf, sizeof(int));
+ }