File README added (mode: 100644) (index 0000000..689c3bd) |
|
1 |
|
1.) Introduction |
|
2 |
|
This project is a simple memory leak checker. |
|
3 |
|
It is intended for simple (small) C projects |
|
4 |
|
where memory leaks may be a concern. It is |
|
5 |
|
not intended to replace the more powerful |
|
6 |
|
debugging tools out there. Rather, it is |
|
7 |
|
intended to be an easy to use simple check. |
|
8 |
|
|
|
9 |
|
2.) Brief overview |
|
10 |
|
It works my defining macros that logs memory |
|
11 |
|
allocation, reallocation and freeing. If all |
|
12 |
|
of the memory allocated is not freed, the |
|
13 |
|
scanner will alert you of that. |
|
14 |
|
|
|
15 |
|
3). Simple Howto |
|
16 |
|
To start using this project you would add the line |
|
17 |
|
"#include <mem_check.h>" into your program and replace |
|
18 |
|
the stdlib functions as shown below. |
|
19 |
|
data = malloc(size); ---> allocate_memory(data,size); |
|
20 |
|
new = realloc(old,size); ---> realloc_memory(new, old, size); |
|
21 |
|
free(data); ---> free_memory(data); |
|
22 |
|
|
|
23 |
|
Next, add the line "init_mem_check();" |
|
24 |
|
before any memory handling function calls. |
|
25 |
|
Lastly, add the line "close_mem_check();" |
|
26 |
|
after your last memory handling call. |
|
27 |
|
|
|
28 |
|
If you recompile your program and run it you |
|
29 |
|
should see a new file mem_check.log |
|
30 |
|
|
|
31 |
|
If you want to temporarily disable the new macro's and |
|
32 |
|
reinstate the stdlib versions, then add the line |
|
33 |
|
#define MEM_CHECK 0 |
|
34 |
|
above the line |
|
35 |
|
#include <mem_check.h> |