From 649905f4ee3bc856d8188b9b18436eeff924b723 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Mon, 28 Feb 2022 05:19:38 -0500 Subject: [PATCH] TD-13747 New SQL model integration --- source/libs/nodes/src/nodesUtilFuncs.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 5d51b2e523..07ae118c01 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -101,20 +101,29 @@ SNode* nodesMakeNode(ENodeType type) { return NULL; } -static EDealRes destroyNode(SNode* pNode, void* pContext) { - switch (nodeType(pNode)) { +static EDealRes destroyNode(SNode** pNode, void* pContext) { + switch (nodeType(*pNode)) { case QUERY_NODE_VALUE: - tfree(((SValueNode*)pNode)->literal); + tfree(((SValueNode*)(*pNode))->literal); + break; + case QUERY_NODE_LOGIC_CONDITION: + nodesDestroyList(((SLogicConditionNode*)(*pNode))->pParameterList); + break; + case QUERY_NODE_FUNCTION: + nodesDestroyList(((SFunctionNode*)(*pNode))->pParameterList); + break; + case QUERY_NODE_GROUPING_SET: + nodesDestroyList(((SGroupingSetNode*)(*pNode))->pParameterList); break; default: break; } - tfree(pNode); + tfree(*pNode); return DEAL_RES_CONTINUE; } void nodesDestroyNode(SNode* pNode) { - nodesWalkNodePostOrder(pNode, destroyNode, NULL); + nodesRewriteNodePostOrder(&pNode, destroyNode, NULL); } SNodeList* nodesMakeList() { @@ -191,9 +200,9 @@ SNode* nodesListGetNode(SNodeList* pList, int32_t index) { } void nodesDestroyList(SNodeList* pList) { - SNode* node; - FOREACH(node, pList) { - nodesDestroyNode(node); + SListCell* pNext = pList->pHead; + while (NULL != pNext) { + pNext = nodesListErase(pList, pNext); } tfree(pList); } -- GitLab