[FFmpeg-devel] [PATCH 2/2] avutil/atomic: reuse ret to avoid dereferencing twice the same value.
Clément Bœsch
u at pkh.me
Mon May 26 21:18:59 CEST 2014
---
Shouldn't change anything since ptr access is locked with the mutex, but code
looks more obvious that way to me. Maybe I'm wrong...
---
libavutil/atomic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavutil/atomic.c b/libavutil/atomic.c
index 1fa6308..b13725d 100644
--- a/libavutil/atomic.c
+++ b/libavutil/atomic.c
@@ -64,7 +64,7 @@ void *avpriv_atomic_ptr_cas(void * volatile *ptr, void *oldval, void *newval)
void *ret;
pthread_mutex_lock(&atomic_lock);
ret = *ptr;
- if (*ptr == oldval)
+ if (ret == oldval)
*ptr = newval;
pthread_mutex_unlock(&atomic_lock);
return ret;
--
1.9.3
More information about the ffmpeg-devel
mailing list