public static int Compress(byte[] inbuf, uint inlen, byte[] outbuf, ref uint outlen) { lock (CompressWork) { if (_Is64Bit == true) { return(Native64.NativeCompress(inbuf, inlen, outbuf, ref outlen, CompressWork)); } return(Native32.NativeCompress(inbuf, inlen, outbuf, ref outlen, CompressWork)); } }
public static ErrorCode Compress(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; lock (_CompressWork) { if (_Is64Bit == true) { result = Native64.NativeCompress(inputHandle.AddrOfPinnedObject() + inputOffset, inputCount, outputHandle.AddrOfPinnedObject() + outputOffset, ref outputCount, _CompressWork); } else { result = Native32.NativeCompress(inputHandle.AddrOfPinnedObject() + inputOffset, inputCount, outputHandle.AddrOfPinnedObject() + outputOffset, ref outputCount, _CompressWork); } } return(result); }