X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu%2Furcu_ref.h;h=a422a9906fd787d1482210a5a61b6f3611b7f99c;hp=bce711619a8b77dfb5795e5aee8421964d6028ac;hb=a2e7bf9ce5de5113c7f59c380b0087e291cd603d;hpb=453629a9317adef5b96c3d55e4dcd98db680997a diff --git a/urcu/urcu_ref.h b/urcu/urcu_ref.h index bce7116..a422a99 100644 --- a/urcu/urcu_ref.h +++ b/urcu/urcu_ref.h @@ -15,7 +15,7 @@ */ #include -#include +#include struct urcu_ref { long refcount; /* ATOMIC */ @@ -33,14 +33,15 @@ static inline void urcu_ref_init(struct urcu_ref *ref) static inline void urcu_ref_get(struct urcu_ref *ref) { - long res = uatomic_add_return(&ref->refcount, 1); - assert(res != 0); + uatomic_add(&ref->refcount, 1); } static inline void urcu_ref_put(struct urcu_ref *ref, void (*release)(struct urcu_ref *)) { - if (!uatomic_sub_return(&ref->refcount, 1)) + long res = uatomic_sub_return(&ref->refcount, 1); + assert (res >= 0); + if (res == 0) release(ref); }