summaryrefslogtreecommitdiffstats
path: root/libpng/inffast.c
diff options
context:
space:
mode:
authordimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2002-04-07 17:23:32 (GMT)
committerdimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2002-04-07 17:23:32 (GMT)
commit63962ead8b355c4c93d5e442ab0a26005e1b863f (patch)
treec38e1a43019260d8c13223b0bab64424c575dfcb /libpng/inffast.c
parentde20cde3d47c58a69c25afe75e4c476d61dbe631 (diff)
downloadDoxygen-63962ead8b355c4c93d5e442ab0a26005e1b863f.zip
Doxygen-63962ead8b355c4c93d5e442ab0a26005e1b863f.tar.gz
Doxygen-63962ead8b355c4c93d5e442ab0a26005e1b863f.tar.bz2
Release-1.2.15-20020407
Diffstat (limited to 'libpng/inffast.c')
-rw-r--r--libpng/inffast.c59
1 files changed, 36 insertions, 23 deletions
diff --git a/libpng/inffast.c b/libpng/inffast.c
index 61a78ee..1f0d650 100644
--- a/libpng/inffast.c
+++ b/libpng/inffast.c
@@ -1,5 +1,5 @@
/* inffast.c -- process literals and length/distance pairs fast
- * Copyright (C) 1995-1998 Mark Adler
+ * Copyright (C) 1995-2002 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -25,12 +25,12 @@ struct inflate_codes_state {int dummy;}; /* for buggy compilers */
at least ten. The ten bytes are six bytes for the longest length/
distance pair plus four bytes for overloading the bit buffer. */
-int inflate_fast(bl, bd, tl, td, s, z)
-uInt bl, bd;
-inflate_huft *tl;
-inflate_huft *td; /* need separate declaration for Borland C++ */
-inflate_blocks_statef *s;
-z_streamp z;
+int inflate_fast(uInt bl, uInt bd, inflate_huft *tl, inflate_huft *td, inflate_blocks_statef *s, z_streamp z)
+
+
+ /* need separate declaration for Borland C++ */
+
+
{
inflate_huft *t; /* temporary pointer */
uInt e; /* extra bits or operation */
@@ -93,28 +93,41 @@ z_streamp z;
/* do the copy */
m -= c;
- if ((uInt)(q - s->window) >= d) /* offset before dest */
- { /* just copy */
- r = q - d;
- *q++ = *r++; c--; /* minimum count is three, */
- *q++ = *r++; c--; /* so unroll loop a little */
- }
- else /* else offset after destination */
+ r = q - d;
+ if (r < s->window) /* wrap if needed */
{
- e = d - (uInt)(q - s->window); /* bytes from offset to end */
- r = s->end - e; /* pointer to offset */
- if (c > e) /* if source crosses, */
+ do {
+ r += s->end - s->window; /* force pointer in window */
+ } while (r < s->window); /* covers invalid distances */
+ e = s->end - r;
+ if (c > e)
{
- c -= e; /* copy to end of window */
+ c -= e; /* wrapped copy */
do {
- *q++ = *r++;
+ *q++ = *r++;
} while (--e);
- r = s->window; /* copy rest from start of window */
+ r = s->window;
+ do {
+ *q++ = *r++;
+ } while (--c);
}
+ else /* normal copy */
+ {
+ *q++ = *r++; c--;
+ *q++ = *r++; c--;
+ do {
+ *q++ = *r++;
+ } while (--c);
+ }
+ }
+ else /* normal copy */
+ {
+ *q++ = *r++; c--;
+ *q++ = *r++; c--;
+ do {
+ *q++ = *r++;
+ } while (--c);
}
- do { /* copy all or what's left */
- *q++ = *r++;
- } while (--c);
break;
}
else if ((e & 64) == 0)