This commit is contained in:
Maryna Kravtsova 2020-11-05 23:29:11 +01:00
parent 2b24ea0449
commit 2a624c76de

View File

@ -33,20 +33,12 @@ void print_train(struct car* first) {
} }
void cancel_train(struct car* first) { void cancel_train(struct car* first) {
if(first == NULL){ if(first != NULL){
return; cancel_train(first->next);
} free(first);
if(first->next != NULL){
cancel_train(first->next);
first->next = NULL;
}
else if(first->next == NULL){
free(first);
} }
} }
struct car* clear_train(struct car* first, const char* target) { struct car* clear_train(struct car* first, const char* target) {
if(first == NULL){ if(first == NULL){
return 0; return 0;