clear
This commit is contained in:
parent
c8beff4de8
commit
ff410acb17
@ -63,31 +63,19 @@ struct car* clear_train(struct car* first, const char* target) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct car* this = first;
|
struct car* this = first;
|
||||||
while(this->next != NULL){
|
while(this->next->next != NULL){
|
||||||
int x = strcmp(this->value, target);
|
int x = strcmp(this->next->value, target);
|
||||||
if(x == 0){
|
if(x == 0){
|
||||||
struct car* tmp = first;
|
struct car* third = this->next->next;
|
||||||
struct car* prev = first;
|
|
||||||
if(first == this){
|
if(first == this){
|
||||||
first = this->next;
|
first = this->next;
|
||||||
free(this);
|
free(this);
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
if(first->next == this){
|
|
||||||
while(tmp->next != NULL){
|
|
||||||
prev = tmp;
|
|
||||||
tmp = tmp->next;
|
|
||||||
}
|
|
||||||
if(tmp == first){
|
|
||||||
first = NULL;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
prev->next = NULL;
|
free(this->next);
|
||||||
|
this->next = third;
|
||||||
}
|
}
|
||||||
free(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
this = this->next;
|
this = this->next;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user