zlib 1.0.1
This commit is contained in:
31
inftrees.c
31
inftrees.c
@@ -1,12 +1,12 @@
|
||||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||
* Copyright (C) 1995 Mark Adler
|
||||
* Copyright (C) 1995-1996 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
|
||||
char inflate_copyright[] = " inflate 1.0 Copyright 1995 Mark Adler ";
|
||||
char inflate_copyright[] = " inflate 1.0.1 Copyright 1995-1996 Mark Adler ";
|
||||
/*
|
||||
If you use the zlib library in a product, an acknowledgment is welcome
|
||||
in the documentation of your product. If for some reason you cannot
|
||||
@@ -38,18 +38,18 @@ local voidpf falloc OF((
|
||||
uInt)); /* size of item */
|
||||
|
||||
/* Tables for deflate from PKZIP's appnote.txt. */
|
||||
local uInt cplens[] = { /* Copy lengths for literal codes 257..285 */
|
||||
local uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
|
||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||
/* actually lengths - 2; also see note #13 above about 258 */
|
||||
local uInt cplext[] = { /* Extra bits for literal codes 257..285 */
|
||||
local uInt cplext[31] = { /* Extra bits for literal codes 257..285 */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 192, 192}; /* 192==invalid */
|
||||
local uInt cpdist[] = { /* Copy offsets for distance codes 0..29 */
|
||||
local uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
8193, 12289, 16385, 24577};
|
||||
local uInt cpdext[] = { /* Extra bits for distance codes */
|
||||
local uInt cpdext[30] = { /* Extra bits for distance codes */
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
|
||||
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
|
||||
12, 12, 13, 13};
|
||||
@@ -215,7 +215,8 @@ z_stream *zs; /* for zalloc function */
|
||||
w += l; /* previous table always l bits */
|
||||
|
||||
/* compute minimum size table less than or equal to l bits */
|
||||
z = (z = g - w) > (uInt)l ? l : z; /* table size upper limit */
|
||||
z = g - w;
|
||||
z = z > (uInt)l ? l : z; /* table size upper limit */
|
||||
if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
|
||||
{ /* too few codes for k-w bit table */
|
||||
f -= a + 1; /* deduct codes from patterns left */
|
||||
@@ -268,7 +269,7 @@ z_stream *zs; /* for zalloc function */
|
||||
}
|
||||
else
|
||||
{
|
||||
r.exop = (Byte)e[*p - s] + 16 + 64; /* non-simple--look up in lists */
|
||||
r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */
|
||||
r.base = d[*p++ - s];
|
||||
}
|
||||
|
||||
@@ -307,11 +308,11 @@ z_stream *z; /* for zfree function */
|
||||
|
||||
r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, tb, bb, z);
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = "oversubscribed dynamic bit lengths tree";
|
||||
z->msg = (char*)"oversubscribed dynamic bit lengths tree";
|
||||
else if (r == Z_BUF_ERROR)
|
||||
{
|
||||
inflate_trees_free(*tb, z);
|
||||
z->msg = "incomplete dynamic bit lengths tree";
|
||||
z->msg = (char*)"incomplete dynamic bit lengths tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
return r;
|
||||
@@ -334,11 +335,11 @@ z_stream *z; /* for zfree function */
|
||||
if ((r = huft_build(c, nl, 257, cplens, cplext, tl, bl, z)) != Z_OK)
|
||||
{
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = "oversubscribed literal/length tree";
|
||||
z->msg = (char*)"oversubscribed literal/length tree";
|
||||
else if (r == Z_BUF_ERROR)
|
||||
{
|
||||
inflate_trees_free(*tl, z);
|
||||
z->msg = "incomplete literal/length tree";
|
||||
z->msg = (char*)"incomplete literal/length tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
return r;
|
||||
@@ -348,14 +349,14 @@ z_stream *z; /* for zfree function */
|
||||
if ((r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, z)) != Z_OK)
|
||||
{
|
||||
if (r == Z_DATA_ERROR)
|
||||
z->msg = "oversubscribed literal/length tree";
|
||||
z->msg = (char*)"oversubscribed literal/length tree";
|
||||
else if (r == Z_BUF_ERROR) {
|
||||
#ifdef PKZIP_BUG_WORKAROUND
|
||||
r = Z_OK;
|
||||
}
|
||||
#else
|
||||
inflate_trees_free(*td, z);
|
||||
z->msg = "incomplete literal/length tree";
|
||||
z->msg = (char*)"incomplete literal/length tree";
|
||||
r = Z_DATA_ERROR;
|
||||
}
|
||||
inflate_trees_free(*tl, z);
|
||||
@@ -385,7 +386,7 @@ uInt s; /* size of item */
|
||||
{
|
||||
Assert(s == sizeof(inflate_huft) && n <= *(intf *)q,
|
||||
"inflate_trees falloc overflow");
|
||||
*(intf *)q -= n;
|
||||
*(intf *)q -= n+s-s; /* s-s to avoid warning */
|
||||
return (voidpf)(fixed_mem + *(intf *)q);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user