X-Git-Url: http://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu%2Furcu_ref.h;fp=urcu%2Furcu_ref.h;h=75620d14f576b30f38bcc4836d4c2b7e88a56594;hp=bce711619a8b77dfb5795e5aee8421964d6028ac;hb=bf27322dfd077203b5f8a58548560158dccd8c60;hpb=b4e6d540d604b2c9fc617d6d7c2c02469c97ad0f diff --git a/urcu/urcu_ref.h b/urcu/urcu_ref.h index bce7116..75620d1 100644 --- a/urcu/urcu_ref.h +++ b/urcu/urcu_ref.h @@ -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); }