提交 699451e6 编写于 作者: Y Yifan Hao

Hash table cleanup [6/n]

Fix a memory leak bug introduced in [5/n].
上级 6a71b8ea
...@@ -584,8 +584,9 @@ void taosHashCondTraverse(SHashObj *pHashObj, bool (*fp)(void *, void *), void * ...@@ -584,8 +584,9 @@ void taosHashCondTraverse(SHashObj *pHashObj, bool (*fp)(void *, void *), void *
} }
pEntry->num -= 1; pEntry->num -= 1;
atomic_sub_fetch_64(&pHashObj->size, 1); atomic_sub_fetch_64(&pHashObj->size, 1);
pNode = pNode->next; SHashNode *next = pNode->next;
FREE_HASH_NODE(pHashObj, pNode); FREE_HASH_NODE(pHashObj, pNode);
pNode = next;
} }
} }
...@@ -609,7 +610,7 @@ void taosHashClear(SHashObj *pHashObj) { ...@@ -609,7 +610,7 @@ void taosHashClear(SHashObj *pHashObj) {
for (int32_t i = 0; i < pHashObj->capacity; ++i) { for (int32_t i = 0; i < pHashObj->capacity; ++i) {
SHashEntry *pEntry = pHashObj->hashList[i]; SHashEntry *pEntry = pHashObj->hashList[i];
if (pEntry->num == 0) { if (pEntry->num == 0) {
assert(pEntry->next == 0); assert(pEntry->next == NULL);
continue; continue;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册