[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

svn path=/trunk/; revision=51019
This commit is contained in:
Jérôme Gardou 2011-03-11 18:17:34 +00:00
parent 1f0f4f62b0
commit 0cc06c7b45
3 changed files with 6 additions and 4 deletions

View file

@ -18,6 +18,8 @@ typedef struct tagICDTable
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 */

View file

@ -34,7 +34,7 @@ OPENGL32_ThreadAttach( void )
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 @@ OPENGL32_ThreadDetach( void )
GetLastError() );
lpData = NULL;
}
TlsSetValue( OPENGL32_tls, NULL );
if (teb->glTable != NULL)
{

View file

@ -454,13 +454,12 @@ ROSGL_SetContextCallBack( const ICDTable *table )
/* 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 */