Plugging the memory leak
This commit is contained in:
parent
315b42fc4c
commit
0f9e18cdd0
@ -68,11 +68,16 @@ struct car* clear_train(struct car* first, const char* target) {
|
|||||||
prev = temp;
|
prev = temp;
|
||||||
temp = temp->next;
|
temp = temp->next;
|
||||||
if(strcmp(temp->value, target) == 0){
|
if(strcmp(temp->value, target) == 0){
|
||||||
struct car* next = temp->next;
|
struct car* targetNode = temp;
|
||||||
prev->next = next;
|
prev->next = temp->next;
|
||||||
temp = next;
|
temp = temp->next;
|
||||||
|
free(targetNode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
prev = temp;
|
||||||
|
temp = temp->next;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user