aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alThunk.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-08-22 07:22:02 -0700
committerChris Robinson <[email protected]>2011-08-22 07:22:02 -0700
commitc1f435cc18df4e2597d166b8b1c8a0d4ba9b23a6 (patch)
tree49e06bfa81531efa7217a487dbea712a35af5905 /OpenAL32/alThunk.c
parent858592832f7adf39dd1983ff72ebeda75cc4dd16 (diff)
Don't use the thunk array for object lookups
Diffstat (limited to 'OpenAL32/alThunk.c')
-rw-r--r--OpenAL32/alThunk.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/OpenAL32/alThunk.c b/OpenAL32/alThunk.c
index e4e99a2c..bb843c3e 100644
--- a/OpenAL32/alThunk.c
+++ b/OpenAL32/alThunk.c
@@ -25,12 +25,8 @@
#include "alMain.h"
#include "alThunk.h"
-typedef struct {
- ALvoid *ptr;
- ALboolean InUse;
-} ThunkEntry;
-static ThunkEntry *g_ThunkArray;
+static ALboolean *g_ThunkArray;
static ALuint g_ThunkArraySize;
static CRITICAL_SECTION g_ThunkLock;
@@ -39,7 +35,7 @@ void alThunkInit(void)
{
InitializeCriticalSection(&g_ThunkLock);
g_ThunkArraySize = 1;
- g_ThunkArray = calloc(1, g_ThunkArraySize * sizeof(ThunkEntry));
+ g_ThunkArray = calloc(1, g_ThunkArraySize * sizeof(*g_ThunkArray));
}
void alThunkExit(void)
@@ -50,7 +46,7 @@ void alThunkExit(void)
DeleteCriticalSection(&g_ThunkLock);
}
-ALenum alThunkAddEntry(ALvoid *ptr, ALuint *idx)
+ALenum alThunkNewEntry(ALuint *idx)
{
ALuint index;
@@ -58,28 +54,27 @@ ALenum alThunkAddEntry(ALvoid *ptr, ALuint *idx)
for(index = 0;index < g_ThunkArraySize;index++)
{
- if(g_ThunkArray[index].InUse == AL_FALSE)
+ if(g_ThunkArray[index] == AL_FALSE)
break;
}
if(index == g_ThunkArraySize)
{
- ThunkEntry *NewList;
+ ALboolean *NewList;
- NewList = realloc(g_ThunkArray, g_ThunkArraySize*2 * sizeof(ThunkEntry));
+ NewList = realloc(g_ThunkArray, g_ThunkArraySize*2 * sizeof(*g_ThunkArray));
if(!NewList)
{
LeaveCriticalSection(&g_ThunkLock);
ERR("Realloc failed to increase to %u enties!\n", g_ThunkArraySize*2);
return AL_OUT_OF_MEMORY;
}
- memset(&NewList[g_ThunkArraySize], 0, g_ThunkArraySize*sizeof(ThunkEntry));
+ memset(&NewList[g_ThunkArraySize], 0, g_ThunkArraySize*sizeof(*g_ThunkArray));
g_ThunkArraySize *= 2;
g_ThunkArray = NewList;
}
- g_ThunkArray[index].ptr = ptr;
- g_ThunkArray[index].InUse = AL_TRUE;
+ g_ThunkArray[index] = AL_TRUE;
*idx = index+1;
LeaveCriticalSection(&g_ThunkLock);
@@ -92,21 +87,7 @@ void alThunkRemoveEntry(ALuint index)
EnterCriticalSection(&g_ThunkLock);
if(index > 0 && index <= g_ThunkArraySize)
- g_ThunkArray[index-1].InUse = AL_FALSE;
+ g_ThunkArray[index-1] = AL_FALSE;
LeaveCriticalSection(&g_ThunkLock);
}
-
-ALvoid *alThunkLookupEntry(ALuint index)
-{
- ALvoid *ptr = NULL;
-
- EnterCriticalSection(&g_ThunkLock);
-
- if(index > 0 && index <= g_ThunkArraySize)
- ptr = g_ThunkArray[index-1].ptr;
-
- LeaveCriticalSection(&g_ThunkLock);
-
- return ptr;
-}