MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fixedtables

Function fixedtables

freebsd/contrib/zlib/infback.c:82–123  ·  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

(state)

Source from the content-addressed store, hash-verified

80 may not be thread-safe.
81 */
82local void fixedtables(state)
83struct inflate_state FAR *state;
84{
85#ifdef BUILDFIXED
86 static int virgin = 1;
87 static code *lenfix, *distfix;
88 static code fixed[544];
89
90 /* build fixed huffman tables if first call (may not be thread safe) */
91 if (virgin) {
92 unsigned sym, bits;
93 static code *next;
94
95 /* literal/length table */
96 sym = 0;
97 while (sym < 144) state->lens[sym++] = 8;
98 while (sym < 256) state->lens[sym++] = 9;
99 while (sym < 280) state->lens[sym++] = 7;
100 while (sym < 288) state->lens[sym++] = 8;
101 next = fixed;
102 lenfix = next;
103 bits = 9;
104 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
105
106 /* distance table */
107 sym = 0;
108 while (sym < 32) state->lens[sym++] = 5;
109 distfix = next;
110 bits = 5;
111 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
112
113 /* do this just once */
114 virgin = 0;
115 }
116#else /* !BUILDFIXED */
117# include "inffixed.h"
118#endif /* BUILDFIXED */
119 state->lencode = lenfix;
120 state->lenbits = 9;
121 state->distcode = distfix;
122 state->distbits = 5;
123}
124
125/* Macros for inflateBack(): */
126

Callers 1

inflateBackFunction · 0.70

Calls 1

inflate_tableFunction · 0.85

Tested by

no test coverage detected