Commit 71fd7207 authored by Zhao Zhili's avatar Zhao Zhili Committed by James Almer

avutil/buffer: use appropriate atomic operations

No functional changes. ref/unref vs add/sub is symmetrical.
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 964eb754
...@@ -116,7 +116,7 @@ static void buffer_replace(AVBufferRef **dst, AVBufferRef **src) ...@@ -116,7 +116,7 @@ static void buffer_replace(AVBufferRef **dst, AVBufferRef **src)
} else } else
av_freep(dst); av_freep(dst);
if (atomic_fetch_add_explicit(&b->refcount, -1, memory_order_acq_rel) == 1) { if (atomic_fetch_sub_explicit(&b->refcount, 1, memory_order_acq_rel) == 1) {
b->free(b->opaque, b->data); b->free(b->opaque, b->data);
av_freep(&b); av_freep(&b);
} }
...@@ -281,7 +281,7 @@ void av_buffer_pool_uninit(AVBufferPool **ppool) ...@@ -281,7 +281,7 @@ void av_buffer_pool_uninit(AVBufferPool **ppool)
pool = *ppool; pool = *ppool;
*ppool = NULL; *ppool = NULL;
if (atomic_fetch_add_explicit(&pool->refcount, -1, memory_order_acq_rel) == 1) if (atomic_fetch_sub_explicit(&pool->refcount, 1, memory_order_acq_rel) == 1)
buffer_pool_free(pool); buffer_pool_free(pool);
} }
...@@ -298,7 +298,7 @@ static void pool_release_buffer(void *opaque, uint8_t *data) ...@@ -298,7 +298,7 @@ static void pool_release_buffer(void *opaque, uint8_t *data)
pool->pool = buf; pool->pool = buf;
ff_mutex_unlock(&pool->mutex); ff_mutex_unlock(&pool->mutex);
if (atomic_fetch_add_explicit(&pool->refcount, -1, memory_order_acq_rel) == 1) if (atomic_fetch_sub_explicit(&pool->refcount, 1, memory_order_acq_rel) == 1)
buffer_pool_free(pool); buffer_pool_free(pool);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment