This tool helps to locate and address memory management and heap corruption
issues. Although not as sophisticated or as powerful as valgrind, it often
catches issues valgrind misses.
How to use:
1. Drop the memcheck.c and memcheck.h into your project
2. #include memcheck.h as the LAST include in your project you want to test
2.1 Include it in each 'C' file you would like to test
3. Compile and run your program, you should get a file called .memlog in
your executables working directory.
4. Run check.py .memlog and look at the output
The "oldptr" field is usually all "0"s unless on a realloc where it contains
the old ptr.
A free of NULL is considered an error, but a realloc of an old ptr of NULL is allowed.
I threw this together in a hurry, so it could use some cleaning up and better documentation.
Also libc fprintf is thread safe, do we need the locks? The locks are currently used to prevent another thread from making a malloc request while a thread is
sleeping on brk to try and keep the logs in chronological order. Maybe timestamping is a better idea.