Fix of memory leak
authorVlad K <vperus@gmail.com>
Tue, 9 May 2017 02:36:54 +0000 (05:36 +0300)
committerVlad K <vperus@gmail.com>
Fri, 16 Jun 2017 19:07:11 +0000 (22:07 +0300)
src/OpenTK/Platform/SDL2/Sdl2.cs
src/OpenTK/Platform/SDL2/Sdl2NativeWindow.cs

index bb437ee..96bc099 100644 (file)
@@ -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]
index d75ac17..22538e6 100644 (file)
@@ -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);
         }