Мой код:Valgrind показывает unfreed модуля памяти
bool check(const char* word)
{
char letter;
node* nodes = malloc(sizeof(node));
for (int i = 0; isalpha(word[i]) != 0; i++)
{
letter = tolower(word[i]);
if (i == 0)
{
if (root->children[(int)letter - 96] == NULL)
return false;
nodes = root->children[(int)letter - 96];
}
else
{
if (nodes->children[(int)letter - 96] == NULL)
{
return false;
}
nodes = nodes->children[(int)letter - 96];
}
}
if (nodes->value == 1)
return true;
else
return false;
free (&letter);
free (nodes->children);
free (&nodes->value);
free (nodes);
}
Valgrind говорит, что я не свободной переменной, созданной в строке 4, но я не понимаю, почему, как я освобождаю его в конце.
Вы не производите переменные; вы освобождаете блоки памяти. – immibis