ReactOS  0.4.14-dev-98-gb0d4763
inftrees.c File Reference
#include "zutil.h"
#include "inftrees.h"
Include dependency graph for inftrees.c:

Go to the source code of this file.

Macros

#define BUILDFIXED   /* non ANSI compilers may not accept inffixed.h */
 
#define exop   word.what.Exop
 
#define bits   word.what.Bits
 
#define BMAX   15 /* maximum bit length of any code */
 
#define C0   *p++ = 0;
 
#define C2   C0 C0 C0 C0
 
#define C4   C2 C2 C2 C2
 
#define FIXEDH   544 /* number of hufts used by fixed tables */
 

Functions

int huft_build OF ((uIntf *, uInt, uInt, const uIntf *, const uIntf *, inflate_huft *FAR *, uIntf *, inflate_huft *, uInt *, uIntf *))
 
int huft_build (uIntf *b, uInt n, uInt s, const uIntf *d, const uIntf *e, inflate_huft *FAR *t, uIntf *m, inflate_huft *hp, uInt *hn, uIntf *v)
 
int inflate_trees_bits (uIntf *c, uIntf *bb, inflate_huft *FAR *tb, inflate_huft *hp, z_streamp z)
 
int inflate_trees_dynamic (uInt nl, uInt nd, uIntf *c, uIntf *bl, uIntf *bd, inflate_huft *FAR *tl, inflate_huft *FAR *td, inflate_huft *hp, z_streamp z)
 
int inflate_trees_fixed (uIntf *bl, uIntf *bd, const inflate_huft *FAR *tl, const inflate_huft *FAR *td, z_streamp z)
 

Variables

const uInt cplens [31]
 
const uInt cplext [31]
 
const uInt cpdist [30]
 
const uInt cpdext [30]
 
int fixed_built = 0
 
inflate_huft fixed_mem [FIXEDH]
 
uInt fixed_bl
 
uInt fixed_bd
 
inflate_huftfixed_tl
 
inflate_huftfixed_td
 

Macro Definition Documentation

◆ bits

#define bits   word.what.Bits

Definition at line 27 of file inftrees.c.

◆ BMAX

#define BMAX   15 /* maximum bit length of any code */

Definition at line 93 of file inftrees.c.

◆ BUILDFIXED

#define BUILDFIXED   /* non ANSI compilers may not accept inffixed.h */

Definition at line 10 of file inftrees.c.

◆ C0

#define C0   *p++ = 0;

◆ C2

#define C2   C0 C0 C0 C0

◆ C4

#define C4   C2 C2 C2 C2

◆ exop

#define exop   word.what.Exop

Definition at line 26 of file inftrees.c.

◆ FIXEDH

#define FIXEDH   544 /* number of hufts used by fixed tables */

Definition at line 398 of file inftrees.c.

Function Documentation

◆ huft_build()

int huft_build ( uIntf b,
uInt  n,
uInt  s,
const uIntf d,
const uIntf e,
inflate_huft *FAR t,
uIntf m,
inflate_huft hp,
uInt hn,
uIntf v 
)

Definition at line 95 of file inftrees.c.

111 {
112 
113  uInt a; /* counter for codes of length k */
114  uInt c[BMAX+1]; /* bit length count table */
115  uInt f; /* i repeats in table every f entries */
116  int g; /* maximum code length */
117  int h; /* table level */
118  uInt i; /* counter, current code */
119  uInt j; /* counter */
120  int k; /* number of bits in current code */
121  int l; /* bits per table (returned in m) */
122  uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */
123  uIntf *p; /* pointer into c[], b[], or v[] */
124  inflate_huft *q; /* points to current table */
125  struct inflate_huft_s r; /* table entry for structure assignment */
126  inflate_huft *u[BMAX]; /* table stack */
127  int w; /* bits before this table == (l * h) */
128  uInt x[BMAX+1]; /* bit offsets, then code stack */
129  uIntf *xp; /* pointer into x */
130  int y; /* number of dummy codes added */
131  uInt z; /* number of entries in current table */
132 
133 
134  /* Make compiler happy */
135  r.base = 0;
136 
137  /* Generate counts for each bit length */
138  p = c;
139 #define C0 *p++ = 0;
140 #define C2 C0 C0 C0 C0
141 #define C4 C2 C2 C2 C2
142  C4 /* clear c[]--assume BMAX+1 is 16 */
143  p = b; i = n;
144  do {
145  c[*p++]++; /* assume all entries <= BMAX */
146  } while (--i);
147  if (c[0] == n) /* null input--all zero length codes */
148  {
149  *t = (inflate_huft *)Z_NULL;
150  *m = 0;
151  return Z_OK;
152  }
153 
154 
155  /* Find minimum and maximum length, bound *m by those */
156  l = *m;
157  for (j = 1; j <= BMAX; j++)
158  if (c[j])
159  break;
160  k = j; /* minimum code length */
161  if ((uInt)l < j)
162  l = j;
163  for (i = BMAX; i; i--)
164  if (c[i])
165  break;
166  g = i; /* maximum code length */
167  if ((uInt)l > i)
168  l = i;
169  *m = l;
170 
171 
172  /* Adjust last length count to fill out codes, if needed */
173  for (y = 1 << j; j < i; j++, y <<= 1)
174  if ((y -= c[j]) < 0)
175  return Z_DATA_ERROR;
176  if ((y -= c[i]) < 0)
177  return Z_DATA_ERROR;
178  c[i] += y;
179 
180 
181  /* Generate starting offsets into the value table for each length */
182  x[1] = j = 0;
183  p = c + 1; xp = x + 2;
184  while (--i) { /* note that i == g from above */
185  *xp++ = (j += *p++);
186  }
187 
188 
189  /* Make a table of values in order of bit lengths */
190  p = b; i = 0;
191  do {
192  if ((j = *p++) != 0)
193  v[x[j]++] = i;
194  } while (++i < n);
195  n = x[g]; /* set n to length of v */
196 
197 
198  /* Generate the Huffman codes and for each, make the table entries */
199  x[0] = i = 0; /* first Huffman code is zero */
200  p = v; /* grab values in bit order */
201  h = -1; /* no tables yet--level -1 */
202  w = -l; /* bits decoded == (l * h) */
203  u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */
204  q = (inflate_huft *)Z_NULL; /* ditto */
205  z = 0; /* ditto */
206 
207  /* go through the bit lengths (k already is bits in shortest code) */
208  for (; k <= g; k++)
209  {
210  a = c[k];
211  while (a--)
212  {
213  /* here i is the Huffman code of length k bits for value *p */
214  /* make tables up to required level */
215  while (k > w + l)
216  {
217  h++;
218  w += l; /* previous table always l bits */
219 
220  /* compute minimum size table less than or equal to l bits */
221  z = g - w;
222  z = z > (uInt)l ? (uInt)l : z; /* table size upper limit */
223  if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
224  { /* too few codes for k-w bit table */
225  f -= a + 1; /* deduct codes from patterns left */
226  xp = c + k;
227  if (j < z)
228  while (++j < z) /* try smaller tables up to z bits */
229  {
230  if ((f <<= 1) <= *++xp)
231  break; /* enough codes to use up j bits */
232  f -= *xp; /* else deduct codes from patterns */
233  }
234  }
235  z = 1 << j; /* table entries for j-bit table */
236 
237  /* allocate new table */
238  if (*hn + z > MANY) /* (note: doesn't matter for fixed) */
239  return Z_DATA_ERROR; /* overflow of MANY */
240  u[h] = q = hp + *hn;
241  *hn += z;
242 
243  /* connect to last table, if there is one */
244  if (h)
245  {
246  x[h] = i; /* save pattern for backing up */
247  r.bits = (Byte)l; /* bits to dump before this table */
248  r.exop = (Byte)j; /* bits in this table */
249  j = i >> (w - l);
250  r.base = (uInt)(q - u[h-1] - j); /* offset to this table */
251  u[h-1][j] = r; /* connect to last table */
252  }
253  else
254  *t = q; /* first table is returned result */
255  }
256 
257  /* set up table entry in r */
258  r.bits = (Byte)(k - w);
259  if (p >= v + n)
260  r.exop = 128 + 64; /* out of values--invalid code */
261  else if (*p < s)
262  {
263  r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */
264  r.base = *p++; /* simple code is just the value */
265  }
266  else
267  {
268  r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */
269  r.base = d[*p++ - s];
270  }
271 
272  /* fill code-like entries with r */
273  f = 1 << (k - w);
274  for (j = i >> w; j < z; j += f)
275  q[j] = r;
276 
277  /* backwards increment the k-bit code i */
278  for (j = 1 << (k - 1); i & j; j >>= 1)
279  i ^= j;
280  i ^= j;
281 
282  /* backup over finished tables */
283  mask = (1 << w) - 1; /* needed on HP, cc -O bug */
284  while ((i & mask) != x[h])
285  {
286  h--; /* don't need to update q */
287  w -= l;
288  mask = (1 << w) - 1;
289  }
290  }
291  }
292 
293 
294  /* Return Z_BUF_ERROR if we were given an incomplete table */
295  return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
296 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define BMAX
Definition: inftrees.c:93
unsigned char Byte
Definition: zconf.h:391
uInt FAR uIntf
Definition: zconf.h:404
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLdouble GLdouble t
Definition: gl.h:2047
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
const GLfloat * m
Definition: glext.h:10848
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define MANY
Definition: inftrees.h:36
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define Z_BUF_ERROR
Definition: zlib.h:184
GLenum GLint GLuint mask
Definition: glext.h:6028
#define a
Definition: ke_i.h:78
#define e
Definition: ke_i.h:82
#define Z_OK
Definition: zlib.h:177
GLdouble GLdouble z
Definition: glext.h:5874
#define b
Definition: ke_i.h:79
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
r l[0]
Definition: byte_order.h:167
GLboolean GLboolean g
Definition: glext.h:6204
GLfloat f
Definition: glext.h:7540
#define d
Definition: ke_i.h:81
const GLubyte * c
Definition: glext.h:8905
#define Z_DATA_ERROR
Definition: zlib.h:182
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLdouble s
Definition: gl.h:2039
struct inflate_huft_s FAR inflate_huft
Definition: inftrees.h:17
const GLdouble * v
Definition: gl.h:2040
#define f
Definition: ke_i.h:83
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define c
Definition: ke_i.h:80
#define C4
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
GLfloat GLfloat p
Definition: glext.h:8902
#define Z_NULL
Definition: zlib.h:212
int k
Definition: mpi.c:3369
unsigned int uInt
Definition: zconf.h:393

Referenced by inflate_trees_bits(), inflate_trees_dynamic(), and inflate_trees_fixed().

◆ inflate_trees_bits()

int inflate_trees_bits ( uIntf c,
uIntf bb,
inflate_huft *FAR tb,
inflate_huft hp,
z_streamp  z 
)

Definition at line 299 of file inftrees.c.

306 {
307  int r;
308  uInt hn = 0; /* hufts used in space */
309  uIntf *v; /* work area for huft_build */
310 
311  if ((v = (uIntf*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL)
312  return Z_MEM_ERROR;
313  r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL,
314  tb, bb, hp, &hn, v);
315  if (r == Z_DATA_ERROR)
316  z->msg = (char*)"oversubscribed dynamic bit lengths tree";
317  else if (r == Z_BUF_ERROR || *bb == 0)
318  {
319  z->msg = (char*)"incomplete dynamic bit lengths tree";
320  r = Z_DATA_ERROR;
321  }
322  ZFREE(z, v);
323  return r;
324 }
uInt FAR uIntf
Definition: zconf.h:404
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define ZALLOC(strm, items, size)
Definition: zutil.h:210
int huft_build(uIntf *b, uInt n, uInt s, const uIntf *d, const uIntf *e, inflate_huft *FAR *t, uIntf *m, inflate_huft *hp, uInt *hn, uIntf *v)
Definition: inftrees.c:95
#define Z_BUF_ERROR
Definition: zlib.h:184
GLdouble GLdouble z
Definition: glext.h:5874
const GLubyte * c
Definition: glext.h:8905
#define ZFREE(strm, addr)
Definition: zutil.h:212
#define Z_DATA_ERROR
Definition: zlib.h:182
static const WCHAR tb[]
Definition: suminfo.c:286
const GLdouble * v
Definition: gl.h:2040
#define Z_NULL
Definition: zlib.h:212
#define Z_MEM_ERROR
Definition: zlib.h:183
unsigned int uInt
Definition: zconf.h:393

Referenced by inflate_blocks().

◆ inflate_trees_dynamic()

int inflate_trees_dynamic ( uInt  nl,
uInt  nd,
uIntf c,
uIntf bl,
uIntf bd,
inflate_huft *FAR tl,
inflate_huft *FAR td,
inflate_huft hp,
z_streamp  z 
)

Definition at line 327 of file inftrees.c.

338 {
339  int r;
340  uInt hn = 0; /* hufts used in space */
341  uIntf *v; /* work area for huft_build */
342 
343  /* allocate work area */
344  if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
345  return Z_MEM_ERROR;
346 
347  /* build literal/length tree */
348  r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v);
349  if (r != Z_OK || *bl == 0)
350  {
351  if (r == Z_DATA_ERROR)
352  z->msg = (char*)"oversubscribed literal/length tree";
353  else if (r != Z_MEM_ERROR)
354  {
355  z->msg = (char*)"incomplete literal/length tree";
356  r = Z_DATA_ERROR;
357  }
358  ZFREE(z, v);
359  return r;
360  }
361 
362  /* build distance tree */
363  r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v);
364  if (r != Z_OK || (*bd == 0 && nl > 257))
365  {
366  if (r == Z_DATA_ERROR)
367  z->msg = (char*)"oversubscribed distance tree";
368  else if (r == Z_BUF_ERROR) {
369 #if 0
370  {
371 #endif
372 #ifdef PKZIP_BUG_WORKAROUND
373  r = Z_OK;
374  }
375 #else
376  z->msg = (char*)"incomplete distance tree";
377  r = Z_DATA_ERROR;
378  }
379  else if (r != Z_MEM_ERROR)
380  {
381  z->msg = (char*)"empty distance tree with lengths";
382  r = Z_DATA_ERROR;
383  }
384  ZFREE(z, v);
385  return r;
386 #endif
387  }
388 
389  /* done */
390  ZFREE(z, v);
391  return Z_OK;
392 }
uInt FAR uIntf
Definition: zconf.h:404
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define ZALLOC(strm, items, size)
Definition: zutil.h:210
int huft_build(uIntf *b, uInt n, uInt s, const uIntf *d, const uIntf *e, inflate_huft *FAR *t, uIntf *m, inflate_huft *hp, uInt *hn, uIntf *v)
Definition: inftrees.c:95
const uInt cplext[31]
Definition: inftrees.c:47
#define Z_BUF_ERROR
Definition: zlib.h:184
#define Z_OK
Definition: zlib.h:177
GLdouble GLdouble z
Definition: glext.h:5874
const uInt cplens[31]
Definition: inftrees.c:43
const GLubyte * c
Definition: glext.h:8905
#define ZFREE(strm, addr)
Definition: zutil.h:212
#define Z_DATA_ERROR
Definition: zlib.h:182
const uInt cpdext[30]
Definition: inftrees.c:54
const GLdouble * v
Definition: gl.h:2040
const uInt cpdist[30]
Definition: inftrees.c:50
#define Z_NULL
Definition: zlib.h:212
#define Z_MEM_ERROR
Definition: zlib.h:183
unsigned int uInt
Definition: zconf.h:393

Referenced by inflate_blocks().

◆ inflate_trees_fixed()

int inflate_trees_fixed ( uIntf bl,
uIntf bd,
const inflate_huft *FAR tl,
const inflate_huft *FAR td,
z_streamp  z 
)

Definition at line 409 of file inftrees.c.

416 {
417 #ifdef BUILDFIXED
418  /* build fixed tables if not already */
419  if (!fixed_built)
420  {
421  int k; /* temporary variable */
422  uInt f = 0; /* number of hufts used in fixed_mem */
423  uIntf *c; /* length list for huft_build */
424  uIntf *v; /* work area for huft_build */
425 
426  /* allocate memory */
427  if ((c = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
428  return Z_MEM_ERROR;
429  if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL)
430  {
431  ZFREE(z, c);
432  return Z_MEM_ERROR;
433  }
434 
435  /* literal table */
436  for (k = 0; k < 144; k++)
437  c[k] = 8;
438  for (; k < 256; k++)
439  c[k] = 9;
440  for (; k < 280; k++)
441  c[k] = 7;
442  for (; k < 288; k++)
443  c[k] = 8;
444  fixed_bl = 9;
445  huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl,
446  fixed_mem, &f, v);
447 
448  /* distance table */
449  for (k = 0; k < 30; k++)
450  c[k] = 5;
451  fixed_bd = 5;
452  huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd,
453  fixed_mem, &f, v);
454 
455  /* done */
456  ZFREE(z, v);
457  ZFREE(z, c);
458  fixed_built = 1;
459  }
460 #else
461  FT_UNUSED(z);
462 #endif
463  *bl = fixed_bl;
464  *bd = fixed_bd;
465  *tl = fixed_tl;
466  *td = fixed_td;
467  return Z_OK;
468 }
uInt fixed_bd
Definition: inftrees.c:401
uInt FAR uIntf
Definition: zconf.h:404
#define ZALLOC(strm, items, size)
Definition: zutil.h:210
int huft_build(uIntf *b, uInt n, uInt s, const uIntf *d, const uIntf *e, inflate_huft *FAR *t, uIntf *m, inflate_huft *hp, uInt *hn, uIntf *v)
Definition: inftrees.c:95
const uInt cplext[31]
Definition: inftrees.c:47
#define Z_OK
Definition: zlib.h:177
GLdouble GLdouble z
Definition: glext.h:5874
const uInt cplens[31]
Definition: inftrees.c:43
GLfloat f
Definition: glext.h:7540
const GLubyte * c
Definition: glext.h:8905
#define ZFREE(strm, addr)
Definition: zutil.h:212
const uInt cpdext[30]
Definition: inftrees.c:54
int fixed_built
Definition: inftrees.c:397
inflate_huft * fixed_tl
Definition: inftrees.c:402
inflate_huft * fixed_td
Definition: inftrees.c:403
inflate_huft fixed_mem[FIXEDH]
Definition: inftrees.c:399
const GLdouble * v
Definition: gl.h:2040
const uInt cpdist[30]
Definition: inftrees.c:50
#define c
Definition: ke_i.h:80
#define Z_NULL
Definition: zlib.h:212
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
int k
Definition: mpi.c:3369
#define Z_MEM_ERROR
Definition: zlib.h:183
unsigned int uInt
Definition: zconf.h:393
uInt fixed_bl
Definition: inftrees.c:400

Referenced by inflate_blocks().

◆ OF()

Variable Documentation

◆ cpdext

const uInt cpdext[30]
Initial value:
= {
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}

Definition at line 54 of file inftrees.c.

Referenced by inflate_trees_dynamic(), and inflate_trees_fixed().

◆ cpdist

const uInt cpdist[30]
Initial value:
= {
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}

Definition at line 50 of file inftrees.c.

Referenced by inflate_trees_dynamic(), and inflate_trees_fixed().

◆ cplens

const uInt cplens[31]
Initial value:
= {
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}

Definition at line 43 of file inftrees.c.

Referenced by inflate_trees_dynamic(), and inflate_trees_fixed().

◆ cplext

const uInt cplext[31]
Initial value:
= {
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, 112, 112}

Definition at line 47 of file inftrees.c.

Referenced by inflate_trees_dynamic(), and inflate_trees_fixed().

◆ fixed_bd

uInt fixed_bd

Definition at line 401 of file inftrees.c.

Referenced by inflate_trees_fixed().

◆ fixed_bl

uInt fixed_bl

Definition at line 400 of file inftrees.c.

Referenced by inflate_trees_fixed().

◆ fixed_built

int fixed_built = 0

Definition at line 397 of file inftrees.c.

Referenced by inflate_trees_fixed().

◆ fixed_mem

inflate_huft fixed_mem[FIXEDH]

Definition at line 399 of file inftrees.c.

Referenced by inflate_trees_fixed().

◆ fixed_td

inflate_huft* fixed_td

Definition at line 403 of file inftrees.c.

Referenced by inflate_trees_fixed().

◆ fixed_tl

inflate_huft* fixed_tl

Definition at line 402 of file inftrees.c.

Referenced by inflate_trees_fixed().