Add solution for clear archive (bst).
This commit is contained in:
parent
93aaf59201
commit
1c76a98186
@ -28,13 +28,13 @@ int main()
|
||||
printf("\nNames in archive:\n");
|
||||
printNames();
|
||||
printf("\n");
|
||||
|
||||
*/
|
||||
printf("Clearing archive ...\n");
|
||||
clearArchive();
|
||||
|
||||
printf("\nNames in archive:\n");
|
||||
printNames();
|
||||
printf("\n");*/
|
||||
printf("\n");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@ -69,12 +69,6 @@ void printNames()
|
||||
printNamesRec(root);
|
||||
}
|
||||
/*
|
||||
static void disposeElem(QueueElem *elem)
|
||||
{
|
||||
if(elem != NULL)
|
||||
free(elem->name);
|
||||
free(elem);
|
||||
}
|
||||
|
||||
static QueueElem *removeElemRek(QueueElem *elem, const char *name)
|
||||
{
|
||||
@ -96,19 +90,27 @@ void removeName(const char *name)
|
||||
{
|
||||
head = removeElemRek(head, name);
|
||||
}
|
||||
*/
|
||||
|
||||
static void clearElemRek(QueueElem *elem)
|
||||
static void disposeNode(Node *node)
|
||||
{
|
||||
if(elem != NULL)
|
||||
if(node != NULL)
|
||||
free(node->name);
|
||||
free(node);
|
||||
}
|
||||
|
||||
static void clearNodeRec(Node *node)
|
||||
{
|
||||
if(node != NULL)
|
||||
{
|
||||
clearElemRek(elem->next);
|
||||
disposeElem(elem);
|
||||
clearNodeRec(node->left);
|
||||
clearNodeRec(node->right);
|
||||
disposeNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
void clearArchive()
|
||||
{
|
||||
clearElemRek(head);
|
||||
head = NULL;
|
||||
clearNodeRec(root);
|
||||
root = NULL;
|
||||
}
|
||||
*/
|
||||
Loading…
x
Reference in New Issue
Block a user