* Sebastian Hammer, Adam Dickmeiss
*
* $Log: cfile.c,v $
- * Revision 1.13 1996-04-09 14:48:49 adam
+ * Revision 1.15 1996-04-18 16:02:56 adam
+ * Changed logging a bit.
+ * Removed warning message when commiting flat shadow files.
+ *
+ * Revision 1.14 1996/04/12 07:01:55 adam
+ * Yet another bug fix (next_block was initialized to 0; now set to 1).
+ *
+ * Revision 1.13 1996/04/09 14:48:49 adam
* Bug fix: offset calculation when using flat files was completely broken.
*
* Revision 1.12 1996/04/09 06:47:28 adam
int hash_bytes;
cf->rmf = mf;
- logf (LOG_LOG, "cf_open %s", cf->rmf->name);
+ logf (LOG_LOG, "cf_open %s %s", cf->rmf->name, wflag ? "rdwr" : "rd");
sprintf (path, "%s-b", fname);
if (!(cf->block_mf = mf_open (area, path, block_size, wflag)))
{
hash_bytes = cf->head.hash_size * sizeof(int);
cf->head.flat_bucket = cf->head.next_bucket = cf->head.first_bucket =
(hash_bytes+sizeof(cf->head))/HASH_BSIZE + 2;
- cf->head.next_block = 0;
+ cf->head.next_block = 1;
if (wflag)
mf_write (cf->hash_mf, 0, 0, sizeof(cf->head), &cf->head);
cf->array = xmalloc (hash_bytes);
assert (cf->head.hash_size > 2);
hash_bytes = cf->head.hash_size * sizeof(int);
assert (cf->head.next_bucket > 0);
+ assert (cf->head.next_block > 0);
if (cf->head.state == 1)
cf->array = xmalloc (hash_bytes);
else
hno += cf->head.next_bucket;
if (hno >= cf->head.flat_bucket)
cf->head.flat_bucket = hno+1;
+ cf->dirty = 1;
mf_write (cf->hash_mf, hno, off, sizeof(int), &vno);
}
xfree (cf->parray);
cf->parray = NULL;
cf->head.state = 2;
+ cf->dirty = 1;
}
static int cf_lookup (CFile cf, int no)
int cf_close (CFile cf)
{
- logf (LOG_LOG, "cf_close %s", cf->rmf->name);
logf (LOG_LOG, "hits=%d miss=%d bucket_in_memory=%d total=%d",
cf->no_hits, cf->no_miss, cf->bucket_in_memory,
cf->head.next_bucket - cf->head.first_bucket);
flush_bucket (cf, -1);
if (cf->dirty)
{
+ logf (LOG_LOG, "dirty. write header");
mf_write (cf->hash_mf, 0, 0, sizeof(cf->head), &cf->head);
write_head (cf);
}
xfree (cf->parray);
xfree (cf->iobuf);
xfree (cf);
+ logf (LOG_LOG, "cf_close %s", cf->rmf->name);
return 0;
}