]> mj.ucw.cz Git - libucw.git/blobdiff - lib/pagecache.c
Introduced obuck_get_pos(), converted gatherd limits to use it.
[libucw.git] / lib / pagecache.c
index f194fc5cb838901dc0a9b13b7c42487b90a6ba3e..57abfeea3beb50193e798d7118cd713dc9e57ffc 100644 (file)
@@ -1,19 +1,19 @@
 /*
  *     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) */
@@ -39,10 +39,9 @@ struct page_cache {
 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);
@@ -65,8 +64,8 @@ pgc_close(struct page_cache *c)
   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
@@ -251,7 +250,7 @@ pgc_cleanup(struct page_cache *c)
       rem_node(&p->hn);
       c->free_count--;
       c->total_count--;
-      free(p);
+      xfree(p);
     }
   ASSERT(!c->free_count);
 }