Most of this pset5 has gone smoothly, but unload() has caused me problems. When I'm navigating down my data structure (trie) to locate a node with all NULL children, the last index has a memory address for some reason.
The example is the word aaas from the dictionary. There are no other words with characters after the 's', so all children of its node pointer are NULL as expected with the exception of the last index (children[26]) which would equate to the apostrophe character.
In debugging, I watched the load() function allocate memory for this word and an apostrophe character was definitely not allocated. It's stalling out my unload() function! Does this make sense to anyone?
Thanks in advance
int delete_NULL_children(void)
{
int notNULL_index = allNULL?(trav);
//If there are only NULL children on the node, this deletes the node
if (notNULL_index == -1)
{
node *delete_ptr = trav;
//travel back up the trie to parent node
trav = trav->parent;
free(delete_ptr);
//recur until root level node is deleted
if (root != NULL)
delete_NULL_children();
else
return 1;
}
else
{
//navigate further down our dictionary
trav = trav->children[notNULL_index];
//recur until root level node is deleted
if (root != NULL)
delete_NULL_children();
}
return 1;
}