Beispiel #1
0
    internal static void calc_symlen(PairsData d, int s, ref string tmp)
    {
        int s1;
        int s2;

        byte[] w = d.sympat + 3 * s;
        s2 = (w[2] << 4) | (w[1] >> 4);
        if (s2 == 0x0fff)
        {
            d.symlen[s] = 0;
        }
        else
        {
            s1 = ((w[1] & 0xf) << 8) | w[0];
            if (!tmp[s1])
            {
                GlobalMembersTbcore.calc_symlen(d, s1, ref tmp);
            }
            if (!tmp[s2])
            {
                GlobalMembersTbcore.calc_symlen(d, s2, ref tmp);
            }
            d.symlen[s] = (byte)(d.symlen[s1] + d.symlen[s2] + 1);
        }
        tmp[s] = 1;
    }
Beispiel #2
0
    internal static PairsData setup_pairs(byte[] data, ulong tb_size, ulong[] size, byte[][] next, ref byte flags, int wdl)
    {
        PairsData d;
        int       i;

        flags = data[0];
        if (data[0] & 0x80)
        {
//C++ TO C# CONVERTER TODO TASK: The memory management function 'malloc' has no equivalent in C#:
            d         = (PairsData)malloc(sizeof(PairsData));
            d.idxbits = 0;
            if (wdl != 0)
            {
                d.min_len = data[1];
            }
            else
            {
                d.min_len = 0;
            }
            next    = data + 2;
            size[0] = size[1] = size[2] = 0;
            return(d);
        }

        int blocksize       = data[1];
        int idxbits         = data[2];
        int real_num_blocks = GlobalMembersTbcore.ReadUint32(data[4]);
        int num_blocks      = real_num_blocks + (byte)(data[3]);
        int max_len         = data[8];
        int min_len         = data[9];
        int h        = max_len - min_len + 1;
        int num_syms = GlobalMembersTbcore.ReadUshort(data[10 + 2 * h]);

//C++ TO C# CONVERTER TODO TASK: The memory management function 'malloc' has no equivalent in C#:
        d           = (PairsData)malloc(sizeof(PairsData) + (h - 1) * sizeof(ulong) + num_syms);
        d.blocksize = blocksize;
        d.idxbits   = idxbits;
        d.offset    = (ushort)(data[10]);
        d.symlen    = ((byte)d) + sizeof(PairsData) + (h - 1) * sizeof(ulong);
        d.sympat    = data[12 + 2 * h];
        d.min_len   = min_len;
        next        = &data[12 + 2 * h + 3 * num_syms + (num_syms & 1)];

        ulong num_indices = (tb_size + (1UL << idxbits) - 1) >> idxbits;

        size[0] = 6UL * num_indices;
        size[1] = 2UL * num_blocks;
        size[2] = (1UL << blocksize) * real_num_blocks;

        // char tmp[num_syms];
        string tmp = new string(new char[4096]);

        for (i = 0; i < num_syms; i++)
        {
            tmp = StringFunctions.ChangeCharacter(tmp, i, 0);
        }
        for (i = 0; i < num_syms; i++)
        {
            if (!tmp[i])
            {
                GlobalMembersTbcore.calc_symlen(d, i, ref tmp);
            }
        }

        d.@base[h - 1] = 0;
        for (i = h - 2; i >= 0; i--)
        {
            d.@base[i] = (d.@base[i + 1] + GlobalMembersTbcore.ReadUshort((byte)(d.offset + i)) - GlobalMembersTbcore.ReadUshort((byte)(d.offset + i + 1))) / 2;
        }
        for (i = 0; i < h; i++)
        {
            d.@base[i] <<= 64 - (min_len + i);
        }

        d.offset -= d.min_len;

        return(d);
    }