From 2a624c76dec7a277dee2d9e7586e6bece846c393 Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Thu, 5 Nov 2020 23:29:11 +0100 Subject: [PATCH] clear --- cv5/a_train.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index 8e85900..34e7a84 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -33,20 +33,12 @@ void print_train(struct car* first) { } void cancel_train(struct car* first) { - if(first == NULL){ - return; - } - if(first->next != NULL){ - cancel_train(first->next); - first->next = NULL; - } - else if(first->next == NULL){ - free(first); + if(first != NULL){ + cancel_train(first->next); + free(first); } } - - struct car* clear_train(struct car* first, const char* target) { if(first == NULL){ return 0;