Using valgrind

Joe Nelson joe at begriffs.com
Wed Nov 7 22:46:45 UTC 2018


I was doing a K&R exercise and noticed a place in the
code that might have a small memory leak. This section
https://github.com/begriffs/kr/blob/master/j-symbols.c#L35-L37 returns
NULL if either a structure or a string fail to be allocated.  However if
the structure succeeded and strdup failed then it would never free the
structure.

Rather than fix it and move on, I wondered if it would be a good
opportunity to learn some tooling. Maybe http://valgrind.org could
detect the error. Have any of you used Valgrind before?


More information about the Friends mailing list