fchash: Fix replace

When we replace a bucket in the hashtable we have to update the
next pointer too, or we lose all the other elements that hashed to
this key.
This commit is contained in:
Alexander Larsson 2017-12-18 16:17:10 +01:00 committed by Akira TAGOH
parent 7ca28c2fed
commit 0b59a65a71
1 changed files with 2 additions and 0 deletions

View File

@ -182,6 +182,7 @@ FcHashTableAddInternal (FcHashTable *table,
{
if (replace)
{
bucket->next = b->next;
if (!fc_atomic_ptr_cmpexch (prev, b, bucket))
goto retry;
bucket = b;
@ -191,6 +192,7 @@ FcHashTableAddInternal (FcHashTable *table,
goto destroy;
}
}
bucket->next = NULL;
if (!fc_atomic_ptr_cmpexch (prev, b, bucket))
goto retry;