我有一个LZ4 c实现的dll,我想调用它。
LZ4_compress_default(const char* source,char* dest,int sourceLength,int maxdestLength);
从C#代码中的函数。该函数将源数组压缩到目标数组中。如何实现?
我的C#代码:
DllImport(@"CXX.dll", CharSet = CharSet.Ansi, SetLastError = true,
CallingConvention = CallingConvention.Cdecl)]
internal static extern int LZ4_compress_default(
[MarshalAs(UnmanagedType.LPArray)] char[] source, out byte[] dest,
int sourceSize, int maxDestSize);
byte[] result= new byte[maxSize];
int x = LZ4_compress_default(array, out result, size, maxSize);