I have ran speller in valgrind to see if there was memory leaks and its appears that all memory allocated have been freed. But, I get many errors of type : "Conditional jump or move depends on uninitialised value(s)". In searching in the questions already asked on this board, I found that it's probably ans issue related to the initialization of my new nodes. I think the problem is when my load function check if the next node to create, isn't it yet, valgrind fail because there is no memory allocated to the "un-existing node" to create... I'm very confuse with this notion. Help would really be appreciate to solve this. There is how I initialize my root and new nodes in load function :
Global declaration in dictionary.c :
node* root = NULL;
node* current = NULL;
and in LOAD :
....
**87** root = malloc(sizeof(node)); --->> LINE 87 <<---
word_counter = 0;
int index = 0;
current = root;
// looks for word until end reached
for (int c = fgetc(inptr); c != EOF; c = fgetc(inptr))
{
// looking words one by one
if (c != '\n')
{
if (c == '\'')
{
index = 26;
if (current->children[index] == NULL)
{
current->children[index] = calloc(1, sizeof(node));
}
}
else
{
index = c - 'a';
**112** if (current->children[index] == NULL) -->> LINE 112 <<--
{
current->children[index] = calloc(1, sizeof(node));
}
}
// update current pointer to the next node
current = current->children[index];
}
else
{
current->is_word = true;
word_counter++;
current = root;
}
}
fclose(inptr);
return true;
}
finally, here transmission of valgrind :