From 0a1321aaaee411393c27c9b4836e4190f3b7e421 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 30 Aug 2011 20:33:47 -0700 Subject: Add a limit to the UIntMap size and use it for sources and effect slots --- OpenAL32/Include/alMain.h | 3 ++- OpenAL32/alAuxEffectSlot.c | 2 -- OpenAL32/alSource.c | 9 +-------- 3 files changed, 3 insertions(+), 11 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index fe9d3331..c712a38b 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -334,11 +334,12 @@ typedef struct UIntMap { } *array; ALsizei size; ALsizei maxsize; + ALsizei limit; RWLock lock; } UIntMap; extern UIntMap TlsDestructor; -void InitUIntMap(UIntMap *map); +void InitUIntMap(UIntMap *map, ALsizei limit); void ResetUIntMap(UIntMap *map); ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value); void RemoveUIntMapKey(UIntMap *map, ALuint key); diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index 27d92949..b2411ed3 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -50,8 +50,6 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo Device = Context->Device; if(n < 0 || IsBadWritePtr((void*)effectslots, n * sizeof(ALuint))) alSetError(Context, AL_INVALID_VALUE); - else if((ALuint)n > Device->AuxiliaryEffectSlotMax - Context->EffectSlotMap.size) - alSetError(Context, AL_INVALID_VALUE); else { ALenum err; diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index e45cbcd9..2fc28e53 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -86,14 +86,7 @@ AL_API ALvoid AL_APIENTRY alGenSources(ALsizei n,ALuint *sources) err = NewThunkEntry(&source->source); if(err == AL_NO_ERROR) - { - LockContext(Context); - if(Device->MaxNoOfSources == (ALuint)Context->SourceMap.size) - err = AL_INVALID_VALUE; - else - err = InsertUIntMapEntry(&Context->SourceMap, source->source, source); - UnlockContext(Context); - } + err = InsertUIntMapEntry(&Context->SourceMap, source->source, source); if(err != AL_NO_ERROR) { FreeThunkEntry(source->source); -- cgit v1.2.3