From 0d5f0521140f4983b4ca9992c88ce5f14e3409be Mon Sep 17 00:00:00 2001 From: drivehappy Date: Sat, 19 May 2018 12:48:46 -0700 Subject: [PATCH] Fixing incorrect marshaling of C# class. Classes are already references, therefore the 'ref' keyword is incorrectly applied here. --- libzopfli-sharp/Zopfli.cs | 4 ++-- libzopfli-sharp/ZopfliCompressor.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libzopfli-sharp/Zopfli.cs b/libzopfli-sharp/Zopfli.cs index 4f43bfb..600846d 100644 --- a/libzopfli-sharp/Zopfli.cs +++ b/libzopfli-sharp/Zopfli.cs @@ -53,9 +53,9 @@ public static byte[] compress(byte[] data_in, ZopfliFormat type, ZopfliOptions o // Compress the data via native methods if (Environment.Is64BitProcess) - ZopfliCompressor64.ZopfliCompress(ref options, type, data_in, data_in.Length, ref result, ref result_size); + ZopfliCompressor64.ZopfliCompress(options, type, data_in, data_in.Length, ref result, ref result_size); else - ZopfliCompressor32.ZopfliCompress(ref options, type, data_in, data_in.Length, ref result, ref result_size); + ZopfliCompressor32.ZopfliCompress(options, type, data_in, data_in.Length, ref result, ref result_size); // Copy data back to managed memory and return return NativeUtilities.GetDataFromUnmanagedMemory(result, (int)result_size); diff --git a/libzopfli-sharp/ZopfliCompressor.cs b/libzopfli-sharp/ZopfliCompressor.cs index 52b07f4..de27f7b 100644 --- a/libzopfli-sharp/ZopfliCompressor.cs +++ b/libzopfli-sharp/ZopfliCompressor.cs @@ -24,7 +24,7 @@ public class ZopfliCompressor32 /// Pointer to the dynamic output array to which the result is appended /// This is the size of the memory block pointed to by the dynamic output array size [DllImport("x86\\zopfli.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern void ZopfliCompress(ref ZopfliOptions options, ZopfliFormat output_type, byte[] data, int data_size, ref IntPtr data_out, ref UIntPtr data_out_size); + public static extern void ZopfliCompress(ZopfliOptions options, ZopfliFormat output_type, byte[] data, int data_size, ref IntPtr data_out, ref UIntPtr data_out_size); } /// @@ -42,6 +42,6 @@ public class ZopfliCompressor64 /// Pointer to the dynamic output array to which the result is appended /// This is the size of the memory block pointed to by the dynamic output array size [DllImport("amd64\\zopfli.dll", CallingConvention = CallingConvention.Cdecl)] - public static extern void ZopfliCompress(ref ZopfliOptions options, ZopfliFormat output_type, byte[] data, int data_size, ref IntPtr data_out, ref UIntPtr data_out_size); + public static extern void ZopfliCompress(ZopfliOptions options, ZopfliFormat output_type, byte[] data, int data_size, ref IntPtr data_out, ref UIntPtr data_out_size); } }