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