MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / fixedtables

Function fixedtables

extern/zlib/src/inflate.c:252–291  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

250 may not be thread-safe.
251 */
252local void fixedtables(struct inflate_state FAR *state) {
253#ifdef BUILDFIXED
254 static int virgin = 1;
255 static code *lenfix, *distfix;
256 static code fixed[544];
257
258 /* build fixed huffman tables if first call (may not be thread safe) */
259 if (virgin) {
260 unsigned sym, bits;
261 static code *next;
262
263 /* literal/length table */
264 sym = 0;
265 while (sym < 144) state->lens[sym++] = 8;
266 while (sym < 256) state->lens[sym++] = 9;
267 while (sym < 280) state->lens[sym++] = 7;
268 while (sym < 288) state->lens[sym++] = 8;
269 next = fixed;
270 lenfix = next;
271 bits = 9;
272 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
273
274 /* distance table */
275 sym = 0;
276 while (sym < 32) state->lens[sym++] = 5;
277 distfix = next;
278 bits = 5;
279 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
280
281 /* do this just once */
282 virgin = 0;
283 }
284#else /* !BUILDFIXED */
285# include "inffixed.h"
286#endif /* BUILDFIXED */
287 state->lencode = lenfix;
288 state->lenbits = 9;
289 state->distcode = distfix;
290 state->distbits = 5;
291}
292
293#ifdef MAKEFIXED
294#include <stdio.h>

Callers 2

makefixedFunction · 0.70
inflate.cFile · 0.70

Calls 1

inflate_tableFunction · 0.85

Tested by

no test coverage detected