From cd83aa7005fc352ac42bcb2bb03c7b88f695ae1c Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Mon, 2 Nov 2020 11:54:55 +0100 Subject: [PATCH] delete --- cv5/a_train.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index 3f25159..fea3ef8 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -32,24 +32,16 @@ void print_train(struct car* first) { } void cancel_train(struct car* first) { - struct car* this = first; if(first == NULL){ exit(0); } if(this->next == NULL){ - this = first->next; - free(first); - this = NULL; + struct car* this = first; + first = first->next; + free(this); + first = NULL; } - else{ - /*struct car* prev = first; - while(prev->next->next != NULL){ - prev = prev->next; - } - this = prev->next; - prev->next = NULL; - free(this);*/ - + else{ cancel_train(first->next); free(first); }