Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified libzopfli-sharp/NativeBinaries/amd64/zopfli.dll
Binary file not shown.
Binary file modified libzopfli-sharp/NativeBinaries/amd64/zopfli.exp
Binary file not shown.
Binary file modified libzopfli-sharp/NativeBinaries/amd64/zopfli.lib
Binary file not shown.
Binary file modified libzopfli-sharp/NativeBinaries/x86/zopfli.dll
Binary file not shown.
Binary file modified libzopfli-sharp/NativeBinaries/x86/zopfli.exp
Binary file not shown.
Binary file modified libzopfli-sharp/NativeBinaries/x86/zopfli.lib
Binary file not shown.
5 changes: 4 additions & 1 deletion libzopfli-sharp/Zopfli.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ public static byte[] compress(byte[] data_in, ZopfliFormat type, ZopfliOptions o
finally
{
// Free unmanaged memory
Marshal.FreeHGlobal(result);
if (Environment.Is64BitProcess)
ZopfliCompressor64.ZopfliFree(result);
else
ZopfliCompressor32.ZopfliFree(result);
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions libzopfli-sharp/ZopfliCompressor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ public class ZopfliCompressor32
/// <param name="data_out_size">This is the size of the memory block pointed to by the dynamic output array size</param>
[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);

/// <summary>
/// Frees memory allocated by the native Zopfli library.
/// </summary>
/// <param name="mem">Pointer to the unmanaged memory to free</param>
[DllImport("x86\\zopfli.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void ZopfliFree(IntPtr mem);
}

/// <summary>
Expand All @@ -43,5 +50,12 @@ public class ZopfliCompressor64
/// <param name="data_out_size">This is the size of the memory block pointed to by the dynamic output array size</param>
[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);

/// <summary>
/// Frees memory allocated by the native Zopfli library.
/// </summary>
/// <param name="mem">Pointer to the unmanaged memory to free</param>
[DllImport("amd64\\zopfli.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void ZopfliFree(IntPtr mem);
}
}