fix: simple hash iterate remove and clear

This commit is contained in:
Cary Xu 2022-08-27 18:04:33 +08:00
parent 4ee28bfc2c
commit 451e621a94
1 changed files with 5 additions and 5 deletions

View File

@ -294,12 +294,11 @@ int32_t tSimpleHashIterateRemove(SSHashObj *pHashObj, const void *key, size_t ke
pPrev->next = pNode->next;
}
if (*pIter == (void*)GET_SHASH_NODE_DATA(pNode)) {
if (pNode->next) {
*pIter = GET_SHASH_NODE_DATA(pNode->next);
} else {
if (*pIter == (void *)GET_SHASH_NODE_DATA(pNode)) {
if (!pPrev) {
*pIter = NULL;
++(*iter);
} else {
*pIter = pPrev;
}
}
@ -331,6 +330,7 @@ void tSimpleHashClear(SSHashObj *pHashObj) {
FREE_HASH_NODE(pNode);
pNode = pNext;
}
pHashObj->hashList[i] = NULL;
}
atomic_store_64(&pHashObj->size, 0);
}