summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-09-02 02:32:35 -0700
committerChris Robinson <[email protected]>2011-09-02 02:32:35 -0700
commit3dfd67680c5d9c9b2139b7a75824ee6fc0943772 (patch)
treed931eb3efe4b3934d1938307cb797af796e517b2
parent3a2fa18744127618c5a6715ff1e24f18c9f9dd49 (diff)
Use an atomic exchange to get the old global context when setting a new one
-rw-r--r--Alc/ALc.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 5cc4a777..df2ba12c 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -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)