Example #1
0
        // bit length count table

        // bit offsets, then code stack
        internal static int inflate_trees_fixed(int[] bl, int[] bd, int[][] tl, int[][] td, ZlibCodec z)
        {
            bl[0] = InfTree.fixed_bl;
            bd[0] = InfTree.fixed_bd;
            tl[0] = InfTree.fixed_tl;
            td[0] = InfTree.fixed_td;
            return(InfTree.Z_OK);
        }
Example #2
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
            this.initWorkArea(288);
            this.hn[0] = 0;
            result     = this.huft_build(c, 0, nl, 257, InfTree.cplens, InfTree.cplext, tl, bl, hp, this.hn, this.v);
            if (result != InfTree.Z_OK || bl[0] == 0)
            {
                if (result == InfTree.Z_DATA_ERROR)
                {
                    z.Message = "oversubscribed literal/length tree";
                }
                else if (result != InfTree.Z_MEM_ERROR)
                {
                    z.Message = "incomplete literal/length tree";
                    result    = InfTree.Z_DATA_ERROR;
                }

                return(result);
            }

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

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

                return(result);
            }

            return(InfTree.Z_OK);
        }