I need to fix the memory leak error for me to complete pset5. When running my code, I get:
:) dictionary.c exists :) speller compiles :) handles most basic words properly :) handles min length (1-char) words :) handles max length (45-char) words :) handles words with apostrophes properly :) spell-checking is case-insensitive :) handles substrings properly :( program is free of memory errors valgrind tests failed; rerun with --log for more information.
Valgrind says that the error is caused by line 90
node *n = malloc(sizeof(node))
running valgrind --show-leak-kinds=all --xml=yes --xml-file=/tmp/tmpp6cuc8aw -- ./speller substring/dict substring/text... checking for output "MISSPELLED WORDS\n\nca\ncats\ncaterpill\ncaterpillars\n\nWORDS MISSPELLED: 4\nWORDS IN DICTIONARY: 2\nWORDS IN TEXT: 6\n"... checking that program exited with status 0... checking for valgrind errors... 112 bytes in 2 blocks are still reachable in loss record 1 of 1: (file: dictionary.c, line: 90)
What I don't get is how would that cause an error. I've been stuck on this problem for quite a while now, and I've browsed for similar questions on this site, but I've had no luck so far. Any output or help is kindly appreciated
<Removed 03/07/2021 for academic honesty>