static void destroyNodes(BST_T *o, Node_T *n) { if (n == o->guard) return; if (n->left) destroyNodes(o, n->left); if (n->right) destroyNodes(o, n->right); free(n); }
void LinkedList<NodeType>::resetList() { destroyNodes(); firstNode = NULL; lastNode = NULL; nodeCount = 0; return; }
void BST_destroy(BST_T **p) { assert(p && *p && (*p)->type == TYPE); BST_T *o = *p; destroyNodes(o, o->root); free(o->guard); free(o); *p = 0; }
int main(int argc, char* argv[]) { tsClient client; client.numNodes = 5; createConfig(client.nodes,client.indexMap,NUM_NODES,client.nodeController); readConfig(client.nodes,client.numNodes); client.clientSetup(); client.startConnection(); writeConfig(client.nodes,client.numNodes,client.indexMap); destroyNodes(client.nodes); return 0; }
void test_container::TC_01_01() { #define NODENUM 6 HQTreeNode* pnodes = createNodes(NODENUM, 0); CPPUNIT_ASSERT(NULL != pnodes); assembleTree0(pnodes); checkSubtree0(pnodes, __FUNCTION__); deassembleTree(pnodes, __FUNCTION__); destroyNodes(pnodes, NODENUM); #undef NODENUM }
void destroyNodes(trieNodePointer root) { int childrenCount = 0; for (int i=0; i<36; i++) { if (root->children[i] != NULL) childrenCount++; } if (childrenCount > 0) { for (int i=0; i<36; i++) { if (root->children[i] != NULL) { destroyNodes(root->children[i]); } } } free(root); root = NULL; }
void test_container::TC_01_04() { #define NODENUM 12 HQTreeNode* pnodes = createNodes(NODENUM, 0); CPPUNIT_ASSERT(NULL != pnodes); HQTreeNode* ptree1 = pnodes; HQTreeNode* ptree2 = pnodes + 6; assembleTree1(ptree1); checkSubtree1(ptree1, __FUNCTION__); assembleTree1(ptree2); checkSubtree1(ptree2, __FUNCTION__); ptree2->Attach(ptree1 + 0, ptree1 + 3); test_nodes nodes[] = { { ptree1 + 0, NULL, ptree1 + 2, NULL, NULL, NULL, ptree1 + 2, ptree1 + 1 }, { ptree1 + 1, ptree1 + 0, NULL, ptree1 + 4, NULL, ptree1 + 3, NULL, NULL }, { ptree1 + 2, ptree1 + 0, ptree2 + 0, ptree1 + 0, ptree2 + 0, NULL, NULL, NULL }, { ptree1 + 3, ptree1 + 0, ptree1 + 5, ptree2 + 1, ptree1 + 1, ptree2 + 0, ptree1 + 5, ptree1 + 4 }, { ptree1 + 4, ptree1 + 3, ptree1 + 1, ptree1 + 5, NULL, ptree1 + 5, NULL, NULL }, { ptree1 + 5, ptree1 + 3, ptree1 + 4, ptree1 + 3, ptree1 + 4, NULL, NULL, NULL }, { ptree2 + 0, ptree1 + 0, ptree2 + 2, ptree1 + 2, ptree1 + 3, ptree1 + 2, ptree2 + 2, ptree2 + 1 }, { ptree2 + 1, ptree2 + 0, ptree1 + 3, ptree2 + 4, NULL, ptree2 + 3, NULL, NULL }, { ptree2 + 2, ptree2 + 0, ptree2 + 3, ptree2 + 0, ptree2 + 3, NULL, NULL, NULL }, { ptree2 + 3, ptree2 + 0, ptree2 + 5, ptree2 + 2, ptree2 + 1, ptree2 + 2, ptree2 + 5, ptree2 + 4 }, { ptree2 + 4, ptree2 + 3, ptree2 + 1, ptree2 + 5, NULL, ptree2 + 5, NULL, NULL }, { ptree2 + 5, ptree2 + 3, ptree2 + 4, ptree2 + 3, ptree2 + 4, NULL, NULL, NULL }, }; check_nodelist(&(nodes[0]), sizeof(nodes) / sizeof(test_nodes), __FUNCTION__); deassembleTree(ptree2, __FUNCTION__); deassembleTree(ptree1, __FUNCTION__); destroyNodes(pnodes, NODENUM); #undef NODENUM }
LinkedList<NodeType>::~LinkedList() { destroyNodes(); }
void destroy() { destroyFiles(ROOT); destroyNodes(ROOT); }