-
Notifications
You must be signed in to change notification settings - Fork 2
/
malloc_wrap.h
47 lines (37 loc) · 1.16 KB
/
malloc_wrap.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef MALLOC_WRAP_H
#define MALLOC_WRAP_H
#include <stdlib.h> /* Avoid breaking the usual definitions */
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
void *wrap_calloc(size_t nmemb, size_t size,
const char *file, unsigned int line, const char *func);
void *wrap_malloc(size_t size,
const char *file, unsigned int line, const char *func);
void *wrap_realloc(void *ptr, size_t size,
const char *file, unsigned int line, const char *func);
char *wrap_strdup(const char *s,
const char *file, unsigned int line, const char *func);
#ifdef __cplusplus
}
#endif
#ifdef USE_MALLOC_WRAPPERS
# ifdef calloc
# undef calloc
# endif
# define calloc(n, s) wrap_calloc( (n), (s), __FILE__, __LINE__, __func__)
# ifdef malloc
# undef malloc
# endif
# define malloc(s) wrap_malloc( (s), __FILE__, __LINE__, __func__)
# ifdef realloc
# undef realloc
# endif
# define realloc(p, s) wrap_realloc((p), (s), __FILE__, __LINE__, __func__)
# ifdef strdup
# undef strdup
# endif
# define strdup(s) wrap_strdup( (s), __FILE__, __LINE__, __func__)
#endif /* USE_MALLOC_WRAPPERS */
#endif /* MALLOC_WRAP_H */