int inflateInit(int w) {
		z.msg = null;
		blocks = null;

		// handle undocumented wrap option (no zlib header or check)
		wrap = 0;
		if (w < 0) {
			w = -w;
		} else if ((w & INFLATE_ANY) != 0) {
			wrap = 4;
			w &= ~INFLATE_ANY;
			if (w < 48)
				w &= 15;
		} else if ((w & ~31) != 0) { // for example, DEF_WBITS + 32
			wrap = 4; // zlib and gzip wrapped data should be accepted.
			w &= 15;
		} else {
			wrap = (w >> 4) + 1;
			if (w < 48)
				w &= 15;
		}

		if (w < 8 || w > 15) {
			inflateEnd();
			return Z_STREAM_ERROR;
		}
		if (blocks != null && wbits != w) {
			blocks.free();
			blocks = null;
		}

		// set window size
		wbits = w;

		this.blocks = new InfBlocks(z, 1 << w);

		// reset state
		inflateReset();

		return Z_OK;
	}