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

Function fixedtables

extern/zlib/src/infback.c:76–115  ·  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

74 may not be thread-safe.
75 */
76local 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(): */
118

Callers 1

inflateBackFunction · 0.70

Calls 1

inflate_tableFunction · 0.85

Tested by

no test coverage detected