Пример #1
0
        public static int Decompress(byte[] inbuf, uint inlen, byte[] outbuf, ref uint outlen)
        {
            if (_Is64Bit == true)
            {
                return(Native64.NativeDecompress(inbuf, inlen, outbuf, ref outlen));
            }

            return(Native32.NativeDecompress(inbuf, inlen, outbuf, ref outlen));
        }
Пример #2
0
        public static ErrorCode Decompress(byte[] inputBytes,
                                           int inputOffset,
                                           int inputCount,
                                           byte[] outputBytes,
                                           int outputOffset,
                                           ref int outputCount)
        {
            if (inputBytes == null)
            {
                throw new ArgumentNullException("inputBytes");
            }

            if (inputOffset < 0 || inputOffset > inputBytes.Length)
            {
                throw new ArgumentOutOfRangeException("inputOffset");
            }

            if (inputCount <= 0 || inputOffset + inputCount > inputBytes.Length)
            {
                throw new ArgumentOutOfRangeException("inputCount");
            }

            if (outputBytes == null)
            {
                throw new ArgumentNullException("outputBytes");
            }

            if (outputOffset < 0 || outputOffset > outputBytes.Length)
            {
                throw new ArgumentOutOfRangeException("outputOffset");
            }

            if (outputCount <= 0 || outputOffset + outputCount > outputBytes.Length)
            {
                throw new ArgumentOutOfRangeException("outputCount");
            }

            var outputHandle = GCHandle.Alloc(outputBytes, GCHandleType.Pinned);
            var inputHandle  = GCHandle.Alloc(inputBytes, GCHandleType.Pinned);

            ErrorCode result;

            if (_Is64Bit == true)
            {
                result = Native64.NativeDecompress(inputHandle.AddrOfPinnedObject() + inputOffset,
                                                   inputCount,
                                                   outputHandle.AddrOfPinnedObject() + outputOffset,
                                                   ref outputCount);
            }
            else
            {
                result = Native32.NativeDecompress(inputHandle.AddrOfPinnedObject() + inputOffset,
                                                   inputCount,
                                                   outputHandle.AddrOfPinnedObject() + outputOffset,
                                                   ref outputCount);
            }

            inputHandle.Free();
            outputHandle.Free();

            return(result);
        }