Commit bfcf81ec authored by Jörn Engel's avatar Jörn Engel Committed by Linus Torvalds

[PATCH] zlib merge: inffast.c

Most of it is reformatting, but the functional bits should fix real
problems.  A loop is introduced, just like in the turboc patch and one
of the three condition bodies has been expanded.
parent 68a37fb3
......@@ -90,28 +90,41 @@ int zlib_inflate_fast(
/* 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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment