This commit is contained in:
Maryna Kravtsova 2020-11-02 14:19:09 +01:00
parent 9b936bc616
commit 3898228630

View File

@ -43,15 +43,13 @@ void cancel_train(struct car* first) {
if(first == NULL){ if(first == NULL){
exit(0); exit(0);
} }
if(first->next == NULL){ else if(first->next == NULL){
struct car* this = first; free(first);
first = first->next; //first = NULL;
free(this);
first = NULL;
} }
else{ else{
cancel_train(first->next); cancel_train(first->next);
free(first); first->next = NULL;
} }
} }