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

Function fixedtables

freebsd/contrib/zlib/inflate.c:278–319  ·  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

276 may not be thread-safe.
277 */
278local void fixedtables(state)
279struct inflate_state FAR *state;
280{
281#ifdef BUILDFIXED
282 static int virgin = 1;
283 static code *lenfix, *distfix;
284 static code fixed[544];
285
286 /* build fixed huffman tables if first call (may not be thread safe) */
287 if (virgin) {
288 unsigned sym, bits;
289 static code *next;
290
291 /* literal/length table */
292 sym = 0;
293 while (sym < 144) state->lens[sym++] = 8;
294 while (sym < 256) state->lens[sym++] = 9;
295 while (sym < 280) state->lens[sym++] = 7;
296 while (sym < 288) state->lens[sym++] = 8;
297 next = fixed;
298 lenfix = next;
299 bits = 9;
300 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
301
302 /* distance table */
303 sym = 0;
304 while (sym < 32) state->lens[sym++] = 5;
305 distfix = next;
306 bits = 5;
307 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
308
309 /* do this just once */
310 virgin = 0;
311 }
312#else /* !BUILDFIXED */
313# include "inffixed.h"
314#endif /* BUILDFIXED */
315 state->lencode = lenfix;
316 state->lenbits = 9;
317 state->distcode = distfix;
318 state->distbits = 5;
319}
320
321#ifdef MAKEFIXED
322#include <stdio.h>

Callers 2

makefixedFunction · 0.70
inflate.cFile · 0.70

Calls 1

inflate_tableFunction · 0.85

Tested by

no test coverage detected