Plugging the memory leak

This commit is contained in:
Anton Dolozin 2025-10-28 20:46:05 +01:00
parent 315b42fc4c
commit 0f9e18cdd0

View File

@ -68,11 +68,16 @@ struct car* clear_train(struct car* first, const char* target) {
prev = temp;
temp = temp->next;
if(strcmp(temp->value, target) == 0){
struct car* next = temp->next;
prev->next = next;
temp = next;
struct car* targetNode = temp;
prev->next = temp->next;
temp = temp->next;
free(targetNode);
}
else{
prev = temp;
temp = temp->next;
}
}