From 70399f1c8cae6e9ddd43cd28ecdaf17c96274c65 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 1 Sep 2011 19:51:19 +0200 Subject: Use GCC-specific atomic memory access primitives for reference counting. --- bitmapped_patricia_tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitmapped_patricia_tree.c b/bitmapped_patricia_tree.c index ca36271..79ac076 100644 --- a/bitmapped_patricia_tree.c +++ b/bitmapped_patricia_tree.c @@ -435,13 +435,13 @@ static unsigned int bpt_find_diverging_chunk(bpt_key_t a, bpt_key_t b) { void bpt_retain(bpt_t bpt) { if (bpt) { - bpt->refcount++; + __sync_fetch_and_add(&bpt->refcount, 1); } } void bpt_release(bpt_t bpt) { if (bpt) { - if (--(bpt->refcount) == 0) { + if (__sync_sub_and_fetch(&bpt->refcount, 1) == 0) { bpt_dealloc(bpt); } } -- cgit v1.2.3