Example #1
0
        internal int inflate_trees_dynamic(int nl, int nd, int[] c, int[] bl, int[] bd, int[] tl, int[] td, int[] hp, ZlibCodec z)
        {
            int result;

                        // build literal/length tree
                        initWorkArea(288);
                        hn[0] = 0;
                        result = huft_build(c, 0, nl, 257, cplens, cplext, tl, bl, hp, hn, v);
                        if (result != Z_OK || bl[0] == 0)
                        {
                                if (result == Z_DATA_ERROR)
                                {
                                        z.Message = "oversubscribed literal/length tree";
                                }
                                else if (result != Z_MEM_ERROR)
                                {
                                        z.Message = "incomplete literal/length tree";
                                        result = Z_DATA_ERROR;
                                }
                                return result;
                        }

                        // build distance tree
                        initWorkArea(288);
                        result = huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, hn, v);

                        if (result != Z_OK || (bd[0] == 0 && nl > 257))
                        {
                                if (result == Z_DATA_ERROR)
                                {
                                        z.Message = "oversubscribed distance tree";
                                }
                                else if (result == Z_BUF_ERROR)
                                {
                                        z.Message = "incomplete distance tree";
                                        result = Z_DATA_ERROR;
                                }
                                else if (result != Z_MEM_ERROR)
                                {
                                        z.Message = "empty distance tree with lengths";
                                        result = Z_DATA_ERROR;
                                }
                                return result;
                        }

                        return Z_OK;
        }
Example #2
0
 internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZlibCodec z)
 {
     bl[0] = fixed_bl;
                 bd[0] = fixed_bd;
                 tl[0] = fixed_tl;
                 td[0] = fixed_td;
                 return Z_OK;
 }
Example #3
0
        internal int inflate_trees_bits(int[] c, int[] bb, int[] tb, int[] hp, ZlibCodec z)
        {
            int result;
                        initWorkArea(19);
                        hn[0] = 0;
                        result = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v);

                        if (result == Z_DATA_ERROR)
                        {
                                z.Message = "oversubscribed dynamic bit lengths tree";
                        }
                        else if (result == Z_BUF_ERROR || bb[0] == 0)
                        {
                                z.Message = "incomplete dynamic bit lengths tree";
                                result = Z_DATA_ERROR;
                        }
                        return result;
        }
Example #4
0
 private void end()
 {
     if (z == null)
         return;
     if (_wantCompress)
     {
         _z.EndDeflate();
     }
     else
     {
         _z.EndInflate();
     }
     _z = null;
 }