diff options
author | Chris Robinson <[email protected]> | 2008-07-11 09:12:11 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2008-07-11 09:12:11 -0700 |
commit | 97d3a45aff582242a9e5229c1e170f45ac96e0d9 (patch) | |
tree | 23920261f18dff973850a37037ed4d97ec7cdc21 /OpenAL32/alBuffer.c | |
parent | 9e9ff44b176578035be146f89c5a06258cb6a019 (diff) |
Don't check the number of objects being deleted with the number currently allocated
Since apps can validly delete buffer 0, and delete the same source/buffer multiple times in a single call
Diffstat (limited to 'OpenAL32/alBuffer.c')
-rw-r--r-- | OpenAL32/alBuffer.c | 76 |
1 files changed, 36 insertions, 40 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index 84f29508..8934f878 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -142,63 +142,59 @@ ALAPI ALvoid ALAPIENTRY alDeleteBuffers(ALsizei n, const ALuint *puiBuffers) // Check we are actually Deleting some Buffers if (n >= 0) { - if ((ALuint)n <= g_uiBufferCount) + // Check that all the buffers are valid and can actually be deleted + for (i = 0; i < n; i++) { - // Check that all the buffers are valid and can actually be deleted - for (i = 0; i < n; i++) + // Check for valid Buffer ID (can be NULL buffer) + if (alIsBuffer(puiBuffers[i])) { - // Check for valid Buffer ID (can be NULL buffer) - if (alIsBuffer(puiBuffers[i])) + // If not the NULL buffer, check that the reference count is 0 + ALBuf = ((ALbuffer *)ALTHUNK_LOOKUPENTRY(puiBuffers[i])); + if (ALBuf) { - // If not the NULL buffer, check that the reference count is 0 - ALBuf = ((ALbuffer *)ALTHUNK_LOOKUPENTRY(puiBuffers[i])); - if (ALBuf) + if (ALBuf->refcount != 0) { - if (ALBuf->refcount != 0) - { - // Buffer still in use, cannot be deleted - alSetError(AL_INVALID_OPERATION); - bFailed = AL_TRUE; - } + // Buffer still in use, cannot be deleted + alSetError(AL_INVALID_OPERATION); + bFailed = AL_TRUE; } } - else - { - // Invalid Buffer - alSetError(AL_INVALID_NAME); - bFailed = AL_TRUE; - } } + else + { + // Invalid Buffer + alSetError(AL_INVALID_NAME); + bFailed = AL_TRUE; + } + } - // If all the Buffers were valid (and have Reference Counts of 0), then we can delete them - if (!bFailed) + // If all the Buffers were valid (and have Reference Counts of 0), then we can delete them + if (!bFailed) + { + for (i = 0; i < n; i++) { - for (i = 0; i < n; i++) + if (puiBuffers[i] && alIsBuffer(puiBuffers[i])) { + ALbuffer **list = &g_pBuffers; + ALBuf=((ALbuffer *)ALTHUNK_LOOKUPENTRY(puiBuffers[i])); - if (ALBuf) - { - ALbuffer **list = &g_pBuffers; - while(*list && *list != ALBuf) - list = &(*list)->next; + while(*list && *list != ALBuf) + list = &(*list)->next; - if(*list) - *list = (*list)->next; + if(*list) + *list = (*list)->next; - // Release the memory used to store audio data - free(ALBuf->data); + // Release the memory used to store audio data + free(ALBuf->data); - // Release buffer structure - ALTHUNK_REMOVEENTRY(puiBuffers[i]); - memset(ALBuf, 0, sizeof(ALbuffer)); - g_uiBufferCount--; - free(ALBuf); - } + // Release buffer structure + ALTHUNK_REMOVEENTRY(puiBuffers[i]); + memset(ALBuf, 0, sizeof(ALbuffer)); + g_uiBufferCount--; + free(ALBuf); } } } - else - alSetError(AL_INVALID_NAME); } else alSetError(AL_INVALID_VALUE); |