diff --git a/src/util/src/tskiplist.c b/src/util/src/tskiplist.c index 3a474fe6c15629953dda23fc525362037cf4221a..2394adc6f33b93aa38b4daca6990fbc163c0738c 100644 --- a/src/util/src/tskiplist.c +++ b/src/util/src/tskiplist.c @@ -194,13 +194,12 @@ void *tSkipListDestroy(SSkipList *pSkipList) { pthread_rwlock_wrlock(pSkipList->lock); } - SSkipListNode *pNode = SL_GET_FORWARD_POINTER(pSkipList->pHead, 0); + if (pSkipList->keyInfo.freeNode) { + SSkipListNode *pNode = SL_GET_FORWARD_POINTER(pSkipList->pHead, 0); - while (pNode != pSkipList->pTail) { - SSkipListNode *pTemp = pNode; - pNode = SL_GET_FORWARD_POINTER(pNode, 0); - - if (pSkipList->keyInfo.freeNode) { + while (pNode != pSkipList->pTail) { + SSkipListNode *pTemp = pNode; + pNode = SL_GET_FORWARD_POINTER(pNode, 0); tfree(pTemp); } }