This commit is contained in:
Maryna Kravtsova 2020-11-03 18:10:14 +01:00
parent 9d3a3489bb
commit dbd2844ed5

View File

@ -56,6 +56,7 @@ struct car* clear_train(struct car* first, const char* target) {
int result = strcmp(first->value, target); int result = strcmp(first->value, target);
if(result == 0){ if(result == 0){
free(first); free(first);
free(first->value);
return 0; return 0;
} }
} }
@ -67,6 +68,7 @@ struct car* clear_train(struct car* first, const char* target) {
struct car* temp = this->next; struct car* temp = this->next;
strcpy(this->value,temp->value); strcpy(this->value,temp->value);
free(temp); free(temp);
free(temp->value);
return 0; return 0;
} }
this = this->next; this = this->next;