diff options
Diffstat (limited to 'infback.c')
| -rw-r--r-- | infback.c | 53 |
1 files changed, 1 insertions, 52 deletions
| @@ -63,57 +63,6 @@ int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, | |||
| 63 | return Z_OK; | 63 | return Z_OK; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | /* | ||
| 67 | Return state with length and distance decoding tables and index sizes set to | ||
| 68 | fixed code decoding. Normally this returns fixed tables from inffixed.h. | ||
| 69 | If BUILDFIXED is defined, then instead this routine builds the tables the | ||
| 70 | first time it's called, and returns those tables the first time and | ||
| 71 | thereafter. This reduces the size of the code by about 2K bytes, in | ||
| 72 | exchange for a little execution time. However, BUILDFIXED should not be | ||
| 73 | used for threaded applications, since the rewriting of the tables and virgin | ||
| 74 | may not be thread-safe. | ||
| 75 | */ | ||
| 76 | local void fixedtables(struct inflate_state FAR *state) { | ||
| 77 | #ifdef BUILDFIXED | ||
| 78 | static int virgin = 1; | ||
| 79 | static code *lenfix, *distfix; | ||
| 80 | static code fixed[544]; | ||
| 81 | |||
| 82 | /* build fixed huffman tables if first call (may not be thread safe) */ | ||
| 83 | if (virgin) { | ||
| 84 | unsigned sym, bits; | ||
| 85 | static code *next; | ||
| 86 | |||
| 87 | /* literal/length table */ | ||
| 88 | sym = 0; | ||
| 89 | while (sym < 144) state->lens[sym++] = 8; | ||
| 90 | while (sym < 256) state->lens[sym++] = 9; | ||
| 91 | while (sym < 280) state->lens[sym++] = 7; | ||
| 92 | while (sym < 288) state->lens[sym++] = 8; | ||
| 93 | next = fixed; | ||
| 94 | lenfix = next; | ||
| 95 | bits = 9; | ||
| 96 | inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); | ||
| 97 | |||
| 98 | /* distance table */ | ||
| 99 | sym = 0; | ||
| 100 | while (sym < 32) state->lens[sym++] = 5; | ||
| 101 | distfix = next; | ||
| 102 | bits = 5; | ||
| 103 | inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); | ||
| 104 | |||
| 105 | /* do this just once */ | ||
| 106 | virgin = 0; | ||
| 107 | } | ||
| 108 | #else /* !BUILDFIXED */ | ||
| 109 | # include "inffixed.h" | ||
| 110 | #endif /* BUILDFIXED */ | ||
| 111 | state->lencode = lenfix; | ||
| 112 | state->lenbits = 9; | ||
| 113 | state->distcode = distfix; | ||
| 114 | state->distbits = 5; | ||
| 115 | } | ||
| 116 | |||
| 117 | /* Macros for inflateBack(): */ | 66 | /* Macros for inflateBack(): */ |
| 118 | 67 | ||
| 119 | /* Load returned state from inflate_fast() */ | 68 | /* Load returned state from inflate_fast() */ |
| @@ -293,7 +242,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, | |||
| 293 | state->mode = STORED; | 242 | state->mode = STORED; |
| 294 | break; | 243 | break; |
| 295 | case 1: /* fixed block */ | 244 | case 1: /* fixed block */ |
| 296 | fixedtables(state); | 245 | inflate_fixed(state); |
| 297 | Tracev((stderr, "inflate: fixed codes block%s\n", | 246 | Tracev((stderr, "inflate: fixed codes block%s\n", |
| 298 | state->last ? " (last)" : "")); | 247 | state->last ? " (last)" : "")); |
| 299 | state->mode = LEN; /* decode codes */ | 248 | state->mode = LEN; /* decode codes */ |
