VR-Vantage 3.1 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
dbgint.h
Go to the documentation of this file.
1 /***
2 *dbgint.h - Supports debugging features of the C runtime library.
3 *
4 * Copyright (c) Microsoft Corporation. All rights reserved.
5 *
6 *Purpose:
7 * Support CRT debugging features.
8 *
9 * [Internal]
10 *
11 ****/
12 
13 #if _MSC_VER > 1000
14 #pragma once
15 #endif /* _MSC_VER > 1000 */
16 
17 #ifndef _INC_DBGINT
18 #define _INC_DBGINT
19 
20 #ifndef _CRTBLD
21 /*
22  * This is an internal C runtime header file. It is used when building
23  * the C runtimes only. It is not to be used as a public header file.
24  */
25 #error ERROR: Use of C runtime library internal header file.
26 #endif /* _CRTBLD */
27 
28 #include <crtdbg.h>
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33 
34 #ifndef _DEBUG
35 
36  /****************************************************************************
37  *
38  * Debug OFF
39  * Debug OFF
40  * Debug OFF
41  *
42  ***************************************************************************/
43 
44 #ifdef __cplusplus
45 
46 #define _new_crt new
47 
48 #endif /* __cplusplus */
49 
50 #define _malloc_crt malloc
51 #define _calloc_crt calloc
52 #define _realloc_crt realloc
53 #define _expand_crt _expand
54 #define _free_crt free
55 #define _msize_crt _msize
56 
57 
58 #define _malloc_base malloc
59 #define _nh_malloc_base _nh_malloc
60 #define _nh_malloc_dbg(s, n, t, f, l) _nh_malloc(s, n)
61 #define _heap_alloc_base _heap_alloc
62 #define _heap_alloc_dbg(s, t, f, l) _heap_alloc(s)
63 #define _calloc_base calloc
64 #define _realloc_base realloc
65 #define _expand_base _expand
66 #define _free_base free
67 #define _msize_base _msize
68 #define _aligned_malloc_base _aligned_malloc
69 #define _aligned_realloc_base _aligned_realloc
70 #define _aligned_offset_malloc_base _aligned_offset_malloc
71 #define _aligned_offset_realloc_base _aligned_offset_realloc
72 #define _aligned_free_base _aligned_free
73 
74 #ifdef _MT
75 
76 #define _calloc_dbg_lk(c, s, t, f, l) _calloc_lk(c, s)
77 #define _realloc_dbg_lk(p, s, t, f, l) _realloc_lk(p, s)
78 #define _free_base_lk _free_lk
79 #define _free_dbg_lk(p, t) _free_lk(p)
80 
81 #else /* _MT */
82 
83 #define _calloc_dbg_lk(c, s, t, f, l) calloc(c, s)
84 #define _realloc_dbg_lk(p, s, t, f, l) realloc(p, s)
85 #define _free_base_lk free
86 #define _free_dbg_lk(p, t) free(p)
87 
88 #endif /* _MT */
89 
90 
91 #else /* _DEBUG */
92 
93 
94  /****************************************************************************
95  *
96  * Debug ON
97  * Debug ON
98  * Debug ON
99  *
100  ***************************************************************************/
101 
102 #define _THISFILE __FILE__
103 
104 #ifdef __cplusplus
105 
106 #define _new_crt new(_CRT_BLOCK, _THISFILE, __LINE__)
107 
108 #endif /* __cplusplus */
109 
110 #define _malloc_crt(s) _malloc_dbg(s, _CRT_BLOCK, _THISFILE, __LINE__)
111 #define _calloc_crt(c, s) _calloc_dbg(c, s, _CRT_BLOCK, _THISFILE, __LINE__)
112 #define _realloc_crt(p, s) _realloc_dbg(p, s, _CRT_BLOCK, _THISFILE, __LINE__)
113 #define _expand_crt(p, s) _expand_dbg(p, s, _CRT_BLOCK)
114 #define _free_crt(p) _free_dbg(p, _CRT_BLOCK)
115 #define _msize_crt(p) _msize_dbg(p, _CRT_BLOCK)
116 
117 /*
118  * Prototypes for malloc, free, realloc, etc are in malloc.h
119  */
120 
121 void * __cdecl _malloc_base(
122  size_t
123  );
124 
125 void * __cdecl _nh_malloc_base (
126  size_t,
127  int
128  );
129 
130 void * __cdecl _nh_malloc_dbg (
131  size_t,
132  int,
133  int,
134  const char *,
135  int
136  );
137 
138 void * __cdecl _heap_alloc_base(
139  size_t
140  );
141 
142 void * __cdecl _heap_alloc_dbg(
143  size_t,
144  int,
145  const char *,
146  int
147  );
148 
149 void * __cdecl _calloc_base(
150  size_t,
151  size_t
152  );
153 
154 void * __cdecl _realloc_base(
155  void *,
156  size_t
157  );
158 
159 void * __cdecl _expand_base(
160  void *,
161  size_t
162  );
163 
164 void __cdecl _free_base(
165  void *
166  );
167 
168 size_t __cdecl _msize_base (
169  void *
170  );
171 
172 void __cdecl _aligned_free_base(
173  void *
174  );
175 
176 void * __cdecl _aligned_malloc_base(
177  size_t,
178  size_t
179  );
180 
181 void * __cdecl _aligned_offset_malloc_base(
182  size_t,
183  size_t,
184  size_t
185  );
186 
187 void * __cdecl _aligned_realloc_base(
188  void *,
189  size_t,
190  size_t
191  );
192 
193 void * __cdecl _aligned_offset_realloc_base(
194  void *,
195  size_t,
196  size_t,
197  size_t
198  );
199 
200 #ifdef _MT
201 
202 /*
203  * Prototypes and macros for multi-thread support
204  */
205 
206 
207 void * __cdecl _calloc_dbg_lk(
208  size_t,
209  size_t,
210  int,
211  char *,
212  int
213  );
214 
215 
216 void * __cdecl _realloc_dbg_lk(
217  void *,
218  size_t,
219  int,
220  const char *,
221  int
222  );
223 
224 
225 void __cdecl _free_base_lk(
226  void *
227  );
228 
229 void __cdecl _free_dbg_lk(
230  void *,
231  int
232  );
233 
234 #else /* _MT */
235 
236 #define _calloc_dbg_lk _calloc_dbg
237 #define _realloc_dbg_lk _realloc_dbg
238 #define _free_base_lk _free_base
239 #define _free_dbg_lk _free_dbg
240 
241 #endif /* _MT */
242 
243 /*
244  * For diagnostic purpose, blocks are allocated with extra information and
245  * stored in a doubly-linked list. This makes all blocks registered with
246  * how big they are, when they were allocated, and what they are used for.
247  */
248 
249 #define nNoMansLandSize 4
250 
251 typedef struct _CrtMemBlockHeader
252 {
253  struct _CrtMemBlockHeader * pBlockHeaderNext;
254  struct _CrtMemBlockHeader * pBlockHeaderPrev;
255  char * szFileName;
256  int nLine;
257 #ifdef _WIN64
258  /* These items are reversed on Win64 to eliminate gaps in the struct
259  * and ensure that sizeof(struct)%16 == 0, so 16-byte alignment is
260  * maintained in the debug heap.
261  */
262  int nBlockUse;
263  size_t nDataSize;
264 #else /* _WIN64 */
265  size_t nDataSize;
266  int nBlockUse;
267 #endif /* _WIN64 */
268  long lRequest;
269  unsigned char gap[nNoMansLandSize];
270  /* followed by:
271  * unsigned char data[nDataSize];
272  * unsigned char anotherGap[nNoMansLandSize];
273  */
274 } _CrtMemBlockHeader;
275 
276 #define pbData(pblock) ((unsigned char *)((_CrtMemBlockHeader *)pblock + 1))
277 #define pHdr(pbData) (((_CrtMemBlockHeader *)pbData)-1)
278 
279 
280 _CRTIMP void __cdecl _CrtSetDbgBlockType(
281  void *,
282  int
283  );
284 
285 #define _BLOCK_TYPE_IS_VALID(use) (_BLOCK_TYPE(use) == _CLIENT_BLOCK || \
286  (use) == _NORMAL_BLOCK || \
287  _BLOCK_TYPE(use) == _CRT_BLOCK || \
288  (use) == _IGNORE_BLOCK)
289 
290 extern _CRT_ALLOC_HOOK _pfnAllocHook; /* defined in dbghook.c */
291 
292 int __cdecl _CrtDefaultAllocHook(
293  int,
294  void *,
295  size_t,
296  int,
297  long,
298  const unsigned char *,
299  int
300  );
301 
302 #endif /* _DEBUG */
303 
304 #ifdef __cplusplus
305 }
306 #endif /* __cplusplus */
307 
308 #endif /* _INC_DBGINT */


Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)