[ros-diffs] [jgardou] 51019: [OPENGL32] - use well defined macro instead of weird pointer calculation - reset thread specific data on a thread detach call Fixes crash in heroes 3 and probably others

jgardou at svn.reactos.org jgardou at svn.reactos.org
Fri Mar 11 18:17:35 UTC 2011


Author: jgardou
Date: Fri Mar 11 18:17:34 2011
New Revision: 51019

URL: http://svn.reactos.org/svn/reactos?rev=51019&view=rev
Log:
[OPENGL32]
  - use well defined macro instead of weird pointer calculation
  - reset thread specific data on a thread detach call
Fixes crash in heroes 3 and probably others

Modified:
    trunk/reactos/dll/win32/opengl32/icdtable.h
    trunk/reactos/dll/win32/opengl32/opengl32.c
    trunk/reactos/dll/win32/opengl32/wgl.c

Modified: trunk/reactos/dll/win32/opengl32/icdtable.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/opengl32/icdtable.h?rev=51019&r1=51018&r2=51019&view=diff
==============================================================================
--- trunk/reactos/dll/win32/opengl32/icdtable.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/opengl32/icdtable.h [iso-8859-1] Fri Mar 11 18:17:34 2011
@@ -18,6 +18,8 @@
     PROC	dispatch_table[812]; /*!< Table containing \a num_funcs pointers to OpenGL functions */
 } ICDTable, *PICDTable;
 
+#define DISPATCH_TABLE_SIZE 812*sizeof(PROC)
+
 #endif /* OPENGL32_PRIVATE_ICDTABLE_H */
 
 /* EOF */

Modified: trunk/reactos/dll/win32/opengl32/opengl32.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/opengl32/opengl32.c?rev=51019&r1=51018&r2=51019&view=diff
==============================================================================
--- trunk/reactos/dll/win32/opengl32/opengl32.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/opengl32/opengl32.c [iso-8859-1] Fri Mar 11 18:17:34 2011
@@ -34,7 +34,7 @@
 
     dispatchTable = (PROC*)HeapAlloc( GetProcessHeap(),
                                       HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,
-                                      sizeof (((ICDTable *)(0))->dispatch_table) );
+                                      DISPATCH_TABLE_SIZE );
     if (dispatchTable == NULL)
     {
         DBGPRINT( "Error: Couldn't allocate GL dispatch table" );
@@ -84,6 +84,7 @@
                       GetLastError() );
         lpData = NULL;
     }
+    TlsSetValue( OPENGL32_tls, NULL );
 
     if (teb->glTable != NULL)
     {

Modified: trunk/reactos/dll/win32/opengl32/wgl.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/opengl32/wgl.c?rev=51019&r1=51018&r2=51019&view=diff
==============================================================================
--- trunk/reactos/dll/win32/opengl32/wgl.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/opengl32/wgl.c [iso-8859-1] Fri Mar 11 18:17:34 2011
@@ -454,13 +454,12 @@
         /* save table */
         size = sizeof (PROC) * table->num_funcs;
         memcpy( tebTable, table->dispatch_table, size );
-        memset( tebTable + table->num_funcs, 0,
-                sizeof (table->dispatch_table) - size );
+        memset( tebTable + table->num_funcs, 0, DISPATCH_TABLE_SIZE - size );
     }
     else
     {
         DBGPRINT( "Unsetting current context" );
-        memset( tebTable, 0, sizeof (table->dispatch_table) );
+        memset( tebTable, 0, DISPATCH_TABLE_SIZE );
     }
 
     /* put in empty functions as long as we dont have a fallback */




More information about the Ros-diffs mailing list