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");
|
printf("\nNames in archive:\n");
|
||||||
printNames();
|
printNames();
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
*/
|
||||||
printf("Clearing archive ...\n");
|
printf("Clearing archive ...\n");
|
||||||
clearArchive();
|
clearArchive();
|
||||||
|
|
||||||
printf("\nNames in archive:\n");
|
printf("\nNames in archive:\n");
|
||||||
printNames();
|
printNames();
|
||||||
printf("\n");*/
|
printf("\n");
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -69,12 +69,6 @@ void printNames()
|
|||||||
printNamesRec(root);
|
printNamesRec(root);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
static void disposeElem(QueueElem *elem)
|
|
||||||
{
|
|
||||||
if(elem != NULL)
|
|
||||||
free(elem->name);
|
|
||||||
free(elem);
|
|
||||||
}
|
|
||||||
|
|
||||||
static QueueElem *removeElemRek(QueueElem *elem, const char *name)
|
static QueueElem *removeElemRek(QueueElem *elem, const char *name)
|
||||||
{
|
{
|
||||||
@ -96,19 +90,27 @@ void removeName(const char *name)
|
|||||||
{
|
{
|
||||||
head = removeElemRek(head, 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);
|
clearNodeRec(node->left);
|
||||||
disposeElem(elem);
|
clearNodeRec(node->right);
|
||||||
|
disposeNode(node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearArchive()
|
void clearArchive()
|
||||||
{
|
{
|
||||||
clearElemRek(head);
|
clearNodeRec(root);
|
||||||
head = NULL;
|
root = NULL;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
Loading…
x
Reference in New Issue
Block a user