# HG changeset patch
# User moel.mich
# Date 1285631321 0
# Node ID 50de2faf3336ebf106c5445d75a6047de532cc1d
# Parent  7026bb2e1f7d6d146779626d0f819147ccaf1e68
Fixed a problem where the ADL Main_Memory_Alloc callback delegate could be garbage collected while still in use.

diff -r 7026bb2e1f7d -r 50de2faf3336 Hardware/ATI/ADL.cs
--- a/Hardware/ATI/ADL.cs	Fri Sep 24 21:33:55 2010 +0000
+++ b/Hardware/ATI/ADL.cs	Mon Sep 27 23:48:41 2010 +0000
@@ -267,9 +267,11 @@
 
     private delegate IntPtr ADL_Main_Memory_AllocDelegate(int size);
 
-    private static IntPtr Main_Memory_Alloc(int size) {
-      return Marshal.AllocHGlobal(size);;
-    }
+    // create a Main_Memory_Alloc delegate and keep it alive
+    private static ADL_Main_Memory_AllocDelegate Main_Memory_Alloc =
+      delegate(int size) {
+        return Marshal.AllocHGlobal(size);
+      };
 
     private static void Main_Memory_Free(IntPtr buffer) {
       if (IntPtr.Zero != buffer)