clear
This commit is contained in:
parent
5dc075a476
commit
ee01429d40
@ -64,17 +64,20 @@ struct car* clear_train(struct car* first, const char* target) {
|
||||
while(first != NULL){
|
||||
int x = strcmp(this->value, target);
|
||||
if(x == 0){
|
||||
struct car* prev = this;
|
||||
struct car* node = this->next;
|
||||
while(prev != NULL && node != NULL){
|
||||
prev->next = node->next;
|
||||
free(node);
|
||||
prev = prev->next;
|
||||
if(prev != NULL){
|
||||
node = prev->next;
|
||||
struct car* curr = first;
|
||||
struct car* prev = NULL;
|
||||
if(first == this){
|
||||
first = this->next;
|
||||
free(this);
|
||||
return 0;
|
||||
}
|
||||
while(curr != this){
|
||||
prev = curr;
|
||||
curr = curr->next;
|
||||
|
||||
}
|
||||
prev->next = curr->next;
|
||||
free(this);
|
||||
}
|
||||
this = this->next;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user