diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:26:40 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:26:40 -0700 |
commit | f6194ef39af5864f792412460c354cc339dde7d1 (patch) | |
tree | 5ea1e6849128e9b2194c66ee3d82afa36b4ac07c /contrib/infback9/inftree9.c | |
parent | 639be997883d9016baaf46017a2802b2ce1698bd (diff) | |
download | zlib-1.2.3.4.tar.gz zlib-1.2.3.4.tar.bz2 zlib-1.2.3.4.zip |
zlib 1.2.3.4v1.2.3.4
Diffstat (limited to 'contrib/infback9/inftree9.c')
-rw-r--r-- | contrib/infback9/inftree9.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/contrib/infback9/inftree9.c b/contrib/infback9/inftree9.c index c24302b..18353cb 100644 --- a/contrib/infback9/inftree9.c +++ b/contrib/infback9/inftree9.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* inftree9.c -- generate Huffman trees for efficient decoding | 1 | /* inftree9.c -- generate Huffman trees for efficient decoding |
2 | * Copyright (C) 1995-2006 Mark Adler | 2 | * Copyright (C) 1995-2008 Mark Adler |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -9,7 +9,7 @@ | |||
9 | #define MAXBITS 15 | 9 | #define MAXBITS 15 |
10 | 10 | ||
11 | const char inflate9_copyright[] = | 11 | const char inflate9_copyright[] = |
12 | " inflate9 1.2.3.3 Copyright 1995-2006 Mark Adler "; | 12 | " inflate9 1.2.3.4 Copyright 1995-2008 Mark Adler "; |
13 | /* | 13 | /* |
14 | If you use the zlib library in a product, an acknowledgment is welcome | 14 | If you use the zlib library in a product, an acknowledgment is welcome |
15 | in the documentation of your product. If for some reason you cannot | 15 | in the documentation of your product. If for some reason you cannot |
@@ -64,7 +64,7 @@ unsigned short FAR *work; | |||
64 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ | 64 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ |
65 | 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, | 65 | 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, |
66 | 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, | 66 | 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, |
67 | 133, 133, 133, 133, 144, 201, 203}; | 67 | 133, 133, 133, 133, 144, 72, 200}; |
68 | static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ | 68 | static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ |
69 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, | 69 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, |
70 | 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, | 70 | 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, |
@@ -160,11 +160,10 @@ unsigned short FAR *work; | |||
160 | entered in the tables. | 160 | entered in the tables. |
161 | 161 | ||
162 | used keeps track of how many table entries have been allocated from the | 162 | used keeps track of how many table entries have been allocated from the |
163 | provided *table space. It is checked when a LENS table is being made | 163 | provided *table space. It is checked for LENS and DIST tables against |
164 | against the space in *table, ENOUGH, minus the maximum space needed by | 164 | the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in |
165 | the worst case distance code, MAXD. This should never happen, but the | 165 | the initial root table size constants. See the comments in inftree9.h |
166 | sufficiency of ENOUGH has not been proven exhaustively, hence the check. | 166 | for more information. |
167 | This assumes that when type == LENS, bits == 9. | ||
168 | 167 | ||
169 | sym increments through all symbols, and the loop terminates when | 168 | sym increments through all symbols, and the loop terminates when |
170 | all codes of length max, i.e. all codes, have been processed. This | 169 | all codes of length max, i.e. all codes, have been processed. This |
@@ -203,7 +202,8 @@ unsigned short FAR *work; | |||
203 | mask = used - 1; /* mask for comparing low */ | 202 | mask = used - 1; /* mask for comparing low */ |
204 | 203 | ||
205 | /* check available table space */ | 204 | /* check available table space */ |
206 | if (type == LENS && used >= ENOUGH - MAXD) | 205 | if ((type == LENS && used >= ENOUGH_LENS) || |
206 | (type == DISTS && used >= ENOUGH_DISTS)) | ||
207 | return 1; | 207 | return 1; |
208 | 208 | ||
209 | /* process all codes and make table entries */ | 209 | /* process all codes and make table entries */ |
@@ -270,7 +270,8 @@ unsigned short FAR *work; | |||
270 | 270 | ||
271 | /* check for enough space */ | 271 | /* check for enough space */ |
272 | used += 1U << curr; | 272 | used += 1U << curr; |
273 | if (type == LENS && used >= ENOUGH - MAXD) | 273 | if ((type == LENS && used >= ENOUGH_LENS) || |
274 | (type == DISTS && used >= ENOUGH_DISTS)) | ||
274 | return 1; | 275 | return 1; |
275 | 276 | ||
276 | /* point entry in root table to sub-table */ | 277 | /* point entry in root table to sub-table */ |