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