/*
* Sherlock Library -- File Page Cache
*
- * (c) 1999--2000 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * (c) 1999--2000 Martin Mares <mj@ucw.cz>
*/
+#include "lib/lib.h"
+#include "lib/pagecache.h"
+#include "lib/lfs.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
-#include "lib.h"
-#include "pagecache.h"
-#include "lfs.h"
-
struct page_cache {
list free_pages; /* LRU queue of free non-dirty pages */
list locked_pages; /* List of locked pages (starts with dirty ones) */
struct page_cache *
pgc_open(uns page_size, uns max_pages)
{
- struct page_cache *c = xmalloc(sizeof(struct page_cache));
+ struct page_cache *c = xmalloc_zero(sizeof(struct page_cache));
uns i;
- bzero(c, sizeof(*c));
init_list(&c->free_pages);
init_list(&c->locked_pages);
init_list(&c->dirty_pages);
ASSERT(EMPTY_LIST(c->locked_pages));
ASSERT(EMPTY_LIST(c->dirty_pages));
ASSERT(EMPTY_LIST(c->free_pages));
- free(c->hash_table);
- free(c);
+ xfree(c->hash_table);
+ xfree(c);
}
static void
rem_node(&p->hn);
c->free_count--;
c->total_count--;
- free(p);
+ xfree(p);
}
ASSERT(!c->free_count);
}