annotate lib/zlib/inftrees.c @ 170:f089d88b6739

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