Home | History | Annotate | Download | only in zlib

Lines Matching refs:state

19 local void fixedtables OF((struct inflate_state FAR *state));

35 struct inflate_state FAR *state;
49 state = (struct inflate_state FAR *)ZALLOC(strm, 1,
51 if (state == Z_NULL) return Z_MEM_ERROR;
53 strm->state = (struct internal_state FAR *)state;
54 state->dmax = 32768U;
55 state->wbits = windowBits;
56 state->wsize = 1U << windowBits;
57 state->window = window;
58 state->write = 0;
59 state->whave = 0;
64 Return state with length and distance decoding tables and index sizes set to
73 local void fixedtables(state)
74 struct inflate_state FAR *state;
88 while (sym < 144) state->lens[sym++] = 8;
89 while (sym < 256) state->lens[sym++] = 9;
90 while (sym < 280) state->lens[sym++] = 7;
91 while (sym < 288) state->lens[sym++] = 8;
95 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
99 while (sym < 32) state->lens[sym++] = 5;
102 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
110 state->lencode = lenfix;
111 state->lenbits = 9;
112 state->distcode = distfix;
113 state->distbits = 5;
118 /* Load returned state from inflate_fast() */
125 hold = state->hold; \
126 bits = state->bits; \
129 /* Set state from registers for inflate_fast() */
136 state->hold = hold; \
137 state->bits = bits; \
204 put = state->window; \
205 left = state->wsize; \
206 state->whave = left; \
237 error, or Z_MEM_ERROR if it could not allocate memory for the state.
239 are not correct, i.e. strm is Z_NULL or the state was not initialized.
248 struct inflate_state FAR *state;
263 /* Check that the strm exists and that the state was initialized */
264 if (strm == Z_NULL || strm->state == Z_NULL)
266 state = (struct inflate_state FAR *)strm->state;
268 /* Reset the state */
270 state->mode = TYPE;
271 state->last = 0;
272 state->whave = 0;
277 put = state->window;
278 left = state->wsize;
282 switch (state->mode) {
285 if (state->last) {
287 state->mode = DONE;
291 state->last = BITS(1);
296 state->last ? " (last)" : ""));
297 state->mode = STORED;
300 fixedtables(state);
302 state->last ? " (last)" : ""));
303 state->mode = LEN; /* decode codes */
307 state->last ? " (last)" : ""));
308 state->mode = TABLE;
312 state->mode = BAD;
323 state->mode = BAD;
326 state->length = (unsigned)hold & 0xffff;
328 state->length));
332 while (state->length != 0) {
333 copy = state->length;
343 state->length -= copy;
346 state->mode = TYPE;
352 state->nlen = BITS(5) + 257;
354 state->ndist = BITS(5) + 1;
356 state->ncode = BITS(4) + 4;
359 if (state->nlen > 286 || state->ndist > 30) {
361 state->mode = BAD;
368 state->have = 0;
369 while (state->have < state->ncode) {
371 state->lens[order[state->have++]] = (unsigned short)BITS(3);
374 while (state->have < 19)
375 state->lens[order[state->have++]] = 0;
376 state->next = state->codes;
377 state->lencode = (code const FAR *)(state->next);
378 state->lenbits = 7;
379 ret = inflate_table(CODES, state->lens, 19, &(state->next),
380 &(state->lenbits), state->work);
383 state->mode = BAD;
389 state->have = 0;
390 while (state->have < state->nlen + state->ndist) {
392 this = state->lencode[BITS(state->lenbits)];
399 state->lens[state->have++] = this.val;
405 if (state->have == 0) {
407 state->mode = BAD;
410 len = (unsigned)(state->lens[state->have - 1]);
428 if (state->have + copy > state->nlen + state->ndist) {
430 state->mode = BAD;
434 state->lens[state->have++] = (unsigned short)len;
439 if (state->mode == BAD) break;
442 state->next = state->codes;
443 state->lencode = (code const FAR *)(state->next);
444 state->lenbits = 9;
445 ret = inflate_table(LENS, state->lens, state->nlen, &(state
446 &(state->lenbits), state->work);
449 state->mode = BAD;
452 state->distcode = (code const FAR *)(state->next);
453 state->distbits = 6;
454 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
455 &(state->next), &(state->distbits), state->work);
458 state->mode = BAD;
462 state->mode = LEN;
468 if (state->whave < state->wsize)
469 state->whave = state->wsize - left;
470 inflate_fast(strm, state->wsize);
477 this = state->lencode[BITS(state->lenbits)];
484 this = state->lencode[last.val +
492 state->length = (unsigned)this.val;
500 *put++ = (unsigned char)(state->length);
502 state->mode = LEN;
509 state->mode = TYPE;
516 state->mode = BAD;
521 state->extra = (unsigned)(this.op) & 15;
522 if (state->extra != 0) {
523 NEEDBITS(state->extra);
524 state->length += BITS(state->extra);
525 DROPBITS(state->extra);
527 Tracevv((stderr, "inflate: length %u\n", state->length));
531 this = state->distcode[BITS(state->distbits)];
538 this = state->distcode[last.val +
548 state->mode = BAD;
551 state->offset = (unsigned)this.val;
554 state->extra = (unsigned)(this.op) & 15;
555 if (state->extra != 0) {
556 NEEDBITS(state->extra);
557 state->offset += BITS(state->extra);
558 DROPBITS(state->extra);
560 if (state->offset > state->wsize - (state->whave < state->wsize ?
563 state->mode = BAD;
566 Tracevv((stderr, "inflate: distance %u\n", state->offset));
571 copy = state->wsize - state->offset;
577 from = put - state->offset;
580 if (copy > state->length) copy = state->length;
581 state->length -= copy;
586 } while (state->length != 0);
592 if (left < state->wsize) {
593 if (out(out_desc, state->window, state->wsize - left))
617 if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
619 ZFREE(strm, strm->state);
620 strm->state = Z_NULL;