From 18dd6036963e35066050264a4ada790f29bb941c Mon Sep 17 00:00:00 2001 From: Vlad K Date: Tue, 9 May 2017 05:36:54 +0300 Subject: [PATCH] Fix of memory leak --- src/OpenTK/Platform/SDL2/Sdl2.cs | 4 ++++ src/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/OpenTK/Platform/SDL2/Sdl2.cs b/src/OpenTK/Platform/SDL2/Sdl2.cs index bb437eeb..96bc0994 100644 --- a/src/OpenTK/Platform/SDL2/Sdl2.cs +++ b/src/OpenTK/Platform/SDL2/Sdl2.cs @@ -139,6 +139,10 @@ namespace OpenTK.Platform.SDL2 [DllImport(lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_FreeSurface", ExactSpelling = true)] public static extern void FreeSurface(IntPtr surface); + [SuppressUnmanagedCodeSecurity] + [DllImport (lib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "SDL_free", ExactSpelling = true)] + public static extern void Free (IntPtr memblock); + #region GameContoller [SuppressUnmanagedCodeSecurity] diff --git a/src/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs b/src/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs index d75ac170..22538e69 100644 --- a/src/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs +++ b/src/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs @@ -201,6 +201,7 @@ namespace OpenTK.Platform.SDL2 if (windows.TryGetValue(ev.Drop.WindowID, out window)) { ProcessDropEvent(window, ev.Drop); + SDL.Free(ev.Drop.File); processed = true; } break; @@ -311,7 +312,7 @@ namespace OpenTK.Platform.SDL2 byte [] byteArray = new byte[length]; Marshal.Copy(ev.File, byteArray, 0, length); - string dropString = System.Text.Encoding.UTF8.GetString (byteArray); + string dropString = System.Text.Encoding.UTF8.GetString(byteArray); window.OnDrop(dropString); }