From c973646eae533f7ee52ac75557d469eb9646cbe0 Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Wed, 4 Nov 2020 23:17:32 +0100 Subject: [PATCH] clear --- cv5/a_train.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index 7e0a47f..a2152c2 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -73,17 +73,14 @@ struct car* clear_train(struct car* first, const char* target) { free(this); return first; } - else{ + else if(this->next->next == NULL){ while(tmp->next != NULL){ prev = tmp; tmp = tmp->next; } free(tmp); - prev->next = NULL; - - } - - + prev->next = NULL; + } } this = this->next; }