I have my code running well. But Valgrind still shows 568 bytes as reachable. Detailed Valgrind log is here:

==5709== HEAP SUMMARY:
==5709==     in use at exit: 568 bytes in 1 blocks
==5709==   total heap usage: 367,084 allocs, 367,083 frees, 82,227,504 bytes allocated
==5709== LEAK SUMMARY:
==5709==    definitely lost: 0 bytes in 0 blocks
==5709==    indirectly lost: 0 bytes in 0 blocks
==5709==      possibly lost: 0 bytes in 0 blocks
==5709==    still reachable: 568 bytes in 1 blocks
==5709==         suppressed: 0 bytes in 0 blocks
==5709== Reachable blocks (those to which a pointer was found) are not shown.
==5709== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==5709== For counts of detected and suppressed errors, rerun with: -v
==5709== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Code with dictionary.c is here for a glance here.


568 bytes happens to be the size of a structure allocated in fopen and freed in fclose. It seems you don't call fclose on reaching EOF. I don't get that if/else at the end of load, since you can leave the for loop only if c indeed is EOF

BTW, fclose(inptr) makes no sense if inptr is NULL. It might cause a segmentation fault in that case.

  • Well, that sorts it out completely. I have submitted speller successfully. Thank you!
    – pankaj
    Oct 12 '18 at 5:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .