From bb7b4f7a94e5c5c454f886ccd632565b81295e42 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 13 Jul 2020 10:04:18 +1000 Subject: [PATCH] base: use atomic load/store in reference counting Use the new atomic load and store macros for testing and setting reference count overflow. --- lib/base/heimbase.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/base/heimbase.c b/lib/base/heimbase.c index c33d909e0..351c208c7 100644 --- a/lib/base/heimbase.c +++ b/lib/base/heimbase.c @@ -91,7 +91,7 @@ heim_retain(void *ptr) if (ptr == NULL || heim_base_is_tagged(ptr)) return ptr; - if (p->ref_cnt == heim_base_atomic_integer_max) + if (heim_base_atomic_load(&p->ref_cnt) == heim_base_atomic_integer_max) return ptr; if ((heim_base_atomic_inc(&p->ref_cnt) - 1) == 0) @@ -114,7 +114,7 @@ heim_release(void *ptr) if (ptr == NULL || heim_base_is_tagged(ptr)) return; - if (p->ref_cnt == heim_base_atomic_integer_max) + if (heim_base_atomic_load(&p->ref_cnt) == heim_base_atomic_integer_max) return; old = heim_base_atomic_dec(&p->ref_cnt) + 1; @@ -156,7 +156,7 @@ void _heim_make_permanent(heim_object_t ptr) { struct heim_base *p = PTR2BASE(ptr); - p->ref_cnt = heim_base_atomic_integer_max; + heim_base_atomic_store(&p->ref_cnt, heim_base_atomic_integer_max); }