diff options
Diffstat (limited to 'main/zlib/infutil.c')
-rw-r--r-- | main/zlib/infutil.c | 112 |
1 files changed, 62 insertions, 50 deletions
diff --git a/main/zlib/infutil.c b/main/zlib/infutil.c index 4c9fd54..856a197 100644 --- a/main/zlib/infutil.c +++ b/main/zlib/infutil.c @@ -1,6 +1,6 @@ /* inflate_util.c -- data and routines common to blocks and codes * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h + * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" @@ -10,7 +10,9 @@ #include "infutil.h" extern int memcpy(char *,char *, int); -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ +struct inflate_codes_state { + int dummy; +}; /* for buggy compilers */ /* And'ing with mask[n] masks the lower n bits */ uInt inflate_mask[17] = { @@ -26,63 +28,73 @@ inflate_blocks_statef *s; z_streamp z; int r; { - uInt n; - Bytef *p; - Bytef *q; - - /* local copies of source and destination pointers */ - p = z->next_out; - q = s->read; - - /* compute number of bytes to copy as far as end of window */ - n = (uInt)((q <= s->write ? s->write : s->end) - q); - if (n > z->avail_out) n = z->avail_out; - if (n && r == Z_BUF_ERROR) r = Z_OK; - - /* update counters */ - z->avail_out -= n; - z->total_out += n; - - /* update check information */ - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(s->check, q, n); - - /* copy as far as end of window */ - zmemcpy((char *)p, (char *)q, n); - p += n; - q += n; - - /* see if more to copy at beginning of window */ - if (q == s->end) - { - /* wrap pointers */ - q = s->window; - if (s->write == s->end) - s->write = s->window; - - /* compute bytes to copy */ - n = (uInt)(s->write - q); - if (n > z->avail_out) n = z->avail_out; - if (n && r == Z_BUF_ERROR) r = Z_OK; + uInt n; + Bytef *p; + Bytef *q; + + /* local copies of source and destination pointers */ + p = z->next_out; + q = s->read; + + /* compute number of bytes to copy as far as end of window */ + n = (uInt)((q <= s->write ? s->write : s->end) - q); + if(n > z->avail_out) { + n = z->avail_out; + } + if(n && r == Z_BUF_ERROR) { + r = Z_OK; + } /* update counters */ z->avail_out -= n; z->total_out += n; /* update check information */ - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(s->check, q, n); + if(s->checkfn != Z_NULL) { + z->adler = s->check = (*s->checkfn)(s->check, q, n); + } - /* copy */ + /* copy as far as end of window */ zmemcpy((char *)p, (char *)q, n); p += n; q += n; - } - /* update pointers */ - z->next_out = p; - s->read = q; - - /* done */ - return r; + /* see if more to copy at beginning of window */ + if(q == s->end) { + /* wrap pointers */ + q = s->window; + if(s->write == s->end) { + s->write = s->window; + } + + /* compute bytes to copy */ + n = (uInt)(s->write - q); + if(n > z->avail_out) { + n = z->avail_out; + } + if(n && r == Z_BUF_ERROR) { + r = Z_OK; + } + + /* update counters */ + z->avail_out -= n; + z->total_out += n; + + /* update check information */ + if(s->checkfn != Z_NULL) { + z->adler = s->check = (*s->checkfn)(s->check, q, n); + } + + /* copy */ + zmemcpy((char *)p, (char *)q, n); + p += n; + q += n; + } + + /* update pointers */ + z->next_out = p; + s->read = q; + + /* done */ + return r; } |