/* ep->cache already points to space for ep->csize elements */
if (how & EFF_MEM) {
if (ep->fids > ep->csize) {
- logerror("Can't open %s: file larger than %d bytes",
- ep->file, ep->fids * ep->size);
+ logerror("Can't open %s (file larger than %d records)",
+ ep->file, ep->csize);
close(fd);
return 0;
}
if ((how & EFF_MEM) && ep->fids) {
if (fillcache(ep, 0) != ep->fids) {
ep->cids = 0; /* prevent cache flush */
- ep->flags &= EFF_IMMUTABLE; /* maintain invariant */
ef_close(type);
return 0;
}
}
/*
- * Close the file-backed table TYPE (EF_SECTOR, ...).
+ * Close the open table TYPE (EF_SECTOR, ...).
* Return non-zero on success, zero on failure.
*/
int
else {
if (!ef_flush(type))
retval = 0;
- ep->flags &= EFF_IMMUTABLE;
if (!(ep->flags & EFF_STATIC)) {
free(ep->cache);
ep->cache = NULL;
}
ep->fd = -1;
}
+ ep->flags &= EFF_IMMUTABLE;
ep->baseid = ep->cids = ep->fids = 0;
if (ep->onresize && ep->onresize(type) < 0)
retval = 0;
}
/*
- * Initialize element ID for EP in BUF.
+ * Initialize element ID for table TYPE in BUF.
* FIXME pass buffer size!
* BUF is marked fresh with ef_mark_fresh().
*/