I want to integrate into my C code a flag that is e.g. 1 if a memory leak occurs, and 0 if not. I need this sort of functionality to auto-grade student assignments in a course I am teaching. I don't need to know where the memory leak is, just whether one occurs in the runtime of the executable. For informative tracing/debugging, Valgrind is my go-to, but I am reluctant to parse Valgrind text output for grading.
I have experimented with:
mcheck.h-mtrace()requires the use of an environment variable which gets a little hairy because of my autotesting setup (and getting a group of 300 first year students to run shell commands, which they have a weird resistance to)malloc.h-mallinfo()on a memory-clean executable has the same information as when I run it for a particular memory-unclean executable