aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-09-01 19:51:19 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-09-01 19:51:19 +0200
commit70399f1c8cae6e9ddd43cd28ecdaf17c96274c65 (patch)
treedd99f18468fe3f13e29398f8c2dc64c8049996e0
parent35fb513a0814f2d41816ef4aa1211e08e402cdf6 (diff)
Use GCC-specific atomic memory access primitives for reference counting.
-rw-r--r--bitmapped_patricia_tree.c4
1 files 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);
}
}