diff options
author | Chris Robinson <[email protected]> | 2011-09-02 02:32:35 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-09-02 02:32:35 -0700 |
commit | 3dfd67680c5d9c9b2139b7a75824ee6fc0943772 (patch) | |
tree | d931eb3efe4b3934d1938307cb797af796e517b2 /Alc/ALc.c | |
parent | 3a2fa18744127618c5a6715ff1e24f18c9f9dd49 (diff) |
Use an atomic exchange to get the old global context when setting a new one
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r-- | Alc/ALc.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -2231,9 +2231,10 @@ ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context) // context must be a valid Context or NULL if(context == NULL || IsContext(context)) { - ALCcontext *old = GlobalContext; + ALCcontext *old; + if(context) ALCcontext_IncRef(context); - GlobalContext = context; + old = ExchangePtr((void**)&GlobalContext, context); if(old) ALCcontext_DecRef(old); if((old=pthread_getspecific(LocalContext)) != NULL) |