diff options
Diffstat (limited to 'inftrees.c')
-rw-r--r-- | inftrees.c | 31 |
1 files changed, 18 insertions, 13 deletions
@@ -6,8 +6,12 @@ | |||
6 | #include "zutil.h" | 6 | #include "zutil.h" |
7 | #include "inftrees.h" | 7 | #include "inftrees.h" |
8 | 8 | ||
9 | #if !defined(BUILDFIXED) && !defined(STDC) | ||
10 | # define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */ | ||
11 | #endif | ||
12 | |||
9 | const char inflate_copyright[] = | 13 | const char inflate_copyright[] = |
10 | " inflate 1.1.1 Copyright 1995-1998 Mark Adler "; | 14 | " inflate 1.1.2 Copyright 1995-1998 Mark Adler "; |
11 | /* | 15 | /* |
12 | If you use the zlib library in a product, an acknowledgment is welcome | 16 | 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 | 17 | in the documentation of your product. If for some reason you cannot |
@@ -17,8 +21,6 @@ const char inflate_copyright[] = | |||
17 | struct internal_state {int dummy;}; /* for buggy compilers */ | 21 | struct internal_state {int dummy;}; /* for buggy compilers */ |
18 | 22 | ||
19 | /* simplify the use of the inflate_huft type with some defines */ | 23 | /* 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 | 24 | #define exop word.what.Exop |
23 | #define bits word.what.Bits | 25 | #define bits word.what.Bits |
24 | 26 | ||
@@ -232,11 +234,6 @@ uIntf *v; /* working area: values in order of bit length */ | |||
232 | return Z_MEM_ERROR; /* not enough memory */ | 234 | return Z_MEM_ERROR; /* not enough memory */ |
233 | u[h] = q = hp + *hn; | 235 | u[h] = q = hp + *hn; |
234 | *hn += z; | 236 | *hn += z; |
235 | if (t != Z_NULL) /* first table is returned result */ | ||
236 | { | ||
237 | *t = q; | ||
238 | t = Z_NULL; | ||
239 | } | ||
240 | 237 | ||
241 | /* connect to last table, if there is one */ | 238 | /* connect to last table, if there is one */ |
242 | if (h) | 239 | if (h) |
@@ -244,10 +241,12 @@ uIntf *v; /* working area: values in order of bit length */ | |||
244 | x[h] = i; /* save pattern for backing up */ | 241 | x[h] = i; /* save pattern for backing up */ |
245 | r.bits = (Byte)l; /* bits to dump before this table */ | 242 | r.bits = (Byte)l; /* bits to dump before this table */ |
246 | r.exop = (Byte)j; /* bits in this table */ | 243 | r.exop = (Byte)j; /* bits in this table */ |
247 | r.next = q; /* pointer to this table */ | 244 | j = i >> (w - l); |
248 | j = i >> (w - l); /* (get around Turbo C bug) */ | 245 | r.base = (uInt)(q - u[h-1] - j); /* offset to this table */ |
249 | u[h-1][j] = r; /* connect to last table */ | 246 | u[h-1][j] = r; /* connect to last table */ |
250 | } | 247 | } |
248 | else | ||
249 | *t = q; /* first table is returned result */ | ||
251 | } | 250 | } |
252 | 251 | ||
253 | /* set up table entry in r */ | 252 | /* set up table entry in r */ |
@@ -384,13 +383,17 @@ z_streamp z; /* for messages */ | |||
384 | 383 | ||
385 | 384 | ||
386 | /* build fixed tables only once--keep them here */ | 385 | /* build fixed tables only once--keep them here */ |
386 | #ifdef BUILDFIXED | ||
387 | local int fixed_built = 0; | 387 | local int fixed_built = 0; |
388 | #define FIXEDH 424 /* number of hufts used by fixed tables */ | 388 | #define FIXEDH 544 /* number of hufts used by fixed tables */ |
389 | local inflate_huft fixed_mem[FIXEDH]; | 389 | local inflate_huft fixed_mem[FIXEDH]; |
390 | local uInt fixed_bl; | 390 | local uInt fixed_bl; |
391 | local uInt fixed_bd; | 391 | local uInt fixed_bd; |
392 | local inflate_huft *fixed_tl; | 392 | local inflate_huft *fixed_tl; |
393 | local inflate_huft *fixed_td; | 393 | local inflate_huft *fixed_td; |
394 | #else | ||
395 | #include "inffixed.h" | ||
396 | #endif | ||
394 | 397 | ||
395 | 398 | ||
396 | int inflate_trees_fixed(bl, bd, tl, td, z) | 399 | int inflate_trees_fixed(bl, bd, tl, td, z) |
@@ -400,7 +403,8 @@ inflate_huft * FAR *tl; /* literal/length tree result */ | |||
400 | inflate_huft * FAR *td; /* distance tree result */ | 403 | inflate_huft * FAR *td; /* distance tree result */ |
401 | z_streamp z; /* for memory allocation */ | 404 | z_streamp z; /* for memory allocation */ |
402 | { | 405 | { |
403 | /* build fixed tables if not already (multiple overlapped executions ok) */ | 406 | #ifdef BUILDFIXED |
407 | /* build fixed tables if not already */ | ||
404 | if (!fixed_built) | 408 | if (!fixed_built) |
405 | { | 409 | { |
406 | int k; /* temporary variable */ | 410 | int k; /* temporary variable */ |
@@ -426,7 +430,7 @@ z_streamp z; /* for memory allocation */ | |||
426 | c[k] = 7; | 430 | c[k] = 7; |
427 | for (; k < 288; k++) | 431 | for (; k < 288; k++) |
428 | c[k] = 8; | 432 | c[k] = 8; |
429 | fixed_bl = 7; | 433 | fixed_bl = 9; |
430 | huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, | 434 | huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, |
431 | fixed_mem, &f, v); | 435 | fixed_mem, &f, v); |
432 | 436 | ||
@@ -442,6 +446,7 @@ z_streamp z; /* for memory allocation */ | |||
442 | ZFREE(z, c); | 446 | ZFREE(z, c); |
443 | fixed_built = 1; | 447 | fixed_built = 1; |
444 | } | 448 | } |
449 | #endif | ||
445 | *bl = fixed_bl; | 450 | *bl = fixed_bl; |
446 | *bd = fixed_bd; | 451 | *bd = fixed_bd; |
447 | *tl = fixed_tl; | 452 | *tl = fixed_tl; |