Commit 1b2279d6 authored by Akira TAGOH's avatar Akira TAGOH

thread-safe functions in fchash.c

parent 47581444
...@@ -169,13 +169,15 @@ FcHashTableAdd (FcHashTable *table, ...@@ -169,13 +169,15 @@ FcHashTableAdd (FcHashTable *table,
return !ret; return !ret;
} }
retry:
for (prev = &table->buckets[hash % FC_HASH_SIZE]; for (prev = &table->buckets[hash % FC_HASH_SIZE];
(b = *prev); prev = &(b->next)) (b = fc_atomic_ptr_get (prev)); prev = &(b->next))
{ {
if (!table->compare_func (bucket->key, key)) if (!table->compare_func (bucket->key, key))
goto destroy; goto destroy;
} }
*prev = bucket; if (!fc_atomic_ptr_cmpexch (prev, b, bucket))
goto retry;
return FcTrue; return FcTrue;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment