This commit is contained in:
Maryna Kravtsova 2020-11-04 23:01:42 +01:00
parent 466f69ab17
commit 98ba737b3f

View File

@ -66,20 +66,20 @@ struct car* clear_train(struct car* first, const char* target) {
while(this->next != NULL){
int x = strcmp(this->value, target);
if(x == 0){
struct car* curr = first;
struct car* prev = NULL;
struct car* prev = first;
struct car* node = first->next;
if(first == this){
first = this->next;
free(this);
return first;
}
while(curr != this){
prev = curr;
curr = curr->next;
while(prev != NULL && node != NULL){
prev->next = node->next;
free(node);
prev = prev->next;
if(prev != NULL)
node = prev->next;
}
curr->next = prev->next;
this->next = NULL;
free(this);
}
this = this->next;