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;
|
||||
while(this->next->next != NULL){
|
||||
int x = strcmp(this->next->value, target);
|
||||
while(this->next != NULL){
|
||||
int x = strcmp(this->value, target);
|
||||
if(x == 0){
|
||||
struct car* prev = first;
|
||||
struct car* node = first->next;
|
||||
struct car* tmp = first;
|
||||
struct car* prev = NULL;
|
||||
if(first == this){
|
||||
first = this->next;
|
||||
free(this);
|
||||
return first;
|
||||
}
|
||||
while(prev != NULL && node != NULL){
|
||||
prev->next = node->next;
|
||||
free(node);
|
||||
prev = prev->next;
|
||||
if(prev != NULL)
|
||||
node = prev->next;
|
||||
}
|
||||
else{
|
||||
while(tmp->next != NULL){
|
||||
prev = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
free(prev->next);
|
||||
prev->next = NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
this = this->next;
|
||||
|
Loading…
Reference in New Issue
Block a user