Mercurial > mplayer.hg
changeset 2670:d98d6651ffb1
fixed TlsAlloc
author | alex |
---|---|
date | Sun, 04 Nov 2001 02:43:25 +0000 |
parents | 476b9b3b91be |
children | 555cb027c7a7 |
files | loader/win32.c |
diffstat | 1 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/loader/win32.c Sun Nov 04 02:28:23 2001 +0000 +++ b/loader/win32.c Sun Nov 04 02:43:25 2001 +0000 @@ -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; }