summaryrefslogtreecommitdiff
path: root/upb/atomic.h
diff options
context:
space:
mode:
Diffstat (limited to 'upb/atomic.h')
-rw-r--r--upb/atomic.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/upb/atomic.h b/upb/atomic.h
index 53501b5..d2b2bd2 100644
--- a/upb/atomic.h
+++ b/upb/atomic.h
@@ -20,6 +20,7 @@
#define UPB_ATOMIC_H_
#include <stdbool.h>
+#include <assert.h>
#ifdef __cplusplus
extern "C" {
@@ -45,7 +46,7 @@ typedef struct {
INLINE void upb_atomic_init(upb_atomic_t *a, int val) { a->v = val; }
INLINE bool upb_atomic_ref(upb_atomic_t *a) { return a->v++ == 0; }
-INLINE bool upb_atomic_unref(upb_atomic_t *a) { return --a->v == 0; }
+INLINE bool upb_atomic_unref(upb_atomic_t *a) { assert(a->v > 0); return --a->v == 0; }
INLINE int upb_atomic_read(upb_atomic_t *a) { return a->v; }
INLINE bool upb_atomic_add(upb_atomic_t *a, int val) {
a->v += val;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback