示例#1
0
 internal int InflateEnd()
 {
     if (blocks != null)
     {
         blocks.Free();
     }
     return(Z_OK);
 }
示例#2
0
        internal 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);
        }