cannam@128: /* infback9.c -- inflate deflate64 data using a call-back interface cannam@128: * Copyright (C) 1995-2008 Mark Adler cannam@128: * For conditions of distribution and use, see copyright notice in zlib.h cannam@128: */ cannam@128: cannam@128: #include "zutil.h" cannam@128: #include "infback9.h" cannam@128: #include "inftree9.h" cannam@128: #include "inflate9.h" cannam@128: cannam@128: #define WSIZE 65536UL cannam@128: cannam@128: /* cannam@128: strm provides memory allocation functions in zalloc and zfree, or cannam@128: Z_NULL to use the library memory allocation functions. cannam@128: cannam@128: window is a user-supplied window and output buffer that is 64K bytes. cannam@128: */ cannam@128: int ZEXPORT inflateBack9Init_(strm, window, version, stream_size) cannam@128: z_stream FAR *strm; cannam@128: unsigned char FAR *window; cannam@128: const char *version; cannam@128: int stream_size; cannam@128: { cannam@128: struct inflate_state FAR *state; cannam@128: cannam@128: if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || cannam@128: stream_size != (int)(sizeof(z_stream))) cannam@128: return Z_VERSION_ERROR; cannam@128: if (strm == Z_NULL || window == Z_NULL) cannam@128: return Z_STREAM_ERROR; cannam@128: strm->msg = Z_NULL; /* in case we return an error */ cannam@128: if (strm->zalloc == (alloc_func)0) { cannam@128: strm->zalloc = zcalloc; cannam@128: strm->opaque = (voidpf)0; cannam@128: } cannam@128: if (strm->zfree == (free_func)0) strm->zfree = zcfree; cannam@128: state = (struct inflate_state FAR *)ZALLOC(strm, 1, cannam@128: sizeof(struct inflate_state)); cannam@128: if (state == Z_NULL) return Z_MEM_ERROR; cannam@128: Tracev((stderr, "inflate: allocated\n")); cannam@128: strm->state = (voidpf)state; cannam@128: state->window = window; cannam@128: return Z_OK; cannam@128: } cannam@128: cannam@128: /* cannam@128: Build and output length and distance decoding tables for fixed code cannam@128: decoding. cannam@128: */ cannam@128: #ifdef MAKEFIXED cannam@128: #include cannam@128: cannam@128: void makefixed9(void) cannam@128: { cannam@128: unsigned sym, bits, low, size; cannam@128: code *next, *lenfix, *distfix; cannam@128: struct inflate_state state; cannam@128: code fixed[544]; cannam@128: cannam@128: /* literal/length table */ cannam@128: sym = 0; cannam@128: while (sym < 144) state.lens[sym++] = 8; cannam@128: while (sym < 256) state.lens[sym++] = 9; cannam@128: while (sym < 280) state.lens[sym++] = 7; cannam@128: while (sym < 288) state.lens[sym++] = 8; cannam@128: next = fixed; cannam@128: lenfix = next; cannam@128: bits = 9; cannam@128: inflate_table9(LENS, state.lens, 288, &(next), &(bits), state.work); cannam@128: cannam@128: /* distance table */ cannam@128: sym = 0; cannam@128: while (sym < 32) state.lens[sym++] = 5; cannam@128: distfix = next; cannam@128: bits = 5; cannam@128: inflate_table9(DISTS, state.lens, 32, &(next), &(bits), state.work); cannam@128: cannam@128: /* write tables */ cannam@128: puts(" /* inffix9.h -- table for decoding deflate64 fixed codes"); cannam@128: puts(" * Generated automatically by makefixed9()."); cannam@128: puts(" */"); cannam@128: puts(""); cannam@128: puts(" /* WARNING: this file should *not* be used by applications."); cannam@128: puts(" It is part of the implementation of this library and is"); cannam@128: puts(" subject to change. Applications should only use zlib.h."); cannam@128: puts(" */"); cannam@128: puts(""); cannam@128: size = 1U << 9; cannam@128: printf(" static const code lenfix[%u] = {", size); cannam@128: low = 0; cannam@128: for (;;) { cannam@128: if ((low % 6) == 0) printf("\n "); cannam@128: printf("{%u,%u,%d}", lenfix[low].op, lenfix[low].bits, cannam@128: lenfix[low].val); cannam@128: if (++low == size) break; cannam@128: putchar(','); cannam@128: } cannam@128: puts("\n };"); cannam@128: size = 1U << 5; cannam@128: printf("\n static const code distfix[%u] = {", size); cannam@128: low = 0; cannam@128: for (;;) { cannam@128: if ((low % 5) == 0) printf("\n "); cannam@128: printf("{%u,%u,%d}", distfix[low].op, distfix[low].bits, cannam@128: distfix[low].val); cannam@128: if (++low == size) break; cannam@128: putchar(','); cannam@128: } cannam@128: puts("\n };"); cannam@128: } cannam@128: #endif /* MAKEFIXED */ cannam@128: cannam@128: /* Macros for inflateBack(): */ cannam@128: cannam@128: /* Clear the input bit accumulator */ cannam@128: #define INITBITS() \ cannam@128: do { \ cannam@128: hold = 0; \ cannam@128: bits = 0; \ cannam@128: } while (0) cannam@128: cannam@128: /* Assure that some input is available. If input is requested, but denied, cannam@128: then return a Z_BUF_ERROR from inflateBack(). */ cannam@128: #define PULL() \ cannam@128: do { \ cannam@128: if (have == 0) { \ cannam@128: have = in(in_desc, &next); \ cannam@128: if (have == 0) { \ cannam@128: next = Z_NULL; \ cannam@128: ret = Z_BUF_ERROR; \ cannam@128: goto inf_leave; \ cannam@128: } \ cannam@128: } \ cannam@128: } while (0) cannam@128: cannam@128: /* Get a byte of input into the bit accumulator, or return from inflateBack() cannam@128: with an error if there is no input available. */ cannam@128: #define PULLBYTE() \ cannam@128: do { \ cannam@128: PULL(); \ cannam@128: have--; \ cannam@128: hold += (unsigned long)(*next++) << bits; \ cannam@128: bits += 8; \ cannam@128: } while (0) cannam@128: cannam@128: /* Assure that there are at least n bits in the bit accumulator. If there is cannam@128: not enough available input to do that, then return from inflateBack() with cannam@128: an error. */ cannam@128: #define NEEDBITS(n) \ cannam@128: do { \ cannam@128: while (bits < (unsigned)(n)) \ cannam@128: PULLBYTE(); \ cannam@128: } while (0) cannam@128: cannam@128: /* Return the low n bits of the bit accumulator (n <= 16) */ cannam@128: #define BITS(n) \ cannam@128: ((unsigned)hold & ((1U << (n)) - 1)) cannam@128: cannam@128: /* Remove n bits from the bit accumulator */ cannam@128: #define DROPBITS(n) \ cannam@128: do { \ cannam@128: hold >>= (n); \ cannam@128: bits -= (unsigned)(n); \ cannam@128: } while (0) cannam@128: cannam@128: /* Remove zero to seven bits as needed to go to a byte boundary */ cannam@128: #define BYTEBITS() \ cannam@128: do { \ cannam@128: hold >>= bits & 7; \ cannam@128: bits -= bits & 7; \ cannam@128: } while (0) cannam@128: cannam@128: /* Assure that some output space is available, by writing out the window cannam@128: if it's full. If the write fails, return from inflateBack() with a cannam@128: Z_BUF_ERROR. */ cannam@128: #define ROOM() \ cannam@128: do { \ cannam@128: if (left == 0) { \ cannam@128: put = window; \ cannam@128: left = WSIZE; \ cannam@128: wrap = 1; \ cannam@128: if (out(out_desc, put, (unsigned)left)) { \ cannam@128: ret = Z_BUF_ERROR; \ cannam@128: goto inf_leave; \ cannam@128: } \ cannam@128: } \ cannam@128: } while (0) cannam@128: cannam@128: /* cannam@128: strm provides the memory allocation functions and window buffer on input, cannam@128: and provides information on the unused input on return. For Z_DATA_ERROR cannam@128: returns, strm will also provide an error message. cannam@128: cannam@128: in() and out() are the call-back input and output functions. When cannam@128: inflateBack() needs more input, it calls in(). When inflateBack() has cannam@128: filled the window with output, or when it completes with data in the cannam@128: window, it calls out() to write out the data. The application must not cannam@128: change the provided input until in() is called again or inflateBack() cannam@128: returns. The application must not change the window/output buffer until cannam@128: inflateBack() returns. cannam@128: cannam@128: in() and out() are called with a descriptor parameter provided in the cannam@128: inflateBack() call. This parameter can be a structure that provides the cannam@128: information required to do the read or write, as well as accumulated cannam@128: information on the input and output such as totals and check values. cannam@128: cannam@128: in() should return zero on failure. out() should return non-zero on cannam@128: failure. If either in() or out() fails, than inflateBack() returns a cannam@128: Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it cannam@128: was in() or out() that caused in the error. Otherwise, inflateBack() cannam@128: returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format cannam@128: error, or Z_MEM_ERROR if it could not allocate memory for the state. cannam@128: inflateBack() can also return Z_STREAM_ERROR if the input parameters cannam@128: are not correct, i.e. strm is Z_NULL or the state was not initialized. cannam@128: */ cannam@128: int ZEXPORT inflateBack9(strm, in, in_desc, out, out_desc) cannam@128: z_stream FAR *strm; cannam@128: in_func in; cannam@128: void FAR *in_desc; cannam@128: out_func out; cannam@128: void FAR *out_desc; cannam@128: { cannam@128: struct inflate_state FAR *state; cannam@128: z_const unsigned char FAR *next; /* next input */ cannam@128: unsigned char FAR *put; /* next output */ cannam@128: unsigned have; /* available input */ cannam@128: unsigned long left; /* available output */ cannam@128: inflate_mode mode; /* current inflate mode */ cannam@128: int lastblock; /* true if processing last block */ cannam@128: int wrap; /* true if the window has wrapped */ cannam@128: unsigned char FAR *window; /* allocated sliding window, if needed */ cannam@128: unsigned long hold; /* bit buffer */ cannam@128: unsigned bits; /* bits in bit buffer */ cannam@128: unsigned extra; /* extra bits needed */ cannam@128: unsigned long length; /* literal or length of data to copy */ cannam@128: unsigned long offset; /* distance back to copy string from */ cannam@128: unsigned long copy; /* number of stored or match bytes to copy */ cannam@128: unsigned char FAR *from; /* where to copy match bytes from */ cannam@128: code const FAR *lencode; /* starting table for length/literal codes */ cannam@128: code const FAR *distcode; /* starting table for distance codes */ cannam@128: unsigned lenbits; /* index bits for lencode */ cannam@128: unsigned distbits; /* index bits for distcode */ cannam@128: code here; /* current decoding table entry */ cannam@128: code last; /* parent table entry */ cannam@128: unsigned len; /* length to copy for repeats, bits to drop */ cannam@128: int ret; /* return code */ cannam@128: static const unsigned short order[19] = /* permutation of code lengths */ cannam@128: {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; cannam@128: #include "inffix9.h" cannam@128: cannam@128: /* Check that the strm exists and that the state was initialized */ cannam@128: if (strm == Z_NULL || strm->state == Z_NULL) cannam@128: return Z_STREAM_ERROR; cannam@128: state = (struct inflate_state FAR *)strm->state; cannam@128: cannam@128: /* Reset the state */ cannam@128: strm->msg = Z_NULL; cannam@128: mode = TYPE; cannam@128: lastblock = 0; cannam@128: wrap = 0; cannam@128: window = state->window; cannam@128: next = strm->next_in; cannam@128: have = next != Z_NULL ? strm->avail_in : 0; cannam@128: hold = 0; cannam@128: bits = 0; cannam@128: put = window; cannam@128: left = WSIZE; cannam@128: lencode = Z_NULL; cannam@128: distcode = Z_NULL; cannam@128: cannam@128: /* Inflate until end of block marked as last */ cannam@128: for (;;) cannam@128: switch (mode) { cannam@128: case TYPE: cannam@128: /* determine and dispatch block type */ cannam@128: if (lastblock) { cannam@128: BYTEBITS(); cannam@128: mode = DONE; cannam@128: break; cannam@128: } cannam@128: NEEDBITS(3); cannam@128: lastblock = BITS(1); cannam@128: DROPBITS(1); cannam@128: switch (BITS(2)) { cannam@128: case 0: /* stored block */ cannam@128: Tracev((stderr, "inflate: stored block%s\n", cannam@128: lastblock ? " (last)" : "")); cannam@128: mode = STORED; cannam@128: break; cannam@128: case 1: /* fixed block */ cannam@128: lencode = lenfix; cannam@128: lenbits = 9; cannam@128: distcode = distfix; cannam@128: distbits = 5; cannam@128: Tracev((stderr, "inflate: fixed codes block%s\n", cannam@128: lastblock ? " (last)" : "")); cannam@128: mode = LEN; /* decode codes */ cannam@128: break; cannam@128: case 2: /* dynamic block */ cannam@128: Tracev((stderr, "inflate: dynamic codes block%s\n", cannam@128: lastblock ? " (last)" : "")); cannam@128: mode = TABLE; cannam@128: break; cannam@128: case 3: cannam@128: strm->msg = (char *)"invalid block type"; cannam@128: mode = BAD; cannam@128: } cannam@128: DROPBITS(2); cannam@128: break; cannam@128: cannam@128: case STORED: cannam@128: /* get and verify stored block length */ cannam@128: BYTEBITS(); /* go to byte boundary */ cannam@128: NEEDBITS(32); cannam@128: if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) { cannam@128: strm->msg = (char *)"invalid stored block lengths"; cannam@128: mode = BAD; cannam@128: break; cannam@128: } cannam@128: length = (unsigned)hold & 0xffff; cannam@128: Tracev((stderr, "inflate: stored length %lu\n", cannam@128: length)); cannam@128: INITBITS(); cannam@128: cannam@128: /* copy stored block from input to output */ cannam@128: while (length != 0) { cannam@128: copy = length; cannam@128: PULL(); cannam@128: ROOM(); cannam@128: if (copy > have) copy = have; cannam@128: if (copy > left) copy = left; cannam@128: zmemcpy(put, next, copy); cannam@128: have -= copy; cannam@128: next += copy; cannam@128: left -= copy; cannam@128: put += copy; cannam@128: length -= copy; cannam@128: } cannam@128: Tracev((stderr, "inflate: stored end\n")); cannam@128: mode = TYPE; cannam@128: break; cannam@128: cannam@128: case TABLE: cannam@128: /* get dynamic table entries descriptor */ cannam@128: NEEDBITS(14); cannam@128: state->nlen = BITS(5) + 257; cannam@128: DROPBITS(5); cannam@128: state->ndist = BITS(5) + 1; cannam@128: DROPBITS(5); cannam@128: state->ncode = BITS(4) + 4; cannam@128: DROPBITS(4); cannam@128: if (state->nlen > 286) { cannam@128: strm->msg = (char *)"too many length symbols"; cannam@128: mode = BAD; cannam@128: break; cannam@128: } cannam@128: Tracev((stderr, "inflate: table sizes ok\n")); cannam@128: cannam@128: /* get code length code lengths (not a typo) */ cannam@128: state->have = 0; cannam@128: while (state->have < state->ncode) { cannam@128: NEEDBITS(3); cannam@128: state->lens[order[state->have++]] = (unsigned short)BITS(3); cannam@128: DROPBITS(3); cannam@128: } cannam@128: while (state->have < 19) cannam@128: state->lens[order[state->have++]] = 0; cannam@128: state->next = state->codes; cannam@128: lencode = (code const FAR *)(state->next); cannam@128: lenbits = 7; cannam@128: ret = inflate_table9(CODES, state->lens, 19, &(state->next), cannam@128: &(lenbits), state->work); cannam@128: if (ret) { cannam@128: strm->msg = (char *)"invalid code lengths set"; cannam@128: mode = BAD; cannam@128: break; cannam@128: } cannam@128: Tracev((stderr, "inflate: code lengths ok\n")); cannam@128: cannam@128: /* get length and distance code code lengths */ cannam@128: state->have = 0; cannam@128: while (state->have < state->nlen + state->ndist) { cannam@128: for (;;) { cannam@128: here = lencode[BITS(lenbits)]; cannam@128: if ((unsigned)(here.bits) <= bits) break; cannam@128: PULLBYTE(); cannam@128: } cannam@128: if (here.val < 16) { cannam@128: NEEDBITS(here.bits); cannam@128: DROPBITS(here.bits); cannam@128: state->lens[state->have++] = here.val; cannam@128: } cannam@128: else { cannam@128: if (here.val == 16) { cannam@128: NEEDBITS(here.bits + 2); cannam@128: DROPBITS(here.bits); cannam@128: if (state->have == 0) { cannam@128: strm->msg = (char *)"invalid bit length repeat"; cannam@128: mode = BAD; cannam@128: break; cannam@128: } cannam@128: len = (unsigned)(state->lens[state->have - 1]); cannam@128: copy = 3 + BITS(2); cannam@128: DROPBITS(2); cannam@128: } cannam@128: else if (here.val == 17) { cannam@128: NEEDBITS(here.bits + 3); cannam@128: DROPBITS(here.bits); cannam@128: len = 0; cannam@128: copy = 3 + BITS(3); cannam@128: DROPBITS(3); cannam@128: } cannam@128: else { cannam@128: NEEDBITS(here.bits + 7); cannam@128: DROPBITS(here.bits); cannam@128: len = 0; cannam@128: copy = 11 + BITS(7); cannam@128: DROPBITS(7); cannam@128: } cannam@128: if (state->have + copy > state->nlen + state->ndist) { cannam@128: strm->msg = (char *)"invalid bit length repeat"; cannam@128: mode = BAD; cannam@128: break; cannam@128: } cannam@128: while (copy--) cannam@128: state->lens[state->have++] = (unsigned short)len; cannam@128: } cannam@128: } cannam@128: cannam@128: /* handle error breaks in while */ cannam@128: if (mode == BAD) break; cannam@128: cannam@128: /* check for end-of-block code (better have one) */ cannam@128: if (state->lens[256] == 0) { cannam@128: strm->msg = (char *)"invalid code -- missing end-of-block"; cannam@128: mode = BAD; cannam@128: break; cannam@128: } cannam@128: cannam@128: /* build code tables -- note: do not change the lenbits or distbits cannam@128: values here (9 and 6) without reading the comments in inftree9.h cannam@128: concerning the ENOUGH constants, which depend on those values */ cannam@128: state->next = state->codes; cannam@128: lencode = (code const FAR *)(state->next); cannam@128: lenbits = 9; cannam@128: ret = inflate_table9(LENS, state->lens, state->nlen, cannam@128: &(state->next), &(lenbits), state->work); cannam@128: if (ret) { cannam@128: strm->msg = (char *)"invalid literal/lengths set"; cannam@128: mode = BAD; cannam@128: break; cannam@128: } cannam@128: distcode = (code const FAR *)(state->next); cannam@128: distbits = 6; cannam@128: ret = inflate_table9(DISTS, state->lens + state->nlen, cannam@128: state->ndist, &(state->next), &(distbits), cannam@128: state->work); cannam@128: if (ret) { cannam@128: strm->msg = (char *)"invalid distances set"; cannam@128: mode = BAD; cannam@128: break; cannam@128: } cannam@128: Tracev((stderr, "inflate: codes ok\n")); cannam@128: mode = LEN; cannam@128: cannam@128: case LEN: cannam@128: /* get a literal, length, or end-of-block code */ cannam@128: for (;;) { cannam@128: here = lencode[BITS(lenbits)]; cannam@128: if ((unsigned)(here.bits) <= bits) break; cannam@128: PULLBYTE(); cannam@128: } cannam@128: if (here.op && (here.op & 0xf0) == 0) { cannam@128: last = here; cannam@128: for (;;) { cannam@128: here = lencode[last.val + cannam@128: (BITS(last.bits + last.op) >> last.bits)]; cannam@128: if ((unsigned)(last.bits + here.bits) <= bits) break; cannam@128: PULLBYTE(); cannam@128: } cannam@128: DROPBITS(last.bits); cannam@128: } cannam@128: DROPBITS(here.bits); cannam@128: length = (unsigned)here.val; cannam@128: cannam@128: /* process literal */ cannam@128: if (here.op == 0) { cannam@128: Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? cannam@128: "inflate: literal '%c'\n" : cannam@128: "inflate: literal 0x%02x\n", here.val)); cannam@128: ROOM(); cannam@128: *put++ = (unsigned char)(length); cannam@128: left--; cannam@128: mode = LEN; cannam@128: break; cannam@128: } cannam@128: cannam@128: /* process end of block */ cannam@128: if (here.op & 32) { cannam@128: Tracevv((stderr, "inflate: end of block\n")); cannam@128: mode = TYPE; cannam@128: break; cannam@128: } cannam@128: cannam@128: /* invalid code */ cannam@128: if (here.op & 64) { cannam@128: strm->msg = (char *)"invalid literal/length code"; cannam@128: mode = BAD; cannam@128: break; cannam@128: } cannam@128: cannam@128: /* length code -- get extra bits, if any */ cannam@128: extra = (unsigned)(here.op) & 31; cannam@128: if (extra != 0) { cannam@128: NEEDBITS(extra); cannam@128: length += BITS(extra); cannam@128: DROPBITS(extra); cannam@128: } cannam@128: Tracevv((stderr, "inflate: length %lu\n", length)); cannam@128: cannam@128: /* get distance code */ cannam@128: for (;;) { cannam@128: here = distcode[BITS(distbits)]; cannam@128: if ((unsigned)(here.bits) <= bits) break; cannam@128: PULLBYTE(); cannam@128: } cannam@128: if ((here.op & 0xf0) == 0) { cannam@128: last = here; cannam@128: for (;;) { cannam@128: here = distcode[last.val + cannam@128: (BITS(last.bits + last.op) >> last.bits)]; cannam@128: if ((unsigned)(last.bits + here.bits) <= bits) break; cannam@128: PULLBYTE(); cannam@128: } cannam@128: DROPBITS(last.bits); cannam@128: } cannam@128: DROPBITS(here.bits); cannam@128: if (here.op & 64) { cannam@128: strm->msg = (char *)"invalid distance code"; cannam@128: mode = BAD; cannam@128: break; cannam@128: } cannam@128: offset = (unsigned)here.val; cannam@128: cannam@128: /* get distance extra bits, if any */ cannam@128: extra = (unsigned)(here.op) & 15; cannam@128: if (extra != 0) { cannam@128: NEEDBITS(extra); cannam@128: offset += BITS(extra); cannam@128: DROPBITS(extra); cannam@128: } cannam@128: if (offset > WSIZE - (wrap ? 0: left)) { cannam@128: strm->msg = (char *)"invalid distance too far back"; cannam@128: mode = BAD; cannam@128: break; cannam@128: } cannam@128: Tracevv((stderr, "inflate: distance %lu\n", offset)); cannam@128: cannam@128: /* copy match from window to output */ cannam@128: do { cannam@128: ROOM(); cannam@128: copy = WSIZE - offset; cannam@128: if (copy < left) { cannam@128: from = put + copy; cannam@128: copy = left - copy; cannam@128: } cannam@128: else { cannam@128: from = put - offset; cannam@128: copy = left; cannam@128: } cannam@128: if (copy > length) copy = length; cannam@128: length -= copy; cannam@128: left -= copy; cannam@128: do { cannam@128: *put++ = *from++; cannam@128: } while (--copy); cannam@128: } while (length != 0); cannam@128: break; cannam@128: cannam@128: case DONE: cannam@128: /* inflate stream terminated properly -- write leftover output */ cannam@128: ret = Z_STREAM_END; cannam@128: if (left < WSIZE) { cannam@128: if (out(out_desc, window, (unsigned)(WSIZE - left))) cannam@128: ret = Z_BUF_ERROR; cannam@128: } cannam@128: goto inf_leave; cannam@128: cannam@128: case BAD: cannam@128: ret = Z_DATA_ERROR; cannam@128: goto inf_leave; cannam@128: cannam@128: default: /* can't happen, but makes compilers happy */ cannam@128: ret = Z_STREAM_ERROR; cannam@128: goto inf_leave; cannam@128: } cannam@128: cannam@128: /* Return unused input */ cannam@128: inf_leave: cannam@128: strm->next_in = next; cannam@128: strm->avail_in = have; cannam@128: return ret; cannam@128: } cannam@128: cannam@128: int ZEXPORT inflateBack9End(strm) cannam@128: z_stream FAR *strm; cannam@128: { cannam@128: if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) cannam@128: return Z_STREAM_ERROR; cannam@128: ZFREE(strm, strm->state); cannam@128: strm->state = Z_NULL; cannam@128: Tracev((stderr, "inflate: end\n")); cannam@128: return Z_OK; cannam@128: }