Mleak
Library for catching memory leaks, double-frees along with invalid pointers to free() and realloc().
Install / Use
/learn @mini-rose/MleakREADME
BADGES LINES: 603 | SIZE: 28K
NAME mleak - Library for catching memory leaks, double-frees along with invalid pointers to free() and realloc().
DESCRIPTION This library is not designed to be a replacement for the address sanitizer nor Valgrind, or any similar tools. The goal is to provide a very simple to use interface for users who prefer using lightweight tools.
The main selling point is the simple to understand error
messages, which automatically show where this problem happened.
For example, leaking memory will show you where it was allocated
and a pointer for reference, like seen below.
USAGE We only need to include <mleak.h> header and link with -lmleak to our program. Example:
test.c source code:
#include <mleak.h>
int main()
{
void *p = malloc(24);
}
Could output:
Memory leaked, 24 bytes allocated in int main():
test.c
4 | {
5 | void *p = malloc(24); // => 0x603000000040
6 | }
If you called free() with a pointer from strdup or any other
function that allocates memory and is not compiled with mleak,
you will get an error about an unrecognized pointer. In order to
disable this you may use unchecked_free() instead of the regular
free().
LICENSE mleak is released under the MIT license, which grants the following permissions: - commercial use, - distibution, - modification, - private usage. For more information see the license file.
