Subject | Hash | Author | Date (UTC) |
---|---|---|---|
Fixed "multiple definitions for fp_mem_log" error when using library across multiple .c files | 923a622ea28c43c4636bbc24eb15c316993bfcd3 | Josiah Mullins | 2023-10-30 18:00:02 |
README: Updated README to reflect name change | 20b55a22dba0975f17b3e173e9a693cc36e00484 | Josiah Mullins | 2023-10-28 12:52:24 |
moved mem_check.h to memcheck.h to reflect macro name change | d75193eeb7855679bf15fd9e896cef36caae2213 | Josiah Mullins | 2023-10-23 19:34:53 |
mem_check.h: Renamed all macros to be in the format MEMCHECK_name | dfc0166e38d3fce58b03033507d32dee23ca9feb | Josiah Mullins | 2023-10-23 19:33:14 |
mem_check.h: Added support for typecasting the declarations. | 37dc1d6bdd6f4bf770d41146c6f614059b9f1d02 | Josiah Mullins | 2023-10-05 18:11:09 |
Moved mem_check.c to mem_check_scanner.c | 4a6548f5dd52c419dfa3b46b53dc8ff17f044203 | Josiah Mullins | 2023-10-05 18:04:42 |
README: Added instructions to include init and close calls in program. | 9ceea9c4ae0c169a69fc1a0840402bfc2a2843cc | Josiah Mullins | 2023-10-05 18:02:22 |
Fixed bug with allocate memory and added include guards. | 01034908e928b996abf6b92804a9f68112617af1 | Josiah_Mullins_E6440 | 2020-02-14 17:53:16 |
master: initial commit of mem_check | ede7de7550d3243f98279b5bd69eba18748105fa | Josiah_Mullins_E6440 | 2020-02-12 17:42:39 |
File | Lines added | Lines deleted |
---|---|---|
README | 8 | 4 |
memcheck.h | 6 | 1 |
File README changed (mode: 100644) (index 4cd674d..9799d8b) | |||
... | ... | new = realloc(old,size); ---> MEMTYPE_REALLOC(new,type,old,size); | |
21 | 21 | free(data); ---> MEMCHECK_FREE(data); | free(data); ---> MEMCHECK_FREE(data); |
22 | 22 | ||
23 | 23 | Next, add the line "MEMCHECK_INIT();" | Next, add the line "MEMCHECK_INIT();" |
24 | before any memory handling function calls. | ||
25 | Lastly, add the line "MEMCHECK_CLOSE();" | ||
26 | after your last memory handling call. | ||
24 | in your main function before any memory | ||
25 | handling function calls. Then, add the | ||
26 | line "MEMCHECK_CLOSE();" after your | ||
27 | last memory handling call. Lastly, | ||
28 | add the line MEMCHECK_GLOBAL_VARS; | ||
29 | with your global variables in your | ||
30 | c files (not h files). | ||
27 | 31 | ||
28 | 32 | If you recompile your program and run it you | If you recompile your program and run it you |
29 | 33 | should see a new file mem_check.log | should see a new file mem_check.log |
30 | 34 | ||
31 | If you want to temporarily disable the new macro's and | ||
35 | If you want to disable the new macro's and | ||
32 | 36 | reinstate the stdlib versions, then add the line | reinstate the stdlib versions, then add the line |
33 | 37 | #define MEM_CHECK 0 | #define MEM_CHECK 0 |
34 | 38 | above the line | above the line |
File memcheck.h changed (mode: 100644) (index 97f895d..04dd919) | |||
11 | 11 | ||
12 | 12 | #if(MEMORY_CHECK==1) | #if(MEMORY_CHECK==1) |
13 | 13 | //This is defined globally. | //This is defined globally. |
14 | FILE* fp_mem_log; | ||
14 | extern FILE* fp_mem_log; | ||
15 | 15 | ||
16 | //Place this with the global variables in your .c files | ||
17 | #define MEMCHECK_GLOBAL_VARS FILE* fp_mem_log; | ||
16 | 18 | #define MEMCHECK_MALLOC(data, type, size) {\ | #define MEMCHECK_MALLOC(data, type, size) {\ |
17 | 19 | data = (type)malloc(size);\ | data = (type)malloc(size);\ |
18 | 20 | fprintf(fp_mem_log,"a%p,0x0\n",(void*)data);\ | fprintf(fp_mem_log,"a%p,0x0\n",(void*)data);\ |
... | ... | FILE* fp_mem_log; | |
43 | 45 | } | } |
44 | 46 | ||
45 | 47 | #else | #else |
48 | |||
49 | #define MEMCHECK_GLOBAL_VARS | ||
50 | |||
46 | 51 | #define MEMCHECK_MALLOC(data, type, size) {\ | #define MEMCHECK_MALLOC(data, type, size) {\ |
47 | 52 | data = (type)malloc(size);\ | data = (type)malloc(size);\ |
48 | 53 | } | } |