Use an atomic exchange to get the old global context when setting a new one

This commit is contained in:
Chris Robinson
2011-09-02 02:32:35 -07:00
parent 3a2fa18744
commit 3dfd67680c
+3 -2
View File
@@ -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)