Lines Matching +full:no +full:- +full:fallthrough
1 /* inflate.c -- zlib decompression
2 * Copyright (C) 1995-2022 Mark Adler
10 * - First version -- complete rewrite of inflate to simplify code, avoid
16 * - Use pointers for available input and output checking in inffast.c
17 * - Remove input and output counters in inffast.c
18 * - Change inffast.c entry and loop from avail_in >= 7 to >= 6
19 * - Remove unnecessary second byte pull from length extra in inffast.c
20 * - Unroll direct copy to three copies per loop in inffast.c
23 * - Change external routine names to reduce potential conflicts
24 * - Correct filename to inffixed.h for fixed tables in inflate.c
25 * - Make hbuf[] unsigned char to match parameter type in inflate.c
26 * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)
30 * - Add comments on state->bits assertion in inffast.c
31 * - Add comments on op field in inftrees.h
32 * - Fix bug in reuse of allocated window after inflateReset()
33 * - Remove bit fields--back to byte structure for speed
34 * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths
35 * - Change post-increments to pre-increments in inflate_fast(), PPC biased?
36 * - Add compile time option, POSTINC, to use post-increments instead (Intel?)
37 * - Make MATCH copy in inflate() much faster for when inflate_fast() not used
38 * - Use local copies of stream next and avail values, as well as local bit
39 * buffer and bit count in inflate()--for speed when inflate_fast() not used
42 * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings
43 * - Move a comment on output buffer sizes from inffast.c to inflate.c
44 * - Add comments in inffast.c to introduce the inflate_fast() routine
45 * - Rearrange window copies in inflate_fast() for speed and simplification
46 * - Unroll last copy for window match in inflate_fast()
47 * - Use local copies of window variables in inflate_fast() for speed
48 * - Pull out common wnext == 0 case for speed in inflate_fast()
49 * - Make op and len in inflate_fast() unsigned for consistency
50 * - Add FAR to lcode and dcode declarations in inflate_fast()
51 * - Simplified bad distance check in inflate_fast()
52 * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new
53 * source file infback.c to provide a call-back interface to inflate for
54 * programs like gzip and unzip -- uses window as output buffer to avoid
58 * - Improved inflateBack() interface to allow the caller to provide initial
60 * - Fixed stored blocks bug in inflateBack()
63 * - Added comments in inffast.c on effectiveness of POSTINC
64 * - Typecasting all around to reduce compiler warnings
65 * - Changed loops from while (1) or do {} while (1) to for (;;), again to
67 * - Changed type of window in inflateBackInit() to unsigned char *
70 * - Changed many types to unsigned or unsigned short to avoid warnings
71 * - Added inflateCopy() function
74 * - Changed inflateBack() interface to provide separate opaque descriptors
76 * - Changed inflateBack() argument and in_func typedef to swap the length
78 * - Check next_in and next_out for Z_NULL on entry to inflate()
110 strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
112 state = (struct inflate_state FAR *)strm->state;
113 if (state == Z_NULL || state->strm != strm ||
114 state->mode < HEAD || state->mode > SYNC)
125 state = (struct inflate_state FAR *)strm->state;
126 strm->total_in = strm->total_out = state->total = 0;
127 strm->msg = Z_NULL;
128 if (state->wrap) /* to support ill-conceived Java test suite */
129 strm->adler = state->wrap & 1;
130 state->mode = HEAD;
131 state->last = 0;
132 state->havedict = 0;
133 state->flags = -1;
134 state->dmax = 32768U;
135 state->head = Z_NULL;
136 state->hold = 0;
137 state->bits = 0;
138 state->lencode = state->distcode = state->next = state->codes;
139 state->sane = 1;
140 state->back = -1;
151 state = (struct inflate_state FAR *)strm->state;
152 state->wsize = 0;
153 state->whave = 0;
154 state->wnext = 0;
167 state = (struct inflate_state FAR *)strm->state;
172 windowBits = -windowBits;
185 if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
186 ZFREE(strm, state->window);
187 state->window = Z_NULL;
191 state->wrap = wrap;
192 state->wbits = (unsigned)windowBits;
209 strm->msg = Z_NULL; /* in case we return an error */
210 if (strm->zalloc == (alloc_func)0) {
214 strm->zalloc = zcalloc;
215 strm->opaque = (voidpf)0;
218 if (strm->zfree == (free_func)0)
222 strm->zfree = zcfree;
228 strm->state = (struct internal_state FAR *)state;
229 state->strm = strm;
230 state->window = Z_NULL;
231 state->mode = HEAD; /* to pass state test in inflateReset2() */
235 strm->state = Z_NULL;
256 state = (struct inflate_state FAR *)strm->state;
258 state->hold = 0;
259 state->bits = 0;
262 if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
263 value &= (1L << bits) - 1;
264 state->hold += (unsigned)value << state->bits;
265 state->bits += (uInt)bits;
277 may not be thread-safe.
294 while (sym < 144) state->lens[sym++] = 8;
295 while (sym < 256) state->lens[sym++] = 9;
296 while (sym < 280) state->lens[sym++] = 7;
297 while (sym < 288) state->lens[sym++] = 8;
301 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
305 while (sym < 32) state->lens[sym++] = 5;
308 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
316 state->lencode = lenfix;
317 state->lenbits = 9;
318 state->distcode = distfix;
319 state->distbits = 5;
349 puts(" /* inffixed.h -- table for decoding fixed codes"); in makefixed()
405 state = (struct inflate_state FAR *)strm->state;
408 if (state->window == Z_NULL) {
409 state->window = (unsigned char FAR *)
410 ZALLOC(strm, 1U << state->wbits,
412 if (state->window == Z_NULL) return 1;
416 if (state->wsize == 0) {
417 state->wsize = 1U << state->wbits;
418 state->wnext = 0;
419 state->whave = 0;
422 /* copy state->wsize or less output bytes into the circular window */
423 if (copy >= state->wsize) {
424 zmemcpy(state->window, end - state->wsize, state->wsize);
425 state->wnext = 0;
426 state->whave = state->wsize;
429 dist = state->wsize - state->wnext;
431 zmemcpy(state->window + state->wnext, end - copy, dist);
432 copy -= dist;
434 zmemcpy(state->window, end - copy, copy);
435 state->wnext = copy;
436 state->whave = state->wsize;
439 state->wnext += dist;
440 if (state->wnext == state->wsize) state->wnext = 0;
441 if (state->whave < state->wsize) state->whave += dist;
452 (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
479 put = strm->next_out; \
480 left = strm->avail_out; \
481 next = strm->next_in; \
482 have = strm->avail_in; \
483 hold = state->hold; \
484 bits = state->bits; \
490 strm->next_out = put; \
491 strm->avail_out = left; \
492 strm->next_in = next; \
493 strm->avail_in = have; \
494 state->hold = hold; \
495 state->bits = bits; \
506 if there is no input available. */
510 have--; \
525 ((unsigned)hold & ((1U << (n)) - 1))
531 bits -= (unsigned)(n); \
538 bits -= bits & 7; \
577 if there is no input available. The decoding of variable length codes uses
579 code, and no more.
606 Progress is defined as a change in either strm->avail_in or strm->avail_out.
609 and there is no window currently, goto inf_leave will create one and copy
614 strm->next_out, given the space available and the provided input--the effect
646 if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
647 (strm->next_in == Z_NULL && strm->avail_in != 0))
650 state = (struct inflate_state FAR *)strm->state;
651 if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
657 switch (state->mode) {
659 if (state->wrap == 0) {
660 state->mode = TYPEDO;
665 if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
666 if (state->wbits == 0)
667 state->wbits = 15;
668 state->check = crc32(0L, Z_NULL, 0);
669 CRC2(state->check, hold);
671 state->mode = FLAGS;
674 if (state->head != Z_NULL)
675 state->head->done = -1;
676 if (!(state->wrap & 1) || /* check if zlib header allowed */
681 strm->msg = (char *)"incorrect header check";
682 state->mode = BAD;
686 strm->msg = (char *)"unknown compression method";
687 state->mode = BAD;
692 if (state->wbits == 0)
693 state->wbits = len;
694 if (len > 15 || len > state->wbits) {
695 strm->msg = (char *)"invalid window size";
696 state->mode = BAD;
699 state->dmax = 1U << len;
700 state->flags = 0; /* indicate zlib header */
702 strm->adler = state->check = adler32(0L, Z_NULL, 0);
703 state->mode = hold & 0x200 ? DICTID : TYPE;
709 state->flags = (int)(hold);
710 if ((state->flags & 0xff) != Z_DEFLATED) {
711 strm->msg = (char *)"unknown compression method";
712 state->mode = BAD;
715 if (state->flags & 0xe000) {
716 strm->msg = (char *)"unknown header flags set";
717 state->mode = BAD;
720 if (state->head != Z_NULL)
721 state->head->text = (int)((hold >> 8) & 1);
722 if ((state->flags & 0x0200) && (state->wrap & 4))
723 CRC2(state->check, hold);
725 state->mode = TIME;
726 /* fallthrough */
729 if (state->head != Z_NULL)
730 state->head->time = hold;
731 if ((state->flags & 0x0200) && (state->wrap & 4))
732 CRC4(state->check, hold);
734 state->mode = OS;
735 /* fallthrough */
738 if (state->head != Z_NULL) {
739 state->head->xflags = (int)(hold & 0xff);
740 state->head->os = (int)(hold >> 8);
742 if ((state->flags & 0x0200) && (state->wrap & 4))
743 CRC2(state->check, hold);
745 state->mode = EXLEN;
746 /* fallthrough */
748 if (state->flags & 0x0400) {
750 state->length = (unsigned)(hold);
751 if (state->head != Z_NULL)
752 state->head->extra_len = (unsigned)hold;
753 if ((state->flags & 0x0200) && (state->wrap & 4))
754 CRC2(state->check, hold);
757 else if (state->head != Z_NULL)
758 state->head->extra = Z_NULL;
759 state->mode = EXTRA;
760 /* fallthrough */
762 if (state->flags & 0x0400) {
763 copy = state->length;
766 if (state->head != Z_NULL &&
767 state->head->extra != Z_NULL &&
768 (len = state->head->extra_len - state->length) <
769 state->head->extra_max) {
770 zmemcpy(state->head->extra + len, next,
771 len + copy > state->head->extra_max ?
772 state->head->extra_max - len : copy);
774 if ((state->flags & 0x0200) && (state->wrap & 4))
775 state->check = crc32(state->check, next, copy);
776 have -= copy;
778 state->length -= copy;
780 if (state->length) goto inf_leave;
782 state->length = 0;
783 state->mode = NAME;
784 /* fallthrough */
786 if (state->flags & 0x0800) {
791 if (state->head != Z_NULL &&
792 state->head->name != Z_NULL &&
793 state->length < state->head->name_max)
794 state->head->name[state->length++] = (Bytef)len;
796 if ((state->flags & 0x0200) && (state->wrap & 4))
797 state->check = crc32(state->check, next, copy);
798 have -= copy;
802 else if (state->head != Z_NULL)
803 state->head->name = Z_NULL;
804 state->length = 0;
805 state->mode = COMMENT;
806 /* fallthrough */
808 if (state->flags & 0x1000) {
813 if (state->head != Z_NULL &&
814 state->head->comment != Z_NULL &&
815 state->length < state->head->comm_max)
816 state->head->comment[state->length++] = (Bytef)len;
818 if ((state->flags & 0x0200) && (state->wrap & 4))
819 state->check = crc32(state->check, next, copy);
820 have -= copy;
824 else if (state->head != Z_NULL)
825 state->head->comment = Z_NULL;
826 state->mode = HCRC;
827 /* fallthrough */
829 if (state->flags & 0x0200) {
831 if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
832 strm->msg = (char *)"header crc mismatch";
833 state->mode = BAD;
838 if (state->head != Z_NULL) {
839 state->head->hcrc = (int)((state->flags >> 9) & 1);
840 state->head->done = 1;
842 strm->adler = state->check = crc32(0L, Z_NULL, 0);
843 state->mode = TYPE;
848 strm->adler = state->check = ZSWAP32(hold);
850 state->mode = DICT;
851 /* fallthrough */
853 if (state->havedict == 0) {
857 strm->adler = state->check = adler32(0L, Z_NULL, 0);
858 state->mode = TYPE;
859 /* fallthrough */
862 /* fallthrough */
864 if (state->last) {
866 state->mode = CHECK;
870 state->last = BITS(1);
875 state->last ? " (last)" : ""));
876 state->mode = STORED;
881 state->last ? " (last)" : ""));
882 state->mode = LEN_; /* decode codes */
890 state->last ? " (last)" : ""));
891 state->mode = TABLE;
894 strm->msg = (char *)"invalid block type";
895 state->mode = BAD;
903 strm->msg = (char *)"invalid stored block lengths";
904 state->mode = BAD;
907 state->length = (unsigned)hold & 0xffff;
909 state->length));
911 state->mode = COPY_;
913 /* fallthrough */
915 state->mode = COPY;
916 /* fallthrough */
918 copy = state->length;
924 have -= copy;
926 left -= copy;
928 state->length -= copy;
932 state->mode = TYPE;
936 state->nlen = BITS(5) + 257;
938 state->ndist = BITS(5) + 1;
940 state->ncode = BITS(4) + 4;
943 if (state->nlen > 286 || state->ndist > 30) {
944 strm->msg = (char *)"too many length or distance symbols";
945 state->mode = BAD;
950 state->have = 0;
951 state->mode = LENLENS;
952 /* fallthrough */
954 while (state->have < state->ncode) {
956 state->lens[order[state->have++]] = (unsigned short)BITS(3);
959 while (state->have < 19)
960 state->lens[order[state->have++]] = 0;
961 state->next = state->codes;
962 state->lencode = (const code FAR *)(state->next);
963 state->lenbits = 7;
964 ret = inflate_table(CODES, state->lens, 19, &(state->next),
965 &(state->lenbits), state->work);
967 strm->msg = (char *)"invalid code lengths set";
968 state->mode = BAD;
972 state->have = 0;
973 state->mode = CODELENS;
974 /* fallthrough */
976 while (state->have < state->nlen + state->ndist) {
978 here = state->lencode[BITS(state->lenbits)];
984 state->lens[state->have++] = here.val;
990 if (state->have == 0) {
991 strm->msg = (char *)"invalid bit length repeat";
992 state->mode = BAD;
995 len = state->lens[state->have - 1];
1013 if (state->have + copy > state->nlen + state->ndist) {
1014 strm->msg = (char *)"invalid bit length repeat";
1015 state->mode = BAD;
1018 while (copy--)
1019 state->lens[state->have++] = (unsigned short)len;
1024 if (state->mode == BAD) break;
1026 /* check for end-of-block code (better have one) */
1027 if (state->lens[256] == 0) {
1028 strm->msg = (char *)"invalid code -- missing end-of-block";
1029 state->mode = BAD;
1033 /* build code tables -- note: do not change the lenbits or distbits
1036 state->next = state->codes;
1037 state->lencode = (const code FAR *)(state->next);
1038 state->lenbits = 9;
1039 ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
1040 &(state->lenbits), state->work);
1042 strm->msg = (char *)"invalid literal/lengths set";
1043 state->mode = BAD;
1046 state->distcode = (const code FAR *)(state->next);
1047 state->distbits = 6;
1048 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
1049 &(state->next), &(state->distbits), state->work);
1051 strm->msg = (char *)"invalid distances set";
1052 state->mode = BAD;
1056 state->mode = LEN_;
1058 /* fallthrough */
1060 state->mode = LEN;
1061 /* fallthrough */
1067 if (state->mode == TYPE)
1068 state->back = -1;
1071 state->back = 0;
1073 here = state->lencode[BITS(state->lenbits)];
1080 here = state->lencode[last.val +
1086 state->back += last.bits;
1089 state->back += here.bits;
1090 state->length = (unsigned)here.val;
1095 state->mode = LIT;
1100 state->back = -1;
1101 state->mode = TYPE;
1105 strm->msg = (char *)"invalid literal/length code";
1106 state->mode = BAD;
1109 state->extra = (unsigned)(here.op) & 15;
1110 state->mode = LENEXT;
1111 /* fallthrough */
1113 if (state->extra) {
1114 NEEDBITS(state->extra);
1115 state->length += BITS(state->extra);
1116 DROPBITS(state->extra);
1117 state->back += state->extra;
1119 Tracevv((stderr, "inflate: length %u\n", state->length));
1120 state->was = state->length;
1121 state->mode = DIST;
1122 /* fallthrough */
1125 here = state->distcode[BITS(state->distbits)];
1132 here = state->distcode[last.val +
1138 state->back += last.bits;
1141 state->back += here.bits;
1143 strm->msg = (char *)"invalid distance code";
1144 state->mode = BAD;
1147 state->offset = (unsigned)here.val;
1148 state->extra = (unsigned)(here.op) & 15;
1149 state->mode = DISTEXT;
1150 /* fallthrough */
1152 if (state->extra) {
1153 NEEDBITS(state->extra);
1154 state->offset += BITS(state->extra);
1155 DROPBITS(state->extra);
1156 state->back += state->extra;
1159 if (state->offset > state->dmax) {
1160 strm->msg = (char *)"invalid distance too far back";
1161 state->mode = BAD;
1165 Tracevv((stderr, "inflate: distance %u\n", state->offset));
1166 state->mode = MATCH;
1167 /* fallthrough */
1170 copy = out - left;
1171 if (state->offset > copy) { /* copy from window */
1172 copy = state->offset - copy;
1173 if (copy > state->whave) {
1174 if (state->sane) {
1175 strm->msg = (char *)"invalid distance too far back";
1176 state->mode = BAD;
1181 copy -= state->whave;
1182 if (copy > state->length) copy = state->length;
1184 left -= copy;
1185 state->length -= copy;
1188 } while (--copy);
1189 if (state->length == 0) state->mode = LEN;
1193 if (copy > state->wnext) {
1194 copy -= state->wnext;
1195 from = state->window + (state->wsize - copy);
1198 from = state->window + (state->wnext - copy);
1199 if (copy > state->length) copy = state->length;
1202 from = put - state->offset;
1203 copy = state->length;
1206 left -= copy;
1207 state->length -= copy;
1210 } while (--copy);
1211 if (state->length == 0) state->mode = LEN;
1215 *put++ = (unsigned char)(state->length);
1216 left--;
1217 state->mode = LEN;
1220 if (state->wrap) {
1222 out -= left;
1223 strm->total_out += out;
1224 state->total += out;
1225 if ((state->wrap & 4) && out)
1226 strm->adler = state->check =
1227 UPDATE_CHECK(state->check, put - out, out);
1229 if ((state->wrap & 4) && (
1231 state->flags ? hold :
1233 ZSWAP32(hold)) != state->check) {
1234 strm->msg = (char *)"incorrect data check";
1235 state->mode = BAD;
1242 state->mode = LENGTH;
1243 /* fallthrough */
1245 if (state->wrap && state->flags) {
1247 if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
1248 strm->msg = (char *)"incorrect length check";
1249 state->mode = BAD;
1256 state->mode = DONE;
1257 /* fallthrough */
1267 /* fallthrough */
1274 If there was no progress during the inflate() call, return a buffer
1276 Note: a memory error from inflate() is non-recoverable.
1280 if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
1281 (state->mode < CHECK || flush != Z_FINISH)))
1282 if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
1283 state->mode = MEM;
1286 in -= strm->avail_in;
1287 out -= strm->avail_out;
1288 strm->total_in += in;
1289 strm->total_out += out;
1290 state->total += out;
1291 if ((state->wrap & 4) && out)
1292 strm->adler = state->check =
1293 UPDATE_CHECK(state->check, strm->next_out - out, out);
1294 strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
1295 (state->mode == TYPE ? 128 : 0) +
1296 (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
1308 state = (struct inflate_state FAR *)strm->state;
1309 if (state->window != Z_NULL) ZFREE(strm, state->window);
1310 ZFREE(strm, strm->state);
1311 strm->state = Z_NULL;
1325 state = (struct inflate_state FAR *)strm->state;
1328 if (state->whave && dictionary != Z_NULL) {
1329 zmemcpy(dictionary, state->window + state->wnext,
1330 state->whave - state->wnext);
1331 zmemcpy(dictionary + state->whave - state->wnext,
1332 state->window, state->wnext);
1335 *dictLength = state->whave;
1350 state = (struct inflate_state FAR *)strm->state;
1351 if (state->wrap != 0 && state->mode != DICT)
1355 if (state->mode == DICT) {
1358 if (dictid != state->check)
1366 state->mode = MEM;
1369 state->havedict = 1;
1382 state = (struct inflate_state FAR *)strm->state;
1383 if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
1386 state->head = head;
1387 head->done = 0;
1392 Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
1418 got = 4 - got;
1436 state = (struct inflate_state FAR *)strm->state;
1437 if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
1440 if (state->mode != SYNC) {
1441 state->mode = SYNC;
1442 state->hold <<= state->bits & 7;
1443 state->bits -= state->bits & 7;
1445 while (state->bits >= 8) {
1446 buf[len++] = (unsigned char)(state->hold);
1447 state->hold >>= 8;
1448 state->bits -= 8;
1450 state->have = 0;
1451 syncsearch(&(state->have), buf, len);
1455 len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
1456 strm->avail_in -= len;
1457 strm->next_in += len;
1458 strm->total_in += len;
1460 /* return no joy or set up to restart inflate() on a new block */
1461 if (state->have != 4) return Z_DATA_ERROR;
1462 if (state->flags == -1)
1463 state->wrap = 0; /* if no header yet, treat as raw */
1465 state->wrap &= ~4; /* no point in computing a check value now */
1466 flags = state->flags;
1467 in = strm->total_in; out = strm->total_out;
1469 strm->total_in = in; strm->total_out = out;
1470 state->flags = flags;
1471 state->mode = TYPE;
1489 state = (struct inflate_state FAR *)strm->state;
1490 return state->mode == STORED && state->bits == 0;
1505 state = (struct inflate_state FAR *)source->state;
1512 if (state->window != Z_NULL) {
1514 ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
1524 copy->strm = dest;
1525 if (state->lencode >= state->codes &&
1526 state->lencode <= state->codes + ENOUGH - 1) {
1527 copy->lencode = copy->codes + (state->lencode - state->codes);
1528 copy->distcode = copy->codes + (state->distcode - state->codes);
1530 copy->next = copy->codes + (state->next - state->codes);
1532 wsize = 1U << state->wbits;
1533 zmemcpy(window, state->window, wsize);
1535 copy->window = window;
1536 dest->state = (struct internal_state FAR *)copy;
1547 state = (struct inflate_state FAR *)strm->state;
1549 state->sane = !subvert;
1553 state->sane = 1;
1565 state = (struct inflate_state FAR *)strm->state;
1566 if (check && state->wrap)
1567 state->wrap |= 4;
1569 state->wrap &= ~4;
1579 return -(1L << 16);
1580 state = (struct inflate_state FAR *)strm->state;
1581 return (long)(((unsigned long)((long)state->back)) << 16) +
1582 (state->mode == COPY ? state->length :
1583 (state->mode == MATCH ? state->was - state->length : 0));
1590 if (inflateStateCheck(strm)) return (unsigned long)-1;
1591 state = (struct inflate_state FAR *)strm->state;
1592 return (unsigned long)(state->next - state->codes);