diff options
author | Chris Robinson <[email protected]> | 2010-03-20 21:38:05 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-03-20 21:38:05 -0700 |
commit | 99f28f25b07e28415ce58fd552dcadf2a187c3e3 (patch) | |
tree | 45f9ca387fd88b95b013b022d91b004f6ffed91c /OpenAL32 | |
parent | 27358c8ce8dcb9bc6d18c10b652784f068cb2ec2 (diff) |
Avoid calling alDelete* from alGen*
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/alAuxEffectSlot.c | 16 | ||||
-rw-r--r-- | OpenAL32/alBuffer.c | 12 | ||||
-rw-r--r-- | OpenAL32/alDatabuffer.c | 12 | ||||
-rw-r--r-- | OpenAL32/alEffect.c | 16 | ||||
-rw-r--r-- | OpenAL32/alFilter.c | 16 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 12 |
6 files changed, 70 insertions, 14 deletions
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c index bc381bf6..5c49821a 100644 --- a/OpenAL32/alAuxEffectSlot.c +++ b/OpenAL32/alAuxEffectSlot.c @@ -40,7 +40,7 @@ DECL_VERIFIER(Effect, ALeffect, effect) ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { ALCcontext *Context; - ALsizei i, j; + ALsizei i=0, j; Context = GetContextSuspended(); if(!Context) return; @@ -54,11 +54,12 @@ ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) // Check that enough memory has been allocted in the 'effectslots' array for n Effect Slots if (!IsBadWritePtr((void*)effectslots, n * sizeof(ALuint))) { + ALeffectslot *end; ALeffectslot **list = &Context->EffectSlotList; while(*list) list = &(*list)->next; - i = 0; + end = *list; while(i < n) { *list = calloc(1, sizeof(ALeffectslot)); @@ -66,7 +67,16 @@ ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) { // We must have run out or memory free(*list); *list = NULL; - alDeleteAuxiliaryEffectSlots(i, effectslots); + while(end->next) + { + ALeffectslot *temp = end->next; + end->next = temp->next; + + ALEffect_Destroy(temp->EffectState); + ALTHUNK_REMOVEENTRY(temp->effectslot); + Context->EffectSlotCount--; + free(temp); + } alSetError(Context, AL_OUT_OF_MEMORY); break; } diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index 071e56fe..eaf508af 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -120,17 +120,27 @@ AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n,ALuint *puiBuffers) // Check the pointer is valid (and points to enough memory to store Buffer Names) if (!IsBadWritePtr((void*)puiBuffers, n * sizeof(ALuint))) { + ALbuffer *end; ALbuffer **list = &device->BufferList; while(*list) list = &(*list)->next; // Create all the new Buffers + end = *list; while(i < n) { *list = calloc(1, sizeof(ALbuffer)); if(!(*list)) { - alDeleteBuffers(i, puiBuffers); + while(end->next) + { + ALbuffer *temp = end->next; + end->next = temp->next; + + ALTHUNK_REMOVEENTRY(temp->buffer); + device->BufferCount--; + free(temp); + } alSetError(Context, AL_OUT_OF_MEMORY); break; } diff --git a/OpenAL32/alDatabuffer.c b/OpenAL32/alDatabuffer.c index 1f5302e6..f13bc34e 100644 --- a/OpenAL32/alDatabuffer.c +++ b/OpenAL32/alDatabuffer.c @@ -56,17 +56,27 @@ ALvoid AL_APIENTRY alGenDatabuffersEXT(ALsizei n,ALuint *puiBuffers) * Databuffer Names) */ if(!IsBadWritePtr((void*)puiBuffers, n * sizeof(ALuint))) { + ALdatabuffer *end; ALdatabuffer **list = &device->DatabufferList; while(*list) list = &(*list)->next; /* Create all the new Databuffers */ + end = *list; while(i < n) { *list = calloc(1, sizeof(ALdatabuffer)); if(!(*list)) { - alDeleteDatabuffersEXT(i, puiBuffers); + while(end->next) + { + ALdatabuffer *temp = end->next; + end->next = temp->next; + + ALTHUNK_REMOVEENTRY(temp->databuffer); + device->DatabufferCount--; + free(temp); + } alSetError(Context, AL_OUT_OF_MEMORY); break; } diff --git a/OpenAL32/alEffect.c b/OpenAL32/alEffect.c index 7241de2c..a63ea72e 100644 --- a/OpenAL32/alEffect.c +++ b/OpenAL32/alEffect.c @@ -41,7 +41,7 @@ DECL_VERIFIER(Effect, ALeffect, effect) ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) { ALCcontext *Context; - ALsizei i; + ALsizei i=0; Context = GetContextSuspended(); if(!Context) return; @@ -53,18 +53,26 @@ ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) // Check that enough memory has been allocted in the 'effects' array for n Effects if (!IsBadWritePtr((void*)effects, n * sizeof(ALuint))) { + ALeffect *end; ALeffect **list = &device->EffectList; while(*list) list = &(*list)->next; - i = 0; + end = *list; while(i < n) { *list = calloc(1, sizeof(ALeffect)); if(!(*list)) { - // We must have run out or memory - alDeleteEffects(i, effects); + while(end->next) + { + ALeffect *temp = end->next; + end->next = temp->next; + + ALTHUNK_REMOVEENTRY(temp->effect); + device->EffectCount--; + free(temp); + } alSetError(Context, AL_OUT_OF_MEMORY); break; } diff --git a/OpenAL32/alFilter.c b/OpenAL32/alFilter.c index 52030246..1e8ada32 100644 --- a/OpenAL32/alFilter.c +++ b/OpenAL32/alFilter.c @@ -37,7 +37,7 @@ DECL_VERIFIER(Filter, ALfilter, filter) ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters) { ALCcontext *Context; - ALsizei i; + ALsizei i=0; Context = GetContextSuspended(); if(!Context) return; @@ -49,18 +49,26 @@ ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters) // Check that enough memory has been allocted in the 'filters' array for n Filters if (!IsBadWritePtr((void*)filters, n * sizeof(ALuint))) { + ALfilter *end; ALfilter **list = &device->FilterList; while(*list) list = &(*list)->next; - i = 0; + end = *list; while(i < n) { *list = calloc(1, sizeof(ALfilter)); if(!(*list)) { - // We must have run out or memory - alDeleteFilters(i, filters); + while(end->next) + { + ALfilter *temp = end->next; + end->next = temp->next; + + ALTHUNK_REMOVEENTRY(temp->filter); + device->FilterCount--; + free(temp); + } alSetError(Context, AL_OUT_OF_MEMORY); break; } diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index ca5b4e28..bae27709 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -61,17 +61,27 @@ AL_API ALvoid AL_APIENTRY alGenSources(ALsizei n,ALuint *sources) // Check that the requested number of sources can be generated if((Context->SourceCount + n) <= Device->MaxNoOfSources) { + ALsource *end; ALsource **list = &Context->SourceList; while(*list) list = &(*list)->next; // Add additional sources to the list (Source->next points to the location for the next Source structure) + end = *list; while(i < n) { *list = calloc(1, sizeof(ALsource)); if(!(*list)) { - alDeleteSources(i, sources); + while(end->next) + { + ALsource *temp = end->next; + end->next = temp->next; + + ALTHUNK_REMOVEENTRY(temp->source); + Context->SourceCount--; + free(temp); + } alSetError(Context, AL_OUT_OF_MEMORY); break; } |