Decode literal, length, and distance codes and write out the resulting literal and match bytes until either not enough input or output is available, an end-of-block is encountered, or a data error is encountered. When large enough input and output buffers are supplied to inflate(), for example, a 16K input buffer and a 64K output buffer, more than 95% of the inflate execution time i
| 46 | output space. |
| 47 | */ |
| 48 | void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) |
| 49 | { |
| 50 | struct inflate_state FAR *state; |
| 51 | z_const unsigned char FAR *in; /* local strm->next_in */ |
| 52 | z_const unsigned char FAR *last; /* have enough input while in < last */ |
| 53 | unsigned char FAR *out; /* local strm->next_out */ |
| 54 | unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ |
| 55 | unsigned char FAR *end; /* while out < end, enough space available */ |
| 56 | #ifdef INFLATE_STRICT |
| 57 | unsigned dmax; /* maximum distance from zlib header */ |
| 58 | #endif |
| 59 | unsigned wsize; /* window size or zero if not using window */ |
| 60 | unsigned whave; /* valid bytes in the window */ |
| 61 | unsigned wnext; /* window write index */ |
| 62 | unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ |
| 63 | unsigned long hold; /* local strm->hold */ |
| 64 | unsigned bits; /* local strm->bits */ |
| 65 | code const FAR *lcode; /* local strm->lencode */ |
| 66 | code const FAR *dcode; /* local strm->distcode */ |
| 67 | unsigned lmask; /* mask for first level of length codes */ |
| 68 | unsigned dmask; /* mask for first level of distance codes */ |
| 69 | code here; /* retrieved table entry */ |
| 70 | unsigned op; /* code bits, operation, extra bits, or */ |
| 71 | /* window position, window bytes to copy */ |
| 72 | unsigned len; /* match length, unused bytes */ |
| 73 | unsigned dist; /* match distance */ |
| 74 | unsigned char FAR *from; /* where to copy match from */ |
| 75 | |
| 76 | /* copy state to local variables */ |
| 77 | state = (struct inflate_state FAR *)strm->state; |
| 78 | in = strm->next_in; |
| 79 | last = in + (strm->avail_in - 5); |
| 80 | out = strm->next_out; |
| 81 | beg = out - (start - strm->avail_out); |
| 82 | end = out + (strm->avail_out - 257); |
| 83 | #ifdef INFLATE_STRICT |
| 84 | dmax = state->dmax; |
| 85 | #endif |
| 86 | wsize = state->wsize; |
| 87 | whave = state->whave; |
| 88 | wnext = state->wnext; |
| 89 | window = state->window; |
| 90 | hold = state->hold; |
| 91 | bits = state->bits; |
| 92 | lcode = state->lencode; |
| 93 | dcode = state->distcode; |
| 94 | lmask = (1U << state->lenbits) - 1; |
| 95 | dmask = (1U << state->distbits) - 1; |
| 96 | |
| 97 | /* decode literals and length/distances until end-of-block or not enough |
| 98 | input data or output space */ |
| 99 | do { |
| 100 | if (bits < 15) { |
| 101 | hold += (unsigned long)(*in++) << bits; |
| 102 | bits += 8; |
| 103 | hold += (unsigned long)(*in++) << bits; |
| 104 | bits += 8; |
| 105 | } |