Debian Codegraph @

bwa-apache2/malloc_wrap.h

raw
1 #ifndef MALLOC_WRAP_H
2 #define MALLOC_WRAP_H
3
4 #include <stdlib.h> /* Avoid breaking the usual definitions */
5 #include <string.h>
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 void *wrap_calloc(size_t nmemb, size_t size,
12 const char *file, unsigned int line, const char *func);
13 void *wrap_malloc(size_t size,
14 const char *file, unsigned int line, const char *func);
15 void *wrap_realloc(void *ptr, size_t size,
16 const char *file, unsigned int line, const char *func);
17 char *wrap_strdup(const char *s,
18 const char *file, unsigned int line, const char *func);
19
20 #ifdef __cplusplus
21 }
22 #endif
23
24 #ifdef USE_MALLOC_WRAPPERS
25 # ifdef calloc
26 # undef calloc
27 # endif
28 # define calloc(n, s) wrap_calloc( (n), (s), __FILE__, __LINE__, __func__)
29
30 # ifdef malloc
31 # undef malloc
32 # endif
33 # define malloc(s) wrap_malloc( (s), __FILE__, __LINE__, __func__)
34
35 # ifdef realloc
36 # undef realloc
37 # endif
38 # define realloc(p, s) wrap_realloc((p), (s), __FILE__, __LINE__, __func__)
39
40 # ifdef strdup
41 # undef strdup
42 # endif
43 # define strdup(s) wrap_strdup( (s), __FILE__, __LINE__, __func__)
44
45 #endif /* USE_MALLOC_WRAPPERS */
46
47 #endif /* MALLOC_WRAP_H */