Return state with length and distance decoding tables and index sizes set to fixed code decoding. Normally this returns fixed tables from inffixed.h. If BUILDFIXED is defined, then instead this routine builds the tables the first time it's called, and returns those tables the first time and thereafter. This reduces the size of the code by about 2K bytes, in exchange for a little e
| 245 | may not be thread-safe. |
| 246 | */ |
| 247 | local void fixedtables(struct inflate_state FAR *state) |
| 248 | { |
| 249 | #ifdef BUILDFIXED |
| 250 | static int virgin = 1; |
| 251 | static code *lenfix, *distfix; |
| 252 | static code fixed[544]; |
| 253 | |
| 254 | /* build fixed huffman tables if first call (may not be thread safe) */ |
| 255 | if (virgin) { |
| 256 | unsigned sym, bits; |
| 257 | static code *next; |
| 258 | |
| 259 | /* literal/length table */ |
| 260 | sym = 0; |
| 261 | while (sym < 144) state->lens[sym++] = 8; |
| 262 | while (sym < 256) state->lens[sym++] = 9; |
| 263 | while (sym < 280) state->lens[sym++] = 7; |
| 264 | while (sym < 288) state->lens[sym++] = 8; |
| 265 | next = fixed; |
| 266 | lenfix = next; |
| 267 | bits = 9; |
| 268 | inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); |
| 269 | |
| 270 | /* distance table */ |
| 271 | sym = 0; |
| 272 | while (sym < 32) state->lens[sym++] = 5; |
| 273 | distfix = next; |
| 274 | bits = 5; |
| 275 | inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); |
| 276 | |
| 277 | /* do this just once */ |
| 278 | virgin = 0; |
| 279 | } |
| 280 | #else /* !BUILDFIXED */ |
| 281 | # include "inffixed.h" |
| 282 | #endif /* BUILDFIXED */ |
| 283 | state->lencode = lenfix; |
| 284 | state->lenbits = 9; |
| 285 | state->distcode = distfix; |
| 286 | state->distbits = 5; |
| 287 | } |
| 288 | |
| 289 | #ifdef MAKEFIXED |
| 290 | #include <stdio.h> |
no test coverage detected