-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
dmalloc.h.4
186 lines (168 loc) · 5.32 KB
/
dmalloc.h.4
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#ifdef __cplusplus
}
#endif
/*
* alloc macros to provide for memory FILE/LINE debugging information.
*/
#ifndef DMALLOC_DISABLE
#undef malloc
#define malloc(size) \
dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MALLOC, 0, 0)
#undef calloc
#define calloc(count, size) \
dmalloc_malloc(__FILE__, __LINE__, (count)*(size), DMALLOC_FUNC_CALLOC, 0, 0)
#undef realloc
#define realloc(ptr, size) \
dmalloc_realloc(__FILE__, __LINE__, (ptr), (size), DMALLOC_FUNC_REALLOC, 0)
#undef recalloc
#define recalloc(ptr, size) \
dmalloc_realloc(__FILE__, __LINE__, (ptr), (size), DMALLOC_FUNC_RECALLOC, 0)
#undef memalign
#define memalign(alignment, size) \
dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MEMALIGN, \
(alignment), 0 /* no xalloc */)
#undef valloc
#define valloc(size) \
dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_VALLOC, \
0 /* special case */, 0 /* no xalloc */)
#ifndef DMALLOC_STRDUP_MACRO
#undef strdup
#define strdup(str) \
dmalloc_strndup(__FILE__, __LINE__, (str), -1, 0)
#endif
#ifndef DMALLOC_STRNDUP_MACRO
#undef strndup
#define strndup(str, len) \
dmalloc_strndup(__FILE__, __LINE__, (str), (len), 0)
#endif
#undef free
#define free(ptr) \
dmalloc_free(__FILE__, __LINE__, (ptr), DMALLOC_FUNC_FREE)
#undef xmalloc
#define xmalloc(size) \
dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MALLOC, 0, 1)
#undef xcalloc
#define xcalloc(count, size) \
dmalloc_malloc(__FILE__, __LINE__, (count)*(size), DMALLOC_FUNC_CALLOC, 0, 1)
#undef xrealloc
#define xrealloc(ptr, size) \
dmalloc_realloc(__FILE__, __LINE__, (ptr), (size), DMALLOC_FUNC_REALLOC, 1)
#undef xrecalloc
#define xrecalloc(ptr, size) \
dmalloc_realloc(__FILE__, __LINE__, (ptr), (size), DMALLOC_FUNC_RECALLOC, 1)
#undef xmemalign
#define xmemalign(alignment, size) \
dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_MEMALIGN, \
(alignment), 1)
#undef xvalloc
#define xvalloc(size) \
dmalloc_malloc(__FILE__, __LINE__, (size), DMALLOC_FUNC_VALLOC, 0, 1)
#undef xstrdup
#define xstrdup(str) \
dmalloc_strndup(__FILE__, __LINE__, (str), -1, 1)
#undef xstrndup
#define xstrndup(str, len) \
dmalloc_strndup(__FILE__, __LINE__, (str), (len), 1)
#undef xfree
#define xfree(ptr) \
dmalloc_free(__FILE__, __LINE__, (ptr), DMALLOC_FUNC_FREE)
#ifdef DMALLOC_FUNC_CHECK
/*
* do debugging on the following functions. this may cause compilation or
* other problems depending on your architecture.
*/
#undef atoi
#define atoi(str) \
_dmalloc_atoi(__FILE__, __LINE__, (str))
#undef atol
#define atol(str) \
_dmalloc_atol(__FILE__, __LINE__, (str))
#undef bcmp
#define bcmp(b1, b2, len) \
_dmalloc_bcmp(__FILE__, __LINE__, (b1), (b2), (len))
#undef bcopy
#define bcopy(from, to, len) \
_dmalloc_bcopy(__FILE__, __LINE__, (from), (to), (len))
#undef bzero
#define bzero(buf, len) \
_dmalloc_bzero(__FILE__, __LINE__, (buf), (len))
#undef memcmp
#define memcmp(b1, b2, len) \
_dmalloc_memcmp(__FILE__, __LINE__, (b1), (b2), (len))
#undef memcpy
#define memcpy(to, from, len) \
_dmalloc_memcpy(__FILE__, __LINE__, (to), (from), (len))
#undef memmove
#define memmove(to, from, len) \
_dmalloc_memmove(__FILE__, __LINE__, (to), (from), (len))
#undef memset
#define memset(buf, ch, len) \
_dmalloc_memset(__FILE__, __LINE__, (buf), (ch), (len))
#undef index
#define index(str, ch) \
_dmalloc_index(__FILE__, __LINE__, (str), (ch))
#undef rindex
#define rindex(str, ch) \
_dmalloc_rindex(__FILE__, __LINE__, (str), (ch))
#undef strcat
#define strcat(to, from) \
_dmalloc_strcat(__FILE__, __LINE__, (to), (from))
#undef strcmp
#define strcmp(s1, s2) \
_dmalloc_strcmp(__FILE__, __LINE__, (s1), (s2))
#undef strlen
#define strlen(str) \
_dmalloc_strlen(__FILE__, __LINE__, (str))
#undef strtok
#define strtok(str, sep) \
_dmalloc_strtok(__FILE__, __LINE__, (str), (sep))
#undef memccpy
#define memccpy(s1, s2, ch, len) \
_dmalloc_memccpy(__FILE__, __LINE__, (s1), (s2),(ch),(len))
#undef memchr
#define memchr(s1, ch, len) \
_dmalloc_memchr(__FILE__, __LINE__, (s1), (ch), (len))
#undef strchr
#define strchr(str, ch) \
_dmalloc_strchr(__FILE__, __LINE__, (str), (ch))
#undef strrchr
#define strrchr(str, ch) \
_dmalloc_strrchr(__FILE__, __LINE__, (str), (ch))
#undef strcpy
#define strcpy(to, from) \
_dmalloc_strcpy(__FILE__, __LINE__, (to), (from))
#undef strncpy
#define strncpy(to, from, len) \
_dmalloc_strncpy(__FILE__, __LINE__, (to), (from), (len))
#undef strcasecmp
#define strcasecmp(s1, s2) \
_dmalloc_strcasecmp(__FILE__, __LINE__, (s1), (s2))
#undef strncasecmp
#define strncasecmp(s1, s2, len) \
_dmalloc_strncasecmp(__FILE__, __LINE__, (s1), (s2), (len))
#undef strspn
#define strspn(str, list) \
_dmalloc_strspn(__FILE__, __LINE__, (str), (list))
#undef strcspn
#define strcspn(str, list) \
_dmalloc_strcspn(__FILE__, __LINE__, (str), (list))
#undef strncat
#define strncat(to, from, len) \
_dmalloc_strncat(__FILE__, __LINE__, (to), (from), (len))
#undef strncmp
#define strncmp(s1, s2, len) \
_dmalloc_strncmp(__FILE__, __LINE__, (s1), (s2), (len))
#undef strpbrk
#define strpbrk(str, list) \
_dmalloc_strpbrk(__FILE__, __LINE__, (str), (list))
#undef strstr
#define strstr(str, pat) \
_dmalloc_strstr(__FILE__, __LINE__, (str), (pat))
#endif /* DMALLOC_FUNC_CHECK */
#endif /* ! DMALLOC_DISABLE */
/*
* feel free to add your favorite functions here and to arg_check.[ch]
*/
#ifdef __cplusplus
extern "C" {
#endif