From 79d7a7636db33ba97a57f2884546c00c0fa235a1 Mon Sep 17 00:00:00 2001 From: Maryna Kravtsova Date: Mon, 2 Nov 2020 15:10:26 +0100 Subject: [PATCH] car --- cv5/a_train.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cv5/a_train.c b/cv5/a_train.c index fc1d311..9eebf7d 100644 --- a/cv5/a_train.c +++ b/cv5/a_train.c @@ -40,15 +40,12 @@ void print_train(struct car* first) { } void cancel_train(struct car* first) { - if(!first){ - return NULL; + if(first == NULL){ + return; } - struct car* help = cancel_train(first->next); - if(first->value != NULL){ - first->next = help; - free(first); - //cancel_train(help); - //first->next = NULL; + if(first->next != NULL){ + cancel_train(first->next); + first->next = NULL; } //else if(first->next == NULL){ //free(first);