X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fpagecache.c;h=13ad36603fc7f69ea64c0aa9e527e74c88d8a7f5;hb=7af80cdb684884505ceeb2d71414b2b9c24ab02b;hp=edbf6c631ba6cf8ec35f3d52e1803ef709d280e1;hpb=562b2b0f0eaa8baf71a1f39a507b0a0764e18b08;p=libucw.git diff --git a/lib/pagecache.c b/lib/pagecache.c index edbf6c63..13ad3660 100644 --- a/lib/pagecache.c +++ b/lib/pagecache.c @@ -1,5 +1,5 @@ /* - * Sherlock Library -- File Page Cache + * UCW Library -- File Page Cache * * (c) 1999--2002 Martin Mares * @@ -16,6 +16,7 @@ #include #include #include +#include struct page_cache { list free_pages; /* LRU queue of free non-dirty pages */ @@ -30,7 +31,7 @@ struct page_cache { uns stat_miss; /* Number of cache misses */ uns stat_write; /* Number of writes */ list *hash_table; /* List heads corresponding to hash buckets */ -#ifndef SHERLOCK_HAVE_PREAD +#ifndef HAVE_PREAD sh_off_t pos; /* Current position in the file */ int pos_fd; /* FD the position corresponds to */ #endif @@ -54,7 +55,7 @@ pgc_open(uns page_size, uns max_pages) c->hash_table = xmalloc(sizeof(list) * c->hash_size); for(i=0; ihash_size; i++) init_list(&c->hash_table[i]); -#ifndef SHERLOCK_HAVE_PREAD +#ifndef HAVE_PREAD c->pos_fd = -1; #endif return c; @@ -104,7 +105,7 @@ flush_page(struct page_cache *c, struct page *p) int s; ASSERT(p->flags & PG_FLAG_DIRTY); -#ifdef SHERLOCK_HAVE_PREAD +#ifdef HAVE_PREAD s = sh_pwrite(p->fd, p->data, c->page_size, p->pos); #else if (c->pos != p->pos || c->pos_fd != (int) p->fd) @@ -281,7 +282,7 @@ pgc_read(struct page_cache *c, int fd, sh_off_t pos) else { c->stat_miss++; -#ifdef SHERLOCK_HAVE_PREAD +#ifdef HAVE_PREAD s = sh_pread(fd, p->data, c->page_size, pos); #else if (c->pos != pos || c->pos_fd != (int)fd) @@ -342,7 +343,7 @@ pgc_put(struct page_cache *c, struct page *p) else { rem_node(&p->hn); - free(p); + xfree(p); c->total_count--; } }