Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 480 lines (421 sloc) 16.455 kb
bcf78a2 Mark Adler zlib 0.71
authored
1 /* inftrees.c -- generate Huffman trees for efficient decoding
ebd3c2c Mark Adler zlib 1.0.5
authored
2 * Copyright (C) 1995-1998 Mark Adler
bcf78a2 Mark Adler zlib 0.71
authored
3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */
5
6 #include "zutil.h"
7 #include "inftrees.h"
8
7850e4e Mark Adler zlib 1.0.7
authored
9 const char inflate_copyright[] =
6759211 Mark Adler zlib 1.0.8
authored
10 " inflate 1.0.8 Copyright 1995-1998 Mark Adler ";
56bcb18 Mark Adler zlib 0.99
authored
11 /*
12 If you use the zlib library in a product, an acknowledgment is welcome
13 in the documentation of your product. If for some reason you cannot
14 include such an acknowledgment, I would appreciate that you keep this
15 copyright string in the executable of your product.
16 */
bcf78a2 Mark Adler zlib 0.71
authored
17 struct internal_state {int dummy;}; /* for buggy compilers */
18
19 /* simplify the use of the inflate_huft type with some defines */
20 #define base more.Base
21 #define next more.Next
22 #define exop word.what.Exop
23 #define bits word.what.Bits
24
25
23c69f1 Mark Adler zlib 0.94
authored
26 local int huft_build OF((
27 uIntf *, /* code lengths in bits */
bdde4e0 Mark Adler zlib 0.92
authored
28 uInt, /* number of codes */
29 uInt, /* number of "simple" codes */
ebd3c2c Mark Adler zlib 1.0.5
authored
30 const uIntf *, /* list of base values for non-simple codes */
31 const uIntf *, /* list of extra bits for non-simple codes */
23c69f1 Mark Adler zlib 0.94
authored
32 inflate_huft * FAR*,/* result: starting table */
33 uIntf *, /* maximum lookup bits (returns actual) */
ff11b0a Mark Adler zlib 1.0.4
authored
34 z_streamp )); /* for zalloc function */
bcf78a2 Mark Adler zlib 0.71
authored
35
25e5325 Mark Adler zlib 0.95
authored
36 local voidpf falloc OF((
37 voidpf, /* opaque pointer (not used) */
bdde4e0 Mark Adler zlib 0.92
authored
38 uInt, /* number of items */
39 uInt)); /* size of item */
bcf78a2 Mark Adler zlib 0.71
authored
40
41 /* Tables for deflate from PKZIP's appnote.txt. */
ebd3c2c Mark Adler zlib 1.0.5
authored
42 local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */
bcf78a2 Mark Adler zlib 0.71
authored
43 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
44 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
ebd3c2c Mark Adler zlib 1.0.5
authored
45 /* see note #13 above about 258 */
46 local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */
bcf78a2 Mark Adler zlib 0.71
authored
47 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
ebd3c2c Mark Adler zlib 1.0.5
authored
48 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */
49 local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */
bcf78a2 Mark Adler zlib 0.71
authored
50 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
51 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
52 8193, 12289, 16385, 24577};
ebd3c2c Mark Adler zlib 1.0.5
authored
53 local const uInt cpdext[30] = { /* Extra bits for distance codes */
bcf78a2 Mark Adler zlib 0.71
authored
54 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
55 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
56 12, 12, 13, 13};
57
58 /*
59 Huffman code decoding is performed using a multi-level table lookup.
60 The fastest way to decode is to simply build a lookup table whose
61 size is determined by the longest code. However, the time it takes
62 to build this table can also be a factor if the data being decoded
63 is not very long. The most common codes are necessarily the
64 shortest codes, so those codes dominate the decoding time, and hence
65 the speed. The idea is you can have a shorter table that decodes the
66 shorter, more probable codes, and then point to subsidiary tables for
67 the longer codes. The time it costs to decode the longer codes is
68 then traded against the time it takes to make longer tables.
69
70 This results of this trade are in the variables lbits and dbits
71 below. lbits is the number of bits the first level table for literal/
72 length codes can decode in one step, and dbits is the same thing for
73 the distance codes. Subsequent tables are also less than or equal to
74 those sizes. These values may be adjusted either when all of the
75 codes are shorter than that, in which case the longest code length in
76 bits is used, or when the shortest code is *longer* than the requested
77 table size, in which case the length of the shortest code in bits is
78 used.
79
80 There are two different values for the two tables, since they code a
81 different number of possibilities each. The literal/length table
82 codes 286 possible values, or in a flat code, a little over eight
83 bits. The distance table codes 30 possible values, or a little less
84 than five bits, flat. The optimum values for speed end up being
85 about one bit more than those, so lbits is 8+1 and dbits is 5+1.
86 The optimum values may differ though from machine to machine, and
87 possibly even between compilers. Your mileage may vary.
88 */
89
90
91 /* If BMAX needs to be larger than 16, then h and x[] should be uLong. */
92 #define BMAX 15 /* maximum bit length of any code */
93 #define N_MAX 288 /* maximum number of codes in any set */
94
95 #ifdef DEBUG
96 uInt inflate_hufts;
97 #endif
98
99 local int huft_build(b, n, s, d, e, t, m, zs)
23c69f1 Mark Adler zlib 0.94
authored
100 uIntf *b; /* code lengths in bits (all assumed <= BMAX) */
bcf78a2 Mark Adler zlib 0.71
authored
101 uInt n; /* number of codes (assumed <= N_MAX) */
102 uInt s; /* number of simple-valued codes (0..s-1) */
ebd3c2c Mark Adler zlib 1.0.5
authored
103 const uIntf *d; /* list of base values for non-simple codes */
104 const uIntf *e; /* list of extra bits for non-simple codes */
23c69f1 Mark Adler zlib 0.94
authored
105 inflate_huft * FAR *t; /* result: starting table */
106 uIntf *m; /* maximum lookup bits, returns actual */
ff11b0a Mark Adler zlib 1.0.4
authored
107 z_streamp zs; /* for zalloc function */
bcf78a2 Mark Adler zlib 0.71
authored
108 /* Given a list of code lengths and a maximum table size, make a set of
109 tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
110 if the given code set is incomplete (the tables are still built in this
ebd3c2c Mark Adler zlib 1.0.5
authored
111 case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
112 lengths), or Z_MEM_ERROR if not enough memory. */
bcf78a2 Mark Adler zlib 0.71
authored
113 {
23c69f1 Mark Adler zlib 0.94
authored
114
bdde4e0 Mark Adler zlib 0.92
authored
115 uInt a; /* counter for codes of length k */
116 uInt c[BMAX+1]; /* bit length count table */
117 uInt f; /* i repeats in table every f entries */
118 int g; /* maximum code length */
119 int h; /* table level */
120 register uInt i; /* counter, current code */
121 register uInt j; /* counter */
122 register int k; /* number of bits in current code */
123 int l; /* bits per table (returned in m) */
23c69f1 Mark Adler zlib 0.94
authored
124 register uIntf *p; /* pointer into c[], b[], or v[] */
125 inflate_huft *q; /* points to current table */
126 struct inflate_huft_s r; /* table entry for structure assignment */
bdde4e0 Mark Adler zlib 0.92
authored
127 inflate_huft *u[BMAX]; /* table stack */
128 uInt v[N_MAX]; /* values in order of bit length */
129 register int w; /* bits before this table == (l * h) */
130 uInt x[BMAX+1]; /* bit offsets, then code stack */
23c69f1 Mark Adler zlib 0.94
authored
131 uIntf *xp; /* pointer into x */
bdde4e0 Mark Adler zlib 0.92
authored
132 int y; /* number of dummy codes added */
133 uInt z; /* number of entries in current table */
bcf78a2 Mark Adler zlib 0.71
authored
134
135
136 /* Generate counts for each bit length */
137 p = c;
138 #define C0 *p++ = 0;
139 #define C2 C0 C0 C0 C0
140 #define C4 C2 C2 C2 C2
bdde4e0 Mark Adler zlib 0.92
authored
141 C4 /* clear c[]--assume BMAX+1 is 16 */
bcf78a2 Mark Adler zlib 0.71
authored
142 p = b; i = n;
143 do {
144 c[*p++]++; /* assume all entries <= BMAX */
145 } while (--i);
146 if (c[0] == n) /* null input--all zero length codes */
147 {
148 *t = (inflate_huft *)Z_NULL;
149 *m = 0;
150 return Z_OK;
151 }
152
153
154 /* Find minimum and maximum length, bound *m by those */
155 l = *m;
156 for (j = 1; j <= BMAX; j++)
157 if (c[j])
158 break;
159 k = j; /* minimum code length */
160 if ((uInt)l < j)
161 l = j;
162 for (i = BMAX; i; i--)
163 if (c[i])
164 break;
165 g = i; /* maximum code length */
166 if ((uInt)l > i)
167 l = i;
168 *m = l;
169
170
171 /* Adjust last length count to fill out codes, if needed */
172 for (y = 1 << j; j < i; j++, y <<= 1)
173 if ((y -= c[j]) < 0)
174 return Z_DATA_ERROR;
175 if ((y -= c[i]) < 0)
176 return Z_DATA_ERROR;
177 c[i] += y;
178
179
180 /* Generate starting offsets into the value table for each length */
181 x[1] = j = 0;
182 p = c + 1; xp = x + 2;
183 while (--i) { /* note that i == g from above */
184 *xp++ = (j += *p++);
185 }
186
187
188 /* Make a table of values in order of bit lengths */
189 p = b; i = 0;
190 do {
191 if ((j = *p++) != 0)
192 v[x[j]++] = i;
193 } while (++i < n);
ebd3c2c Mark Adler zlib 1.0.5
authored
194 n = x[g]; /* set n to length of v */
bcf78a2 Mark Adler zlib 0.71
authored
195
196
197 /* Generate the Huffman codes and for each, make the table entries */
198 x[0] = i = 0; /* first Huffman code is zero */
199 p = v; /* grab values in bit order */
200 h = -1; /* no tables yet--level -1 */
201 w = -l; /* bits decoded == (l * h) */
bdde4e0 Mark Adler zlib 0.92
authored
202 u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */
203 q = (inflate_huft *)Z_NULL; /* ditto */
bcf78a2 Mark Adler zlib 0.71
authored
204 z = 0; /* ditto */
205
206 /* go through the bit lengths (k already is bits in shortest code) */
207 for (; k <= g; k++)
208 {
209 a = c[k];
210 while (a--)
211 {
212 /* here i is the Huffman code of length k bits for value *p */
213 /* make tables up to required level */
214 while (k > w + l)
215 {
216 h++;
217 w += l; /* previous table always l bits */
218
219 /* compute minimum size table less than or equal to l bits */
423eb40 Mark Adler zlib 1.0.1
authored
220 z = g - w;
221 z = z > (uInt)l ? l : z; /* table size upper limit */
bcf78a2 Mark Adler zlib 0.71
authored
222 if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
223 { /* too few codes for k-w bit table */
224 f -= a + 1; /* deduct codes from patterns left */
225 xp = c + k;
226 if (j < z)
bdde4e0 Mark Adler zlib 0.92
authored
227 while (++j < z) /* try smaller tables up to z bits */
228 {
229 if ((f <<= 1) <= *++xp)
230 break; /* enough codes to use up j bits */
231 f -= *xp; /* else deduct codes from patterns */
232 }
bcf78a2 Mark Adler zlib 0.71
authored
233 }
234 z = 1 << j; /* table entries for j-bit table */
235
236 /* allocate and link in new table */
237 if ((q = (inflate_huft *)ZALLOC
bdde4e0 Mark Adler zlib 0.92
authored
238 (zs,z + 1,sizeof(inflate_huft))) == Z_NULL)
bcf78a2 Mark Adler zlib 0.71
authored
239 {
240 if (h)
241 inflate_trees_free(u[0], zs);
bdde4e0 Mark Adler zlib 0.92
authored
242 return Z_MEM_ERROR; /* not enough memory */
bcf78a2 Mark Adler zlib 0.71
authored
243 }
244 #ifdef DEBUG
bdde4e0 Mark Adler zlib 0.92
authored
245 inflate_hufts += z + 1;
bcf78a2 Mark Adler zlib 0.71
authored
246 #endif
247 *t = q + 1; /* link to list for huft_free() */
23c69f1 Mark Adler zlib 0.94
authored
248 *(t = &(q->next)) = Z_NULL;
bcf78a2 Mark Adler zlib 0.71
authored
249 u[h] = ++q; /* table starts after link */
250
251 /* connect to last table, if there is one */
252 if (h)
253 {
254 x[h] = i; /* save pattern for backing up */
bdde4e0 Mark Adler zlib 0.92
authored
255 r.bits = (Byte)l; /* bits to dump before this table */
23c69f1 Mark Adler zlib 0.94
authored
256 r.exop = (Byte)j; /* bits in this table */
bcf78a2 Mark Adler zlib 0.71
authored
257 r.next = q; /* pointer to this table */
258 j = i >> (w - l); /* (get around Turbo C bug) */
259 u[h-1][j] = r; /* connect to last table */
260 }
261 }
262
263 /* set up table entry in r */
bdde4e0 Mark Adler zlib 0.92
authored
264 r.bits = (Byte)(k - w);
bcf78a2 Mark Adler zlib 0.71
authored
265 if (p >= v + n)
6b834a5 Mark Adler zlib 0.93
authored
266 r.exop = 128 + 64; /* out of values--invalid code */
bcf78a2 Mark Adler zlib 0.71
authored
267 else if (*p < s)
268 {
23c69f1 Mark Adler zlib 0.94
authored
269 r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */
bcf78a2 Mark Adler zlib 0.71
authored
270 r.base = *p++; /* simple code is just the value */
271 }
272 else
273 {
423eb40 Mark Adler zlib 1.0.1
authored
274 r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */
bcf78a2 Mark Adler zlib 0.71
authored
275 r.base = d[*p++ - s];
276 }
277
278 /* fill code-like entries with r */
279 f = 1 << (k - w);
280 for (j = i >> w; j < z; j += f)
281 q[j] = r;
282
283 /* backwards increment the k-bit code i */
284 for (j = 1 << (k - 1); i & j; j >>= 1)
285 i ^= j;
286 i ^= j;
287
288 /* backup over finished tables */
289 while ((i & ((1 << w) - 1)) != x[h])
290 {
291 h--; /* don't need to update q */
292 w -= l;
293 }
294 }
295 }
296
297
298 /* Return Z_BUF_ERROR if we were given an incomplete table */
299 return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
300 }
301
302
303 int inflate_trees_bits(c, bb, tb, z)
23c69f1 Mark Adler zlib 0.94
authored
304 uIntf *c; /* 19 code lengths */
305 uIntf *bb; /* bits tree desired/actual depth */
306 inflate_huft * FAR *tb; /* bits tree result */
ff11b0a Mark Adler zlib 1.0.4
authored
307 z_streamp z; /* for zfree function */
bcf78a2 Mark Adler zlib 0.71
authored
308 {
309 int r;
310
23c69f1 Mark Adler zlib 0.94
authored
311 r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, tb, bb, z);
bcf78a2 Mark Adler zlib 0.71
authored
312 if (r == Z_DATA_ERROR)
423eb40 Mark Adler zlib 1.0.1
authored
313 z->msg = (char*)"oversubscribed dynamic bit lengths tree";
ebd3c2c Mark Adler zlib 1.0.5
authored
314 else if (r == Z_BUF_ERROR || *bb == 0)
bcf78a2 Mark Adler zlib 0.71
authored
315 {
316 inflate_trees_free(*tb, z);
423eb40 Mark Adler zlib 1.0.1
authored
317 z->msg = (char*)"incomplete dynamic bit lengths tree";
bcf78a2 Mark Adler zlib 0.71
authored
318 r = Z_DATA_ERROR;
319 }
320 return r;
321 }
322
323
324 int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, z)
bdde4e0 Mark Adler zlib 0.92
authored
325 uInt nl; /* number of literal/length codes */
326 uInt nd; /* number of distance codes */
23c69f1 Mark Adler zlib 0.94
authored
327 uIntf *c; /* that many (total) code lengths */
328 uIntf *bl; /* literal desired/actual bit depth */
329 uIntf *bd; /* distance desired/actual bit depth */
330 inflate_huft * FAR *tl; /* literal/length tree result */
331 inflate_huft * FAR *td; /* distance tree result */
ff11b0a Mark Adler zlib 1.0.4
authored
332 z_streamp z; /* for zfree function */
bcf78a2 Mark Adler zlib 0.71
authored
333 {
334 int r;
335
336 /* build literal/length tree */
ebd3c2c Mark Adler zlib 1.0.5
authored
337 r = huft_build(c, nl, 257, cplens, cplext, tl, bl, z);
338 if (r != Z_OK || *bl == 0)
bcf78a2 Mark Adler zlib 0.71
authored
339 {
340 if (r == Z_DATA_ERROR)
423eb40 Mark Adler zlib 1.0.1
authored
341 z->msg = (char*)"oversubscribed literal/length tree";
ebd3c2c Mark Adler zlib 1.0.5
authored
342 else if (r != Z_MEM_ERROR)
bcf78a2 Mark Adler zlib 0.71
authored
343 {
344 inflate_trees_free(*tl, z);
423eb40 Mark Adler zlib 1.0.1
authored
345 z->msg = (char*)"incomplete literal/length tree";
bcf78a2 Mark Adler zlib 0.71
authored
346 r = Z_DATA_ERROR;
347 }
348 return r;
349 }
350
351 /* build distance tree */
ebd3c2c Mark Adler zlib 1.0.5
authored
352 r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, z);
353 if (r != Z_OK || (*bd == 0 && nl > 257))
bcf78a2 Mark Adler zlib 0.71
authored
354 {
355 if (r == Z_DATA_ERROR)
ebd3c2c Mark Adler zlib 1.0.5
authored
356 z->msg = (char*)"oversubscribed distance tree";
bcf78a2 Mark Adler zlib 0.71
authored
357 else if (r == Z_BUF_ERROR) {
358 #ifdef PKZIP_BUG_WORKAROUND
359 r = Z_OK;
360 }
361 #else
362 inflate_trees_free(*td, z);
ebd3c2c Mark Adler zlib 1.0.5
authored
363 z->msg = (char*)"incomplete distance tree";
364 r = Z_DATA_ERROR;
365 }
366 else if (r != Z_MEM_ERROR)
367 {
368 z->msg = (char*)"empty distance tree with lengths";
bcf78a2 Mark Adler zlib 0.71
authored
369 r = Z_DATA_ERROR;
370 }
371 inflate_trees_free(*tl, z);
372 return r;
373 #endif
374 }
375
376 /* done */
377 return Z_OK;
378 }
379
380
381 /* build fixed tables only once--keep them here */
382 local int fixed_built = 0;
bdde4e0 Mark Adler zlib 0.92
authored
383 #define FIXEDH 530 /* number of hufts used by fixed tables */
bcf78a2 Mark Adler zlib 0.71
authored
384 local inflate_huft fixed_mem[FIXEDH];
385 local uInt fixed_bl;
386 local uInt fixed_bd;
387 local inflate_huft *fixed_tl;
388 local inflate_huft *fixed_td;
389
390
25e5325 Mark Adler zlib 0.95
authored
391 local voidpf falloc(q, n, s)
56bcb18 Mark Adler zlib 0.99
authored
392 voidpf q; /* opaque pointer */
bdde4e0 Mark Adler zlib 0.92
authored
393 uInt n; /* number of items */
394 uInt s; /* size of item */
bcf78a2 Mark Adler zlib 0.71
authored
395 {
56bcb18 Mark Adler zlib 0.99
authored
396 Assert(s == sizeof(inflate_huft) && n <= *(intf *)q,
bcf78a2 Mark Adler zlib 0.71
authored
397 "inflate_trees falloc overflow");
423eb40 Mark Adler zlib 1.0.1
authored
398 *(intf *)q -= n+s-s; /* s-s to avoid warning */
56bcb18 Mark Adler zlib 0.99
authored
399 return (voidpf)(fixed_mem + *(intf *)q);
bcf78a2 Mark Adler zlib 0.71
authored
400 }
401
402
403 int inflate_trees_fixed(bl, bd, tl, td)
23c69f1 Mark Adler zlib 0.94
authored
404 uIntf *bl; /* literal desired/actual bit depth */
405 uIntf *bd; /* distance desired/actual bit depth */
406 inflate_huft * FAR *tl; /* literal/length tree result */
407 inflate_huft * FAR *td; /* distance tree result */
bcf78a2 Mark Adler zlib 0.71
authored
408 {
56bcb18 Mark Adler zlib 0.99
authored
409 /* build fixed tables if not already (multiple overlapped executions ok) */
bcf78a2 Mark Adler zlib 0.71
authored
410 if (!fixed_built)
411 {
bdde4e0 Mark Adler zlib 0.92
authored
412 int k; /* temporary variable */
413 unsigned c[288]; /* length list for huft_build */
414 z_stream z; /* for falloc function */
56bcb18 Mark Adler zlib 0.99
authored
415 int f = FIXEDH; /* number of hufts left in fixed_mem */
bcf78a2 Mark Adler zlib 0.71
authored
416
417 /* set up fake z_stream for memory routines */
418 z.zalloc = falloc;
56bcb18 Mark Adler zlib 0.99
authored
419 z.zfree = Z_NULL;
420 z.opaque = (voidpf)&f;
bcf78a2 Mark Adler zlib 0.71
authored
421
422 /* literal table */
423 for (k = 0; k < 144; k++)
424 c[k] = 8;
425 for (; k < 256; k++)
426 c[k] = 9;
427 for (; k < 280; k++)
428 c[k] = 7;
429 for (; k < 288; k++)
430 c[k] = 8;
431 fixed_bl = 7;
432 huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, &z);
433
434 /* distance table */
435 for (k = 0; k < 30; k++)
436 c[k] = 5;
437 fixed_bd = 5;
438 huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, &z);
439
440 /* done */
56bcb18 Mark Adler zlib 0.99
authored
441 Assert(f == 0, "invalid build of fixed tables");
bcf78a2 Mark Adler zlib 0.71
authored
442 fixed_built = 1;
443 }
444 *bl = fixed_bl;
445 *bd = fixed_bd;
446 *tl = fixed_tl;
447 *td = fixed_td;
448 return Z_OK;
449 }
450
451
452 int inflate_trees_free(t, z)
bdde4e0 Mark Adler zlib 0.92
authored
453 inflate_huft *t; /* table to free */
ff11b0a Mark Adler zlib 1.0.4
authored
454 z_streamp z; /* for zfree function */
bcf78a2 Mark Adler zlib 0.71
authored
455 /* Free the malloc'ed tables built by huft_build(), which makes a linked
456 list of the tables it made, with the links in a dummy first entry of
457 each table. */
458 {
56bcb18 Mark Adler zlib 0.99
authored
459 register inflate_huft *p, *q, *r;
bcf78a2 Mark Adler zlib 0.71
authored
460
56bcb18 Mark Adler zlib 0.99
authored
461 /* Reverse linked list */
462 p = Z_NULL;
463 q = t;
464 while (q != Z_NULL)
465 {
466 r = (q - 1)->next;
467 (q - 1)->next = p;
468 p = q;
469 q = r;
470 }
bcf78a2 Mark Adler zlib 0.71
authored
471 /* Go through linked list, freeing from the malloced (t[-1]) address. */
472 while (p != Z_NULL)
473 {
474 q = (--p)->next;
475 ZFREE(z,p);
476 p = q;
477 }
478 return Z_OK;
479 }
Something went wrong with that request. Please try again.