Lines Matching refs:state
30 struct inflate_state FAR *state;
53 state = (struct inflate_state FAR *)ZALLOC(strm, 1,
55 if (state == Z_NULL) return Z_MEM_ERROR;
57 strm->state = (struct internal_state FAR *)state;
58 state->dmax = 32768U;
59 state->wbits = (uInt)windowBits;
60 state->wsize = 1U << windowBits;
61 state->window = window;
62 state->wnext = 0;
63 state->whave = 0;
64 state->sane = 1;
69 Return state with length and distance decoding tables and index sizes set to
78 local void fixedtables(struct inflate_state FAR *state) {
91 while (sym < 144) state->lens[sym++] = 8;
92 while (sym < 256) state->lens[sym++] = 9;
93 while (sym < 280) state->lens[sym++] = 7;
94 while (sym < 288) state->lens[sym++] = 8;
98 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
102 while (sym < 32) state->lens[sym++] = 5;
105 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
113 state->lencode = lenfix;
114 state->lenbits = 9;
115 state->distcode = distfix;
116 state->distbits = 5;
121 /* Load returned state from inflate_fast() */
128 hold = state->hold; \
129 bits = state->bits; \
132 /* Set state from registers for inflate_fast() */
139 state->hold = hold; \
140 state->bits = bits; \
207 put = state->window; \
208 left = state->wsize; \
209 state->whave = left; \
240 error, or Z_MEM_ERROR if it could not allocate memory for the state.
242 are not correct, i.e. strm is Z_NULL or the state was not initialized.
246 struct inflate_state FAR *state;
261 /* Check that the strm exists and that the state was initialized */
262 if (strm == Z_NULL || strm->state == Z_NULL)
264 state = (struct inflate_state FAR *)strm->state;
266 /* Reset the state */
268 state->mode = TYPE;
269 state->last = 0;
270 state->whave = 0;
275 put = state->window;
276 left = state->wsize;
280 switch (state->mode) {
283 if (state->last) {
285 state->mode = DONE;
289 state->last = BITS(1);
294 state->last ? " (last)" : ""));
295 state->mode = STORED;
298 fixedtables(state);
300 state->last ? " (last)" : ""));
301 state->mode = LEN; /* decode codes */
305 state->last ? " (last)" : ""));
306 state->mode = TABLE;
310 state->mode = BAD;
321 state->mode = BAD;
324 state->length = (unsigned)hold & 0xffff;
326 state->length));
330 while (state->length != 0) {
331 copy = state->length;
341 state->length -= copy;
344 state->mode = TYPE;
350 state->nlen = BITS(5) + 257;
352 state->ndist = BITS(5) + 1;
354 state->ncode = BITS(4) + 4;
357 if (state->nlen > 286 || state->ndist > 30) {
359 state->mode = BAD;
366 state->have = 0;
367 while (state->have < state->ncode) {
369 state->lens[order[state->have++]] = (unsigned short)BITS(3);
372 while (state->have < 19)
373 state->lens[order[state->have++]] = 0;
374 state->next = state->codes;
375 state->lencode = (code const FAR *)(state->next);
376 state->lenbits = 7;
377 ret = inflate_table(CODES, state->lens, 19, &(state->next),
378 &(state->lenbits), state->work);
381 state->mode = BAD;
387 state->have = 0;
388 while (state->have < state->nlen + state->ndist) {
390 here = state->lencode[BITS(state->lenbits)];
396 state->lens[state->have++] = here.val;
402 if (state->have == 0) {
404 state->mode = BAD;
407 len = (unsigned)(state->lens[state->have - 1]);
425 if (state->have + copy > state->nlen + state->ndist) {
427 state->mode = BAD;
431 state->lens[state->have++] = (unsigned short)len;
436 if (state->mode == BAD) break;
439 if (state->lens[256] == 0) {
441 state->mode = BAD;
448 state->next = state->codes;
449 statestate->next);
450 state->lenbits = 9;
451 ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
452 &(state->lenbits), state->work);
455 state->mode = BAD;
458 state->distcode = (code const FAR *)(state->next);
459 state->distbits = 6;
460 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
461 &(state->next), &(state->distbits), state->work);
464 state->mode = BAD;
468 state->mode = LEN;
475 if (state->whave < state->wsize)
476 state->whave = state->wsize - left;
477 inflate_fast(strm, state->wsize);
484 here = state->lencode[BITS(state->lenbits)];
491 here = state->lencode[last.val +
499 state->length = (unsigned)here.val;
507 *put++ = (unsigned char)(state->length);
509 state->mode = LEN;
516 state->mode = TYPE;
523 state->mode = BAD;
528 state->extra = (unsigned)(here.op) & 15;
529 if (state->extra != 0) {
530 NEEDBITS(state->extra);
531 state->length += BITS(state->extra);
532 DROPBITS(state->extra);
534 Tracevv((stderr, "inflate: length %u\n", state->length));
538 here = state->distcode[BITS(state->distbits)];
545 here = state->distcode[last.val +
555 state->mode = BAD;
558 state->offset = (unsigned)here.val;
561 state->extra = (unsigned)(here.op) & 15;
562 if (state->extra != 0) {
563 NEEDBITS(state->extra);
564 state->offset += BITS(state->extra);
565 DROPBITS(state->extra);
567 if (state->offset > state->wsize - (state->whave < state->wsize ?
570 state->mode = BAD;
573 Tracevv((stderr, "inflate: distance %u\n", state->offset));
578 copy = state->wsize - state->offset;
584 from = put - state->offset;
587 if (copy > state->length) copy = state->length;
588 state->length -= copy;
593 } while (state->length != 0);
613 if (left < state->wsize) {
614 if (out(out_desc, state->window, state->wsize - left) &&
624 if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
626 ZFREE(strm, strm->state);
627 strm->state = Z_NULL;