diff options
author | Chris Robinson <[email protected]> | 2011-06-14 07:04:08 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-06-14 07:04:08 -0700 |
commit | 5a15dc4ddf40ef547f7a776454488490c97f8d7f (patch) | |
tree | df6f022d23d9657d64ae77179087986cae2bd877 /Alc/ALc.c | |
parent | 0f782b385b177a1a5896f26acbef19ee875679d0 (diff) |
Avoid multiple list searches when destroying devices and contexts
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r-- | Alc/ALc.c | 34 |
1 files changed, 17 insertions, 17 deletions
@@ -1612,17 +1612,17 @@ ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *pDevice) ALCdevice **list; LockLists(); - if(!IsDevice(pDevice) || !pDevice->IsCaptureDevice) + list = &g_pDeviceList; + while(*list && *list != pDevice) + list = &(*list)->next; + + if(!*list || !(*list)->IsCaptureDevice) { - alcSetError(pDevice, ALC_INVALID_DEVICE); + alcSetError(*list, ALC_INVALID_DEVICE); UnlockLists(); return ALC_FALSE; } - list = &g_pDeviceList; - while(*list != pDevice) - list = &(*list)->next; - *list = (*list)->next; g_ulDeviceCount--; @@ -2187,17 +2187,17 @@ ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context) ALuint i; LockLists(); - if(!IsContext(context)) + list = &g_pContextList; + while(*list && *list != context) + list = &(*list)->next; + + if(!*list) { alcSetError(NULL, ALC_INVALID_CONTEXT); UnlockLists(); return; } - list = &g_pContextList; - while(*list != context) - list = &(*list)->next; - *list = (*list)->next; g_ulContextCount--; @@ -2693,17 +2693,17 @@ ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *pDevice) ALCdevice **list; LockLists(); - if(!IsDevice(pDevice) || pDevice->IsCaptureDevice) + list = &g_pDeviceList; + while(*list && *list != pDevice) + list = &(*list)->next; + + if(!*list || (*list)->IsCaptureDevice) { - alcSetError(pDevice, ALC_INVALID_DEVICE); + alcSetError(*list, ALC_INVALID_DEVICE); UnlockLists(); return ALC_FALSE; } - list = &g_pDeviceList; - while(*list != pDevice) - list = &(*list)->next; - *list = (*list)->next; g_ulDeviceCount--; |