Ionic.Zlib.InflateBlocks.SetDictionary C# (CSharp) Method

SetDictionary() private method

private SetDictionary ( byte d, int start, int n ) : void
d byte
start int
n int
return void
        internal void SetDictionary(byte[] d, int start, int n)
        {
            Array.Copy(d, start, window, 0, n);
            readAt = writeAt = n;
        }

Usage Example

Example #1
0
        internal int SetDictionary(byte[] dictionary)
        {
            int index  = 0;
            int length = dictionary.Length;

            if (mode != InflateManagerMode.DICT0)
            {
                throw new ZlibException("Stream error.");
            }

            if (Adler.Adler32(1, dictionary, 0, dictionary.Length) != _codec._Adler32)
            {
                return(ZlibConstants.Z_DATA_ERROR);
            }

            _codec._Adler32 = Adler.Adler32(0, null, 0, 0);

            if (length >= (1 << wbits))
            {
                length = (1 << wbits) - 1;
                index  = dictionary.Length - length;
            }
            blocks.SetDictionary(dictionary, index, length);
            mode = InflateManagerMode.BLOCKS;
            return(ZlibConstants.Z_OK);
        }