未验证 提交 591d64ae 编写于 作者: H Haojun Liao 提交者: GitHub

Merge pull request #12804 from taosdata/feature/3_liaohj

refactor: add assert in hash table.
......@@ -192,12 +192,15 @@ static FORCE_INLINE void doUpdateHashNode(SHashObj *pHashObj, SHashEntry *pe, SH
atomic_sub_fetch_16(&pNode->refCount, 1);
if (prev != NULL) {
prev->next = pNewNode;
ASSERT(prev->next != prev);
} else {
pe->next = pNewNode;
}
if (pNode->refCount <= 0) {
pNewNode->next = pNode->next;
ASSERT(pNewNode->next != pNewNode);
FREE_HASH_NODE(pHashObj->freeFp, pNode);
} else {
pNewNode->next = pNode;
......@@ -521,6 +524,7 @@ int32_t taosHashRemove(SHashObj *pHashObj, const void *key, size_t keyLen) {
pe->next = pNode->next;
} else {
prevNode->next = pNode->next;
ASSERT(prevNode->next != prevNode);
}
pe->num--;
......@@ -716,6 +720,7 @@ void pushfrontNodeInEntryList(SHashEntry *pEntry, SHashNode *pNode) {
pNode->next = pEntry->next;
pEntry->next = pNode;
ASSERT(pNode->next != pNode);
pEntry->num += 1;
}
......@@ -766,8 +771,13 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) {
if (pOld->refCount <= 0) {
if (prevNode) {
prevNode->next = pOld->next;
ASSERT(prevNode->next != prevNode);
} else {
pe->next = pOld->next;
SHashNode* x = pe->next;
if (x != NULL) {
ASSERT(x->next != x);
}
}
pe->num--;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册