-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemcheck.h
34 lines (25 loc) · 904 Bytes
/
memcheck.h
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
/*
* FILE: memcheck.h
*
* Interface to the memory leak checker.
*
*/
#ifndef MEMCHECK_H
#define MEMCHECK_H
#include <stdlib.h>
void *checked_malloc_fn(size_t size, char *filename, int lineno);
void *checked_calloc_fn(size_t nmemb, size_t size,
char *filename, int lineno);
void checked_free_fn(void *ptr, char *filename, int lineno);
void print_memory_leaks(void);
/*
* Macros which maintain the interface of the standard malloc/calloc/free
* functions. Don't include these if this file is being included into
* memcheck.c, or it will screw up the definitions of the checked functions.
*/
#ifndef MEMCHECK_C
#define malloc(n) checked_malloc_fn((n), __FILE__, __LINE__)
#define calloc(n, m) checked_calloc_fn((n), (m), __FILE__, __LINE__)
#define free(p) checked_free_fn((p), __FILE__, __LINE__)
#endif /* MEMCHECK_C */
#endif /* MEMCHECK_H */