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