-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme
53 lines (42 loc) · 1.4 KB
/
readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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.