[Mplayer-cvslog] CVS: main/loader win32.c,1.26,1.27

Alex Beregszaszi alex at mplayer.dev.hu
Sun Nov 4 03:43:46 CET 2001


Update of /cvsroot/mplayer/main/loader
In directory mplayer:/var/tmp.root/cvs-serv8285

Modified Files:
	win32.c 
Log Message:
fixed TlsAlloc

Index: win32.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/win32.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- win32.c	4 Nov 2001 00:46:12 -0000	1.26
+++ win32.c	4 Nov 2001 02:43:25 -0000	1.27
@@ -1125,13 +1125,14 @@
     int i;
     
     for (i=0; i < CRITSECS_LIST_MAX; i++)
-	if (critsecs_list[i].cs_win == cs_win)
+	if (critsecs_list[i].cs_win == cs_win && critsecs_list[i].cs_unix)
 	    return(critsecs_list[i].cs_unix);
     return(NULL);
 }
 #endif
 
-#define CRITSECS_NEWTYPE 1
+#undef CRITSECS_NEWTYPE
+//#define CRITSECS_NEWTYPE 1
 
 void WINAPI expInitializeCriticalSection(CRITICAL_SECTION* c)
 {
@@ -1153,7 +1154,13 @@
 	printf("InitializeCriticalSection(%p) - no more space in list\n", c);
 	return;
     }
-    cs = malloc(sizeof(struct CRITSECT));
+    printf("got unused space at %d\n", i);
+    cs = expmalloc(sizeof(struct CRITSECT));
+    if (!cs)
+    {
+	printf("InitializeCriticalSection(%p) - out of memory\n", c);
+	return;
+    }
     pthread_mutex_init(&cs->mutex, NULL);
     cs->locked = 0;
     critsecs_list[i].cs_win = c;
@@ -1183,6 +1190,7 @@
     dbgprintf("EnterCriticalSection(0x%x)\n",c);
     if (!cs)
     {
+        printf("entered uninitialized critisec!\n");
 	expInitializeCriticalSection(c);
 #ifdef CRITSECS_NEWTYPE
 	cs=critsecs_get_unix(c);
@@ -1240,7 +1248,7 @@
     }
      
     critsecs_list[i].cs_win = NULL;
-    free(critsecs_list[i].cs_unix);
+    expfree(critsecs_list[i].cs_unix);
     critsecs_list[i].cs_unix = NULL;
     dbgprintf("DeleteCriticalSection -> itemno=%d\n", i);
 }
@@ -1282,7 +1290,8 @@
 	g_tls=g_tls->next;
     }
     dbgprintf("TlsAlloc() => 0x%x\n", g_tls);
-    g_tls->value=0; /* XXX For Divx.dll */
+    if (g_tls)
+	g_tls->value=0; /* XXX For Divx.dll */
     return g_tls;
 }
 




More information about the MPlayer-cvslog mailing list