[vlc-commits] atomic: prevent overflow
Quentin Chateau
git at videolan.org
Mon Mar 2 20:11:59 CET 2020
vlc | branch: master | Quentin Chateau <quentin.chateau at deepskycorp.com> | Mon Feb 24 09:33:35 2020 +0100| [50d5f881d7e3c25d2b0a69ba78cf316e1ddb8deb] | committer: Rémi Denis-Courmont
atomic: prevent overflow
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=50d5f881d7e3c25d2b0a69ba78cf316e1ddb8deb
---
include/vlc_atomic.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/vlc_atomic.h b/include/vlc_atomic.h
index 2f009fe3be..d596259e12 100644
--- a/include/vlc_atomic.h
+++ b/include/vlc_atomic.h
@@ -35,7 +35,7 @@
# include <vlc_common.h>
typedef struct vlc_atomic_rc_t {
- atomic_uint refs;
+ atomic_uintptr_t refs;
} vlc_atomic_rc_t;
/** Init the RC to 1 */
@@ -47,7 +47,7 @@ static inline void vlc_atomic_rc_init(vlc_atomic_rc_t *rc)
/** Increment the RC */
static inline void vlc_atomic_rc_inc(vlc_atomic_rc_t *rc)
{
- unsigned prev = atomic_fetch_add_explicit(&rc->refs, 1, memory_order_relaxed);
+ uintptr_t prev = atomic_fetch_add_explicit(&rc->refs, 1, memory_order_relaxed);
vlc_assert(prev);
VLC_UNUSED(prev);
}
@@ -55,7 +55,7 @@ static inline void vlc_atomic_rc_inc(vlc_atomic_rc_t *rc)
/** Decrement the RC and return true if it reaches 0 */
static inline bool vlc_atomic_rc_dec(vlc_atomic_rc_t *rc)
{
- unsigned prev = atomic_fetch_sub_explicit(&rc->refs, 1, memory_order_acq_rel);
+ uintptr_t prev = atomic_fetch_sub_explicit(&rc->refs, 1, memory_order_acq_rel);
vlc_assert(prev);
return prev == 1;
}
More information about the vlc-commits
mailing list