X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fpagecache.c;h=e987a5fead8da24d795b5c2d8f6a062b695bcb15;hb=34289767d57bb8845699c819362d286bd51c8952;hp=e3257fe20e5a3612c92d6f80459784822614e56a;hpb=76ee03dea8ff0a04d7659ded5a9a53ef3eb39aa7;p=libucw.git diff --git a/lib/pagecache.c b/lib/pagecache.c index e3257fe2..e987a5fe 100644 --- a/lib/pagecache.c +++ b/lib/pagecache.c @@ -1,7 +1,7 @@ /* * Sherlock Library -- File Page Cache * - * (c) 1999--2000 Martin Mares + * (c) 1999--2002 Martin Mares */ #include "lib/lib.h" @@ -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); @@ -105,7 +104,7 @@ flush_page(struct page_cache *c, struct page *p) #ifdef SHERLOCK_HAVE_PREAD s = sh_pwrite(p->fd, p->data, c->page_size, p->pos); #else - if (c->pos != p->pos || c->pos_fd != p->fd) + if (c->pos != p->pos || c->pos_fd != (int) p->fd) sh_seek(p->fd, p->pos, SEEK_SET); s = write(p->fd, p->data, c->page_size); c->pos = p->pos + s; @@ -140,7 +139,7 @@ static void flush_pages(struct page_cache *c, uns force) { uns cnt = 0; - uns max = force ? ~0 : c->free_count / 2; /* FIXME: Needs tuning */ + uns max = force ? ~0U : c->free_count / 2; /* FIXME: Needs tuning */ uns i; struct page *p, *q, **req, **rr; @@ -282,7 +281,7 @@ pgc_read(struct page_cache *c, int fd, sh_off_t pos) #ifdef SHERLOCK_HAVE_PREAD s = sh_pread(fd, p->data, c->page_size, pos); #else - if (c->pos != pos || c->pos_fd != fd) + if (c->pos != pos || c->pos_fd != (int)fd) sh_seek(fd, pos, SEEK_SET); s = read(fd, p->data, c->page_size); c->pos = pos + s;