=========================================================================== * Initialize the various 'constant' tables. */
| 293 | * Initialize the various 'constant' tables. |
| 294 | */ |
| 295 | local void tr_static_init(void) { |
| 296 | #if defined(GEN_TREES_H) || !defined(STDC) |
| 297 | static int static_init_done = 0; |
| 298 | int n; /* iterates over tree elements */ |
| 299 | int bits; /* bit counter */ |
| 300 | int length; /* length value */ |
| 301 | int code; /* code value */ |
| 302 | int dist; /* distance index */ |
| 303 | ush bl_count[MAX_BITS+1]; |
| 304 | /* number of codes at each bit length for an optimal tree */ |
| 305 | |
| 306 | if (static_init_done) return; |
| 307 | |
| 308 | /* For some embedded targets, global variables are not initialized: */ |
| 309 | #ifdef NO_INIT_GLOBAL_POINTERS |
| 310 | static_l_desc.static_tree = static_ltree; |
| 311 | static_l_desc.extra_bits = extra_lbits; |
| 312 | static_d_desc.static_tree = static_dtree; |
| 313 | static_d_desc.extra_bits = extra_dbits; |
| 314 | static_bl_desc.extra_bits = extra_blbits; |
| 315 | #endif |
| 316 | |
| 317 | /* Initialize the mapping length (0..255) -> length code (0..28) */ |
| 318 | length = 0; |
| 319 | for (code = 0; code < LENGTH_CODES-1; code++) { |
| 320 | base_length[code] = length; |
| 321 | for (n = 0; n < (1 << extra_lbits[code]); n++) { |
| 322 | _length_code[length++] = (uch)code; |
| 323 | } |
| 324 | } |
| 325 | Assert (length == 256, "tr_static_init: length != 256"); |
| 326 | /* Note that the length 255 (match length 258) can be represented |
| 327 | * in two different ways: code 284 + 5 bits or code 285, so we |
| 328 | * overwrite length_code[255] to use the best encoding: |
| 329 | */ |
| 330 | _length_code[length - 1] = (uch)code; |
| 331 | |
| 332 | /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ |
| 333 | dist = 0; |
| 334 | for (code = 0 ; code < 16; code++) { |
| 335 | base_dist[code] = dist; |
| 336 | for (n = 0; n < (1 << extra_dbits[code]); n++) { |
| 337 | _dist_code[dist++] = (uch)code; |
| 338 | } |
| 339 | } |
| 340 | Assert (dist == 256, "tr_static_init: dist != 256"); |
| 341 | dist >>= 7; /* from now on, all distances are divided by 128 */ |
| 342 | for ( ; code < D_CODES; code++) { |
| 343 | base_dist[code] = dist << 7; |
| 344 | for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) { |
| 345 | _dist_code[256 + dist++] = (uch)code; |
| 346 | } |
| 347 | } |
| 348 | Assert (dist == 256, "tr_static_init: 256 + dist != 512"); |
| 349 | |
| 350 | /* Construct the codes of the static literal tree */ |
| 351 | for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0; |
| 352 | n = 0; |
no test coverage detected