STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
crtdbg.h
Go to the documentation of this file.
1 //
2 // crtdbg.h
3 //
4 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //
6 // Public debugging facilities for the CRT
7 //
8 #pragma once
9 #define _INC_CRTDBG
10 
11 #include <corecrt.h>
12 #include <vcruntime_new_debug.h>
13 
15 
16 
17 
18 typedef void* _HFILE; // file handle pointer
19 
20 #define _CRT_WARN 0
21 #define _CRT_ERROR 1
22 #define _CRT_ASSERT 2
23 #define _CRT_ERRCNT 3
24 
25 #define _CRTDBG_MODE_FILE 0x1
26 #define _CRTDBG_MODE_DEBUG 0x2
27 #define _CRTDBG_MODE_WNDW 0x4
28 #define _CRTDBG_REPORT_MODE -1
29 
30 #define _CRTDBG_INVALID_HFILE ((_HFILE)(intptr_t)-1)
31 #define _CRTDBG_HFILE_ERROR ((_HFILE)(intptr_t)-2)
32 #define _CRTDBG_FILE_STDOUT ((_HFILE)(intptr_t)-4)
33 #define _CRTDBG_FILE_STDERR ((_HFILE)(intptr_t)-5)
34 #define _CRTDBG_REPORT_FILE ((_HFILE)(intptr_t)-6)
35 
36 
37 
38 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 //
40 // Client-defined reporting and allocation hooks
41 //
42 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 
44 typedef int (__CRTDECL* _CRT_REPORT_HOOK )(int, char*, int*);
45 typedef int (__CRTDECL* _CRT_REPORT_HOOKW)(int, wchar_t*, int*);
46 
47 #define _CRT_RPTHOOK_INSTALL 0
48 #define _CRT_RPTHOOK_REMOVE 1
49 
50 
51 typedef int (__CRTDECL* _CRT_ALLOC_HOOK)(int, void*, size_t, int, long, unsigned char const*, int);
52 
53 #ifdef _M_CEE
54  typedef int (__clrcall* _CRT_ALLOC_HOOK_M)(int, void*, size_t, int, long, unsigned char const*, int);
55 #endif
56 
57 #define _HOOK_ALLOC 1
58 #define _HOOK_REALLOC 2
59 #define _HOOK_FREE 3
60 
61 
62 
63 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64 //
65 // Memory Management and State Tracking
66 //
67 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68 
69 // Bit values for _crtDbgFlag flag. These bitflags control debug heap behavior.
70 #define _CRTDBG_ALLOC_MEM_DF 0x01 // Turn on debug allocation
71 #define _CRTDBG_DELAY_FREE_MEM_DF 0x02 // Don't actually free memory
72 #define _CRTDBG_CHECK_ALWAYS_DF 0x04 // Check heap every alloc/dealloc
73 #define _CRTDBG_RESERVED_DF 0x08 // Reserved - do not use
74 #define _CRTDBG_CHECK_CRT_DF 0x10 // Leak check/diff CRT blocks
75 #define _CRTDBG_LEAK_CHECK_DF 0x20 // Leak check at program exit
76 
77 // Some bit values for _crtDbgFlag which correspond to frequencies for checking
78 // the heap.
79 #define _CRTDBG_CHECK_EVERY_16_DF 0x00100000 // Check heap every 16 heap ops
80 #define _CRTDBG_CHECK_EVERY_128_DF 0x00800000 // Check heap every 128 heap ops
81 #define _CRTDBG_CHECK_EVERY_1024_DF 0x04000000 // Check heap every 1024 heap ops
82 
83 // We do not check the heap by default at this point because the cost was too
84 // high for some applications. You can still turn this feature on manually.
85 #define _CRTDBG_CHECK_DEFAULT_DF 0
86 
87 #define _CRTDBG_REPORT_FLAG -1 // Query bitflag status
88 
89 #define _BLOCK_TYPE(block) (block & 0xFFFF)
90 #define _BLOCK_SUBTYPE(block) (block >> 16 & 0xFFFF)
91 
92 // Memory block identification
93 #define _FREE_BLOCK 0
94 #define _NORMAL_BLOCK 1
95 #define _CRT_BLOCK 2
96 #define _IGNORE_BLOCK 3
97 #define _CLIENT_BLOCK 4
98 #define _MAX_BLOCKS 5
99 
100 // _UNKNOWN_BLOCK is a sentinel value that may be passed to some functions that
101 // expect a block type as an argument. If this value is passed, those functions
102 // will use the block type specified in the block header instead. This is used
103 // in cases where the heap lock cannot be acquired to compute the block type
104 // before calling the function (e.g. when the caller is outside of the CoreCRT).
105 #define _UNKNOWN_BLOCK (-1)
106 
108 
109 #ifdef _M_CEE
110  typedef void (__clrcall* _CRT_DUMP_CLIENT_M)(void*, size_t);
111 #endif
112 
113 struct _CrtMemBlockHeader;
114 
115 typedef struct _CrtMemState
116 {
117  struct _CrtMemBlockHeader* pBlockHeader;
121  size_t lTotalCount;
122 } _CrtMemState;
123 
124 #ifndef _DEBUG
125 
126  #define _CrtGetAllocHook() ((_CRT_ALLOC_HOOK)0)
127  #define _CrtSetAllocHook(f) ((_CRT_ALLOC_HOOK)0)
128 
129  #define _CrtGetDumpClient() ((_CRT_DUMP_CLIENT)0)
130  #define _CrtSetDumpClient(f) ((_CRT_DUMP_CLIENT)0)
131 
132  #define _CrtCheckMemory() ((int)1)
133  #define _CrtDoForAllClientObjects(f, c) ((void)0)
134  #define _CrtDumpMemoryLeaks() ((int)0)
135  #define _CrtIsMemoryBlock(p, t, r, f, l) ((int)1)
136  #define _CrtIsValidHeapPointer(p) ((int)1)
137  #define _CrtIsValidPointer(p, n, r) ((int)1)
138  #define _CrtMemCheckpoint(s) ((void)0)
139  #define _CrtMemDifference(s1, s2, s3) ((int)0)
140  #define _CrtMemDumpAllObjectsSince(s) ((void)0)
141  #define _CrtMemDumpStatistics(s) ((void)0)
142  #define _CrtReportBlockType(p) ((int)-1)
143  #define _CrtSetBreakAlloc(a) ((long)0)
144  #define _CrtSetDbgFlag(f) ((int)0)
145 
146 
147 #else // ^^^ !_DEBUG ^^^ // vvv _DEBUG vvv //
148 
149  #ifndef _M_CEE_PURE
150 
151  _ACRTIMP int* __cdecl __p__crtDbgFlag(void);
152  _ACRTIMP long* __cdecl __p__crtBreakAlloc(void);
153 
154  #define _crtDbgFlag (*__p__crtDbgFlag())
155  #define _crtBreakAlloc (*__p__crtBreakAlloc())
156 
158 
160  _In_opt_ _CRT_ALLOC_HOOK _PfnNewHook
161  );
162 
164 
166  _In_opt_ _CRT_DUMP_CLIENT _PFnNewDump
167  );
168 
169  #endif // _M_CEE_PURE
170 
171  _ACRTIMP int __cdecl _CrtCheckMemory(void);
172 
173  typedef void (__cdecl* _CrtDoForAllClientObjectsCallback)(void*, void*);
174 
175  _ACRTIMP void __cdecl _CrtDoForAllClientObjects(
176  _In_ _CrtDoForAllClientObjectsCallback _Callback,
177  _In_ void* _Context
178  );
179 
180  _ACRTIMP int __cdecl _CrtDumpMemoryLeaks(void);
181 
182  _ACRTIMP int __cdecl _CrtIsMemoryBlock(
183  _In_opt_ void const* _Block,
184  _In_ unsigned int _Size,
185  _Out_opt_ long* _RequestNumber,
186  _Out_opt_ char** _FileName,
187  _Out_opt_ int* _LineNumber
188  );
189 
191  _ACRTIMP int __cdecl _CrtIsValidHeapPointer(
192  _In_opt_ void const* _Pointer
193  );
194 
196  _ACRTIMP int __cdecl _CrtIsValidPointer(
197  _In_opt_ void const* _Pointer,
198  _In_ unsigned int _Size,
199  _In_ int _ReadWrite
200  );
201 
202  _ACRTIMP void __cdecl _CrtMemCheckpoint(
204  );
205 
206  _ACRTIMP int __cdecl _CrtMemDifference(
208  _In_ _CrtMemState const* _OldState,
209  _In_ _CrtMemState const* _NewState
210  );
211 
214  );
215 
216  _ACRTIMP void __cdecl _CrtMemDumpStatistics(
217  _In_ _CrtMemState const* _State
218  );
219 
221  _ACRTIMP int __cdecl _CrtReportBlockType(
222  _In_opt_ void const* _Block
223  );
224 
225  _ACRTIMP long __cdecl _CrtSetBreakAlloc(
226  _In_ long _NewValue
227  );
228 
229  _ACRTIMP int __cdecl _CrtSetDbgFlag(
230  _In_ int _NewFlag
231  );
232 
233 #endif // _DEBUG
234 
235 
236 
237 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
238 //
239 // Debug Heap Routines
240 //
241 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
242 #ifndef _DEBUG
243 
244  #define _calloc_dbg(c, s, t, f, l) calloc(c, s)
245  #define _expand_dbg(p, s, t, f, l) _expand(p, s)
246  #define _free_dbg(p, t) free(p)
247  #define _malloc_dbg(s, t, f, l) malloc(s)
248  #define _msize_dbg(p, t) _msize(p)
249  #define _realloc_dbg(p, s, t, f, l) realloc(p, s)
250  #define _recalloc_dbg(p, c, s, t, f, l) _recalloc(p, c, s)
251 
252  #define _aligned_free_dbg(p) _aligned_free(p)
253  #define _aligned_malloc_dbg(s, a, f, l) _aligned_malloc(s, a)
254  #define _aligned_msize_dbg(p, a, o) _aligned_msize(p, a, o)
255  #define _aligned_offset_malloc_dbg(s, a, o, f, l) _aligned_offset_malloc(s, a, o)
256  #define _aligned_offset_realloc_dbg(p, s, a, o, f, l) _aligned_offset_realloc(p, s, a, o)
257  #define _aligned_offset_recalloc_dbg(p, c, s, a, o, f, l) _aligned_offset_recalloc(p, c, s, a, o)
258  #define _aligned_realloc_dbg(p, s, a, f, l) _aligned_realloc(p, s, a)
259  #define _aligned_recalloc_dbg(p, c, s, a, f, l) _aligned_recalloc(p, c, s, a)
260 
261  #define _freea_dbg(p, t) _freea(p)
262  #define _malloca_dbg(s, t, f, l) _malloca(s)
263 
264  #define _dupenv_s_dbg(ps1, size, s2, t, f, l) _dupenv_s(ps1, size, s2)
265  #define _fullpath_dbg(s1, s2, le, t, f, l) _fullpath(s1, s2, le)
266  #define _getcwd_dbg(s, le, t, f, l) _getcwd(s, le)
267  #define _getdcwd_dbg(d, s, le, t, f, l) _getdcwd(d, s, le)
268  #define _getdcwd_lk_dbg(d, s, le, t, f, l) _getdcwd(d, s, le)
269  #define _mbsdup_dbg(s, t, f, l) _mbsdup(s)
270  #define _strdup_dbg(s, t, f, l) _strdup(s)
271  #define _tempnam_dbg(s1, s2, t, f, l) _tempnam(s1, s2)
272  #define _wcsdup_dbg(s, t, f, l) _wcsdup(s)
273  #define _wdupenv_s_dbg(ps1, size, s2, t, f, l) _wdupenv_s(ps1, size, s2)
274  #define _wfullpath_dbg(s1, s2, le, t, f, l) _wfullpath(s1, s2, le)
275  #define _wgetcwd_dbg(s, le, t, f, l) _wgetcwd(s, le)
276  #define _wgetdcwd_dbg(d, s, le, t, f, l) _wgetdcwd(d, s, le)
277  #define _wgetdcwd_lk_dbg(d, s, le, t, f, l) _wgetdcwd(d, s, le)
278  #define _wtempnam_dbg(s1, s2, t, f, l) _wtempnam(s1, s2)
279 
280 #else // ^^^ !_DEBUG ^^^ // vvv _DEBUG vvv //
281 
282  #ifdef _CRTDBG_MAP_ALLOC
283 
284  #define calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
285  #define _expand(p, s) _expand_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
286  #define free(p) _free_dbg(p, _NORMAL_BLOCK)
287  #define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
288  #define _msize(p) _msize_dbg(p, _NORMAL_BLOCK)
289  #define realloc(p, s) _realloc_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__)
290  #define _recalloc(p, c, s) _recalloc_dbg(p, c, s, _NORMAL_BLOCK, __FILE__, __LINE__)
291 
292  #define _aligned_free(p) _aligned_free_dbg(p)
293  #define _aligned_malloc(s, a) _aligned_malloc_dbg(s, a, __FILE__, __LINE__)
294  #define _aligned_msize(p, a, o) _aligned_msize_dbg(p, a, o)
295  #define _aligned_offset_malloc(s, a, o) _aligned_offset_malloc_dbg(s, a, o, __FILE__, __LINE__)
296  #define _aligned_offset_realloc(p, s, a, o) _aligned_offset_realloc_dbg(p, s, a, o, __FILE__, __LINE__)
297  #define _aligned_offset_recalloc(p, c, s, a, o) _aligned_offset_recalloc_dbg(p, c, s, a, o, __FILE__, __LINE__)
298  #define _aligned_realloc(p, s, a) _aligned_realloc_dbg(p, s, a, __FILE__, __LINE__)
299  #define _aligned_recalloc(p, c, s, a) _aligned_recalloc_dbg(p, c, s, a, __FILE__, __LINE__)
300 
301  #define _freea(p) _freea_dbg(p, _NORMAL_BLOCK)
302  #define _malloca(s) _malloca_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
303 
304  #define _dupenv_s(ps1, size, s2) _dupenv_s_dbg(ps1, size, s2, _NORMAL_BLOCK, __FILE__, __LINE__)
305  #define _fullpath(s1, s2, le) _fullpath_dbg(s1, s2, le, _NORMAL_BLOCK, __FILE__, __LINE__)
306  #define _getcwd(s, le) _getcwd_dbg(s, le, _NORMAL_BLOCK, __FILE__, __LINE__)
307  #define _getdcwd(d, s, le) _getdcwd_dbg(d, s, le, _NORMAL_BLOCK, __FILE__, __LINE__)
308  #define _mbsdup(s) _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
309  #define _strdup(s) _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
310  #define _tempnam(s1, s2) _tempnam_dbg(s1, s2, _NORMAL_BLOCK, __FILE__, __LINE__)
311  #define _wcsdup(s) _wcsdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
312  #define _wdupenv_s(ps1, size, s2) _wdupenv_s_dbg(ps1, size, s2, _NORMAL_BLOCK, __FILE__, __LINE__)
313  #define _wfullpath(s1, s2, le) _wfullpath_dbg(s1, s2, le, _NORMAL_BLOCK, __FILE__, __LINE__)
314  #define _wgetcwd(s, le) _wgetcwd_dbg(s, le, _NORMAL_BLOCK, __FILE__, __LINE__)
315  #define _wgetdcwd(d, s, le) _wgetdcwd_dbg(d, s, le, _NORMAL_BLOCK, __FILE__, __LINE__)
316  #define _wtempnam(s1, s2) _wtempnam_dbg(s1, s2, _NORMAL_BLOCK, __FILE__, __LINE__)
317 
318  #if _CRT_INTERNAL_NONSTDC_NAMES
319  #define strdup(s) _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
320  #define wcsdup(s) _wcsdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
321  #define tempnam(s1, s2) _tempnam_dbg(s1, s2, _NORMAL_BLOCK, __FILE__, __LINE__)
322  #define getcwd(s, le) _getcwd_dbg(s, le, _NORMAL_BLOCK, __FILE__, __LINE__)
323  #endif
324 
325  #endif // _CRTDBG_MAP_ALLOC
326 
327  _ACRTIMP void __cdecl _aligned_free_dbg(
328  _Pre_maybenull_ _Post_invalid_ void* _Block
329  );
330 
333  _In_ size_t _Size,
334  _In_ size_t _Alignment,
335  _In_opt_z_ char const* _FileName,
336  _In_ int _LineNumber
337  );
338 
339  _ACRTIMP size_t __cdecl _aligned_msize_dbg(
340  _Pre_notnull_ void* _Block,
341  _In_ size_t _Alignment,
342  _In_ size_t _Offset
343  );
344 
347  _In_ size_t _Size,
348  _In_ size_t _Alignment,
349  _In_ size_t _Offset,
350  _In_opt_z_ char const* _FileName,
351  _In_ int _LineNumber
352  );
353 
356  _Pre_maybenull_ _Post_invalid_ void* _Block,
357  _In_ size_t _Size,
358  _In_ size_t _Alignment,
359  _In_ size_t _Offset,
360  _In_opt_z_ char const* _FileName,
361  _In_ int _LineNumber
362  );
363 
366  _Pre_maybenull_ _Post_invalid_ void* _Block,
367  _In_ size_t _Count,
368  _In_ size_t _Size,
369  _In_ size_t _Alignment,
370  _In_ size_t _Offset,
371  _In_opt_z_ char const* _FileName,
372  _In_ int _LineNumber
373  );
374 
377  _Pre_maybenull_ _Post_invalid_ void* _Block,
378  _In_ size_t _Size,
379  _In_ size_t _Alignment,
380  _In_opt_z_ char const* _FileName,
381  _In_ int _LineNumber
382  );
383 
386  _Pre_maybenull_ _Post_invalid_ void* _Block,
387  _In_ size_t _Count,
388  _In_ size_t _Size,
389  _In_ size_t _Alignment,
390  _In_opt_z_ char const* _FileName,
391  _In_ int _LineNumber
392  );
393 
395  _ACRTIMP _CRTALLOCATOR void* __cdecl _calloc_dbg(
396  _In_ size_t _Count,
397  _In_ size_t _Size,
398  _In_ int _BlockUse,
399  _In_opt_z_ char const* _FileName,
400  _In_ int _LineNumber
401  );
402 
404  _ACRTIMP _CRTALLOCATOR void* __cdecl _expand_dbg(
405  _Pre_notnull_ void* _Block,
406  _In_ size_t _Size,
407  _In_ int _BlockUse,
408  _In_opt_z_ char const* _FileName,
409  _In_ int _LineNumber
410  );
411 
412  _ACRTIMP void __cdecl _free_dbg(
413  _Pre_maybenull_ _Post_invalid_ void* _Block,
414  _In_ int _BlockUse
415  );
416 
418  _ACRTIMP _CRTALLOCATOR void* __cdecl _malloc_dbg(
419  _In_ size_t _Size,
420  _In_ int _BlockUse,
421  _In_opt_z_ char const* _FileName,
422  _In_ int _LineNumber
423  );
424 
425  _ACRTIMP size_t __cdecl _msize_dbg(
426  _Pre_notnull_ void* _Block,
427  _In_ int _BlockUse
428  );
429 
431  _ACRTIMP _CRTALLOCATOR void* __cdecl _realloc_dbg(
432  _Pre_maybenull_ _Post_invalid_ void* _Block,
433  _In_ size_t _Size,
434  _In_ int _BlockUse,
435  _In_opt_z_ char const* _FileName,
436  _In_ int _LineNumber
437  );
438 
440  _ACRTIMP _CRTALLOCATOR void* __cdecl _recalloc_dbg(
441  _Pre_maybenull_ _Post_invalid_ void* _Block,
442  _In_ size_t _Count,
443  _In_ size_t _Size,
444  _In_ int _BlockUse,
445  _In_opt_z_ char const* _FileName,
446  _In_ int _LineNumber
447  );
448 
449  _Success_(return == 0)
452  _Outptr_result_buffer_maybenull_(*_PBufferSizeInBytes) char** _PBuffer,
453  _Out_opt_ size_t* _PBufferSizeInBytes,
454  _In_z_ char const* _VarName,
455  _In_ int _BlockType,
456  _In_opt_z_ char const* _FileName,
457  _In_ int _LineNumber
458  );
459 
460  _Success_(return != 0)
462  _ACRTIMP _CRTALLOCATOR char* __cdecl _fullpath_dbg(
463  _Out_writes_opt_z_(_SizeInBytes) char* _FullPath,
464  _In_z_ char const* _Path,
465  _In_ size_t _SizeInBytes,
466  _In_ int _BlockType,
467  _In_opt_z_ char const* _FileName,
468  _In_ int _LineNumber
469  );
470 
471  _Success_(return != 0)
473  _DCRTIMP _CRTALLOCATOR char* __cdecl _getcwd_dbg(
474  _Out_writes_opt_z_(_SizeInBytes) char* _DstBuf,
475  _In_ int _SizeInBytes,
476  _In_ int _BlockType,
477  _In_opt_z_ char const* _FileName,
478  _In_ int _LineNumber
479  );
480 
481 
482  _Success_(return != 0)
484  _DCRTIMP _CRTALLOCATOR char* __cdecl _getdcwd_dbg(
485  _In_ int _Drive,
486  _Out_writes_opt_z_(_SizeInBytes) char* _DstBuf,
487  _In_ int _SizeInBytes,
488  _In_ int _BlockType,
489  _In_opt_z_ char const* _FileName,
490  _In_ int _LineNumber
491  );
492 
494  _ACRTIMP _CRTALLOCATOR char* __cdecl _strdup_dbg(
495  _In_opt_z_ char const* _String,
496  _In_ int _BlockUse,
497  _In_opt_z_ char const* _FileName,
498  _In_ int _LineNumber
499  );
500 
502  _ACRTIMP _CRTALLOCATOR char* __cdecl _tempnam_dbg(
503  _In_opt_z_ char const* _DirName,
504  _In_opt_z_ char const* _FilePrefix,
505  _In_ int _BlockType,
506  _In_opt_z_ char const* _FileName,
507  _In_ int _LineNumber
508  );
509 
510  _Success_(return != 0)
512  _ACRTIMP _CRTALLOCATOR wchar_t* __cdecl _wcsdup_dbg(
513  _In_opt_z_ wchar_t const* _String,
514  _In_ int _BlockUse,
515  _In_opt_z_ char const* _FileName,
516  _In_ int _LineNumber
517  );
518 
519  _Success_(return == 0)
522  _Outptr_result_buffer_maybenull_(*_PBufferSizeInWords) wchar_t** _PBuffer,
523  _Out_opt_ size_t* _PBufferSizeInWords,
524  _In_z_ wchar_t const* _VarName,
525  _In_ int _BlockType,
526  _In_opt_z_ char const* _FileName,
527  _In_ int _LineNumber
528  );
529 
530  _Success_(return != 0)
532  _ACRTIMP _CRTALLOCATOR wchar_t* __cdecl _wfullpath_dbg(
533  _Out_writes_opt_z_(_SizeInWords) wchar_t* _FullPath,
534  _In_z_ wchar_t const* _Path,
535  _In_ size_t _SizeInWords,
536  _In_ int _BlockType,
537  _In_opt_z_ char const* _FileName,
538  _In_ int _LineNumber
539  );
540 
541  _Success_(return != 0)
543  _DCRTIMP _CRTALLOCATOR wchar_t* __cdecl _wgetcwd_dbg(
544  _Out_writes_opt_z_(_SizeInWords) wchar_t* _DstBuf,
545  _In_ int _SizeInWords,
546  _In_ int _BlockType,
547  _In_opt_z_ char const* _FileName,
548  _In_ int _LineNumber
549  );
550 
551  _Success_(return != 0)
553  _DCRTIMP _CRTALLOCATOR wchar_t* __cdecl _wgetdcwd_dbg(
554  _In_ int _Drive,
555  _Out_writes_opt_z_(_SizeInWords) wchar_t* _DstBuf,
556  _In_ int _SizeInWords,
557  _In_ int _BlockType,
558  _In_opt_z_ char const* _FileName,
559  _In_ int _LineNumber
560  );
561 
563  _ACRTIMP _CRTALLOCATOR wchar_t* __cdecl _wtempnam_dbg(
564  _In_opt_z_ wchar_t const* _DirName,
565  _In_opt_z_ wchar_t const* _FilePrefix,
566  _In_ int _BlockType,
567  _In_opt_z_ char const* _FileName,
568  _In_ int _LineNumber
569  );
570 
571  #define _malloca_dbg(s, t, f, l) _malloc_dbg(s, t, f, l)
572  #define _freea_dbg(p, t) _free_dbg(p, t)
573 
574  #if defined __cplusplus && defined _CRTDBG_MAP_ALLOC
575  namespace std
576  {
581  }
582  #endif
583 
584 #endif // _DEBUG
585 
586 
587 
588 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
589 //
590 // Debug Reporting
591 //
592 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
593 
594 #ifndef _DEBUG
595 
596  #define _CrtSetDebugFillThreshold(t) ((size_t)0)
597  #define _CrtSetReportFile(t, f) ((_HFILE)0)
598  #define _CrtSetReportMode(t, f) ((int)0)
599  #define _CrtGetReportHook() ((_CRT_REPORT_HOOK)0)
600  #define _CrtSetReportHook(f) ((_CRT_REPORT_HOOK)0)
601  #define _CrtSetReportHook2(t, f) ((int)0)
602  #define _CrtSetReportHookW2(t, f) ((int)0)
603 
604 #else // ^^^ !_DEBUG ^^^ // vvv _DEBUG vvv //
605 
606  _ACRTIMP int __cdecl _CrtDbgReport(
607  _In_ int _ReportType,
608  _In_opt_z_ char const* _FileName,
609  _In_ int _Linenumber,
610  _In_opt_z_ char const* _ModuleName,
611  _In_opt_z_ char const* _Format,
612  ...);
613 
614  _ACRTIMP int __cdecl _CrtDbgReportW(
615  _In_ int _ReportType,
616  _In_opt_z_ wchar_t const* _FileName,
617  _In_ int _LineNumber,
618  _In_opt_z_ wchar_t const* _ModuleName,
619  _In_opt_z_ wchar_t const* _Format,
620  ...);
621 
622 
623  _ACRTIMP int __cdecl _VCrtDbgReportA(
624  _In_ int _ReportType,
625  _In_opt_ void* _ReturnAddress,
626  _In_opt_z_ char const* _FileName,
627  _In_ int _LineNumber,
628  _In_opt_z_ char const* _ModuleName,
629  _In_opt_z_ char const* _Format,
631  );
632 
633  _ACRTIMP int __cdecl _VCrtDbgReportW(
634  _In_ int _ReportType,
635  _In_opt_ void* _ReturnAddress,
636  _In_opt_z_ wchar_t const* _FileName,
637  _In_ int _LineNumber,
638  _In_opt_z_ wchar_t const* _ModuleName,
639  _In_opt_z_ wchar_t const* _Format,
641  );
642 
643  _ACRTIMP size_t __cdecl _CrtSetDebugFillThreshold(
644  _In_ size_t _NewDebugFillThreshold
645  );
646 
647  _ACRTIMP size_t __cdecl _CrtGetDebugFillThreshold(void);
648 
650  _In_ int _ReportType,
651  _In_opt_ _HFILE _ReportFile
652  );
653 
654  _ACRTIMP int __cdecl _CrtSetReportMode(
655  _In_ int _ReportType,
656  _In_ int _ReportMode
657  );
658 
659  #ifndef _M_CEE_PURE
660 
661  extern long _crtAssertBusy;
662 
663  _ACRTIMP _CRT_REPORT_HOOK __cdecl _CrtGetReportHook(void);
664 
665  // _CrtSetReportHook[[W]2]:
666  // For IJW, we need two versions: one for clrcall and one for cdecl.
667  // For pure and native, we just need clrcall and cdecl, respectively.
668  _ACRTIMP _CRT_REPORT_HOOK __cdecl _CrtSetReportHook(
669  _In_opt_ _CRT_REPORT_HOOK _PFnNewHook
670  );
671 
672  _ACRTIMP int __cdecl _CrtSetReportHook2(
673  _In_ int _Mode,
674  _In_opt_ _CRT_REPORT_HOOK _PFnNewHook
675  );
676 
677  _ACRTIMP int __cdecl _CrtSetReportHookW2(
678  _In_ int _Mode,
679  _In_opt_ _CRT_REPORT_HOOKW _PFnNewHook
680  );
681 
682  #endif // !_M_CEE_PURE
683 
684 #endif // _DEBUG
685 
686 
687 
688 
689 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
690 //
691 // Assertions and Error Reporting Macros
692 //
693 //-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
694 #ifndef _DEBUG
695 
696  #define _CrtDbgBreak() ((void)0)
697 
698  #ifndef _ASSERT_EXPR
699  #define _ASSERT_EXPR(expr, msg) ((void)0)
700  #endif
701 
702  #ifndef _ASSERT
703  #define _ASSERT(expr) ((void)0)
704  #endif
705 
706  #ifndef _ASSERTE
707  #define _ASSERTE(expr) ((void)0)
708  #endif
709 
710  #define _RPT0(rptno, msg)
711  #define _RPTN(rptno, msg, ...)
712 
713  #define _RPTW0(rptno, msg)
714  #define _RPTWN(rptno, msg, ...)
715 
716  #define _RPTF0(rptno, msg)
717  #define _RPTFN(rptno, msg, ...)
718 
719  #define _RPTFW0(rptno, msg)
720  #define _RPTFWN(rptno, msg, ...)
721 
722 #else // ^^^ !_DEBUG ^^^ // vvv _DEBUG vvv //
723 
724  #define _CrtDbgBreak() __debugbreak()
725 
726  // !! is used to ensure that any overloaded operators used to evaluate expr
727  // do not end up at &&.
728  #ifndef _ASSERT_EXPR
729  #define _ASSERT_EXPR(expr, msg) \
730  (void)( \
731  (!!(expr)) || \
732  (1 != _CrtDbgReportW(_CRT_ASSERT, _CRT_WIDE(__FILE__), __LINE__, NULL, L"%ls", msg)) || \
733  (_CrtDbgBreak(), 0) \
734  )
735  #endif
736 
737  #ifndef _ASSERT
738  #define _ASSERT(expr) _ASSERT_EXPR((expr), NULL)
739  #endif
740 
741  #ifndef _ASSERTE
742  #define _ASSERTE(expr) _ASSERT_EXPR((expr), _CRT_WIDE(#expr))
743  #endif
744 
745  #define _RPT_BASE(...) \
746  (void) ((1 != _CrtDbgReport(__VA_ARGS__)) || \
747  (_CrtDbgBreak(), 0))
748 
749  #define _RPT_BASE_W(...) \
750  (void) ((1 != _CrtDbgReportW(__VA_ARGS__)) || \
751  (_CrtDbgBreak(), 0))
752 
753  #define _RPT0(rptno, msg) _RPT_BASE(rptno, NULL, 0, NULL, "%s", msg)
754  #define _RPTN(rptno, msg, ...) _RPT_BASE(rptno, NULL, 0, NULL, msg, __VA_ARGS__)
755 
756  #define _RPTW0(rptno, msg) _RPT_BASE_W(rptno, NULL, 0, NULL, L"%ls", msg)
757  #define _RPTWN(rptno, msg, ...) _RPT_BASE_W(rptno, NULL, 0, NULL, msg, __VA_ARGS__)
758 
759  #define _RPTF0(rptno, msg) _RPT_BASE(rptno, __FILE__, __LINE__, NULL, "%s", msg)
760  #define _RPTFN(rptno, msg, ...) _RPT_BASE(rptno, __FILE__, __LINE__, NULL, msg, __VA_ARGS__)
761 
762  #define _RPTFW0(rptno, msg) _RPT_BASE_W(rptno, _CRT_WIDE(__FILE__), __LINE__, NULL, L"%ls", msg)
763  #define _RPTFWN(rptno, msg, ...) _RPT_BASE_W(rptno, _CRT_WIDE(__FILE__), __LINE__, NULL, msg, __VA_ARGS__)
764 
765 #endif // _DEBUG
766 
767 // Asserts in debug. Invokes Watson in both debug and release
768 #define _ASSERT_AND_INVOKE_WATSON(expr) \
769  { \
770  _ASSERTE((expr)); \
771  if (!(expr)) \
772  { \
773  _invoke_watson(_CRT_WIDE(#expr), __FUNCTIONW__, __FILEW__, __LINE__, 0); \
774  } \
775  }
776 
777 // _ASSERT_BASE is provided only for backwards compatibility.
778 #ifndef _ASSERT_BASE
779  #define _ASSERT_BASE _ASSERT_EXPR
780 #endif
781 
782 #define _RPT1 _RPTN
783 #define _RPT2 _RPTN
784 #define _RPT3 _RPTN
785 #define _RPT4 _RPTN
786 #define _RPT5 _RPTN
787 
788 #define _RPTW1 _RPTWN
789 #define _RPTW2 _RPTWN
790 #define _RPTW3 _RPTWN
791 #define _RPTW4 _RPTWN
792 #define _RPTW5 _RPTWN
793 
794 #define _RPTF1 _RPTFN
795 #define _RPTF2 _RPTFN
796 #define _RPTF3 _RPTFN
797 #define _RPTF4 _RPTFN
798 #define _RPTF5 _RPTFN
799 
800 #define _RPTFW1 _RPTFWN
801 #define _RPTFW2 _RPTFWN
802 #define _RPTFW3 _RPTFWN
803 #define _RPTFW4 _RPTFWN
804 #define _RPTFW5 _RPTFWN
805 
806 
807 
#define _Out_
Definition: sal.h:342
return
Definition: corecrt_memcpy_s.h:60
#define _tempnam_dbg(s1, s2, t, f, l)
Definition: crtdbg.h:271
#define _MAX_BLOCKS
Definition: crtdbg.h:98
#define _ACRTIMP
Definition: corecrt.h:27
struct _CrtMemState _CrtMemState
_Pre_notnull_ _In_opt_z_ wchar_t const _Drive
Definition: corecrt_wstdlib.h:366
void(__CRTDECL * _CRT_DUMP_CLIENT)(void *, size_t)
Definition: crtdbg.h:107
#define _Out_opt_
Definition: sal.h:343
#define _CrtCheckMemory()
Definition: crtdbg.h:132
#define _CrtDumpMemoryLeaks()
Definition: crtdbg.h:134
_Check_return_ _Ret_maybenull_ _In_ size_t _Alignment
Definition: corecrt_malloc.h:153
#define _CrtGetAllocHook()
Definition: crtdbg.h:126
#define _Ret_maybenull_
Definition: sal.h:526
unsigned int size_t
Definition: sourceannotations.h:19
#define _CrtDoForAllClientObjects(f, c)
Definition: crtdbg.h:133
#define _Out_writes_opt_z_(size)
Definition: sal.h:350
size_t lSizes[_MAX_BLOCKS]
Definition: crtdbg.h:119
_In_z_ wchar_t const * _Path
Definition: corecrt_wstdlib.h:337
_In_ long
Definition: corecrt_wstdlib.h:88
#define _aligned_free_dbg(p)
Definition: crtdbg.h:252
int errno_t
Definition: corecrt.h:476
#define _CrtMemCheckpoint(s)
Definition: crtdbg.h:138
#define _getcwd_dbg(s, le, t, f, l)
Definition: crtdbg.h:266
_In_ int _Pre_notnull_ _Post_z_ char * _DstBuf
Definition: stdlib.h:1329
#define _Check_return_wat_
Definition: corecrt.h:102
#define _Post_invalid_
Definition: sal.h:692
STL namespace.
#define _CrtMemDifference(s1, s2, s3)
Definition: crtdbg.h:139
#define _CrtSetReportFile(t, f)
Definition: crtdbg.h:597
_CRT_BEGIN_C_HEADER _Check_return_ _Ret_maybenull_ _In_ size_t _Size
Definition: corecrt_malloc.h:58
#define _CRT_BEGIN_C_HEADER
Definition: vcruntime.h:73
#define _Outptr_result_buffer_maybenull_(size)
Definition: sal.h:461
#define _aligned_realloc_dbg(p, s, a, f, l)
Definition: crtdbg.h:258
#define _CrtSetBreakAlloc(a)
Definition: crtdbg.h:143
_Check_return_ _In_z_ _Scanf_format_string_ wchar_t const *const _Format
Definition: corecrt_wstdio.h:855
size_t lCounts[_MAX_BLOCKS]
Definition: crtdbg.h:118
#define _CrtMemDumpAllObjectsSince(s)
Definition: crtdbg.h:140
#define _CrtIsMemoryBlock(p, t, r, f, l)
Definition: crtdbg.h:135
#define _wfullpath_dbg(s1, s2, le, t, f, l)
Definition: crtdbg.h:274
struct _CrtMemBlockHeader * pBlockHeader
Definition: crtdbg.h:117
#define _aligned_offset_realloc_dbg(p, s, a, o, f, l)
Definition: crtdbg.h:256
_CRT_BEGIN_C_HEADER typedef void * _HFILE
Definition: crtdbg.h:18
#define _aligned_malloc_dbg(s, a, f, l)
Definition: crtdbg.h:253
#define _aligned_offset_malloc_dbg(s, a, o, f, l)
Definition: crtdbg.h:255
#define __CRTDECL
Definition: vcruntime.h:156
#define _CrtIsValidPointer(p, n, r)
Definition: crtdbg.h:137
#define _Pre_maybenull_
Definition: sal.h:678
#define _In_opt_z_
Definition: sal.h:311
#define _realloc_dbg(p, s, t, f, l)
Definition: crtdbg.h:249
#define _Check_return_
Definition: sal.h:554
_String
Definition: corecrt_wstring.h:355
#define _In_z_
Definition: sal.h:310
#define _In_
Definition: sal.h:305
#define _wdupenv_s_dbg(ps1, size, s2, t, f, l)
Definition: crtdbg.h:273
#define _CrtIsValidHeapPointer(p)
Definition: crtdbg.h:136
#define _wgetdcwd_dbg(d, s, le, t, f, l)
Definition: crtdbg.h:276
#define _In_opt_
Definition: sal.h:306
#define _CrtSetAllocHook(f)
Definition: crtdbg.h:127
#define _DCRTIMP
Definition: corecrt.h:43
size_t lTotalCount
Definition: crtdbg.h:121
#define _msize_dbg(p, t)
Definition: crtdbg.h:248
_In_ size_t _Deref_pre_opt_z_ char const _In_ size_t _Inout_ mbstate_t * _State
Definition: wchar.h:78
_Check_return_ _In_z_ wchar_t const * _Mode
Definition: corecrt_wstdio.h:133
#define _dupenv_s_dbg(ps1, size, s2, t, f, l)
Definition: crtdbg.h:264
_CRT_BEGIN_C_HEADER typedef void(__CRTDECL *terminate_handler)()
#define _recalloc_dbg(p, c, s, t, f, l)
Definition: crtdbg.h:250
char int *typedef int(__CRTDECL *_CRT_REPORT_HOOKW)(int
Definition: crtdbg.h:45
#define _CrtMemDumpStatistics(s)
Definition: crtdbg.h:141
#define _CRTALLOCATOR
Definition: corecrt.h:56
_CRT_BEGIN_C_HEADER _In_ int _SizeInWords
Definition: corecrt_wdirect.h:25
#define _Ret_maybenull_z_
Definition: sal.h:522
#define _free_dbg(p, t)
Definition: crtdbg.h:246
#define _CrtSetReportHook2(t, f)
Definition: crtdbg.h:601
Definition: crtdbg.h:115
size_t lHighWaterCount
Definition: crtdbg.h:120
#define _CrtSetDumpClient(f)
Definition: crtdbg.h:130
#define _wtempnam_dbg(s1, s2, t, f, l)
Definition: crtdbg.h:278
_In_opt_z_ wchar_t const _In_opt_z_ wchar_t const * _FileName
Definition: corecrt.h:253
#define _strdup_dbg(s, t, f, l)
Definition: crtdbg.h:270
#define _expand_dbg(p, s, t, f, l)
Definition: crtdbg.h:245
#define _CRT_END_C_HEADER
Definition: vcruntime.h:76
_Check_return_ _In_z_ wchar_t const _Inout_opt_ _Deref_prepost_opt_z_ wchar_t ** _Context
Definition: corecrt_wstring.h:228
#define _getdcwd_dbg(d, s, le, t, f, l)
Definition: crtdbg.h:267
#define _calloc_dbg(c, s, t, f, l)
Definition: crtdbg.h:244
_Out_opt_ size_t _In_z_ wchar_t const * _VarName
Definition: corecrt_wstdlib.h:415
#define _CrtGetDumpClient()
Definition: crtdbg.h:129
#define _fullpath_dbg(s1, s2, le, t, f, l)
Definition: crtdbg.h:265
#define _CrtSetReportHook(f)
Definition: crtdbg.h:600
_Diff _Count
Definition: algorithm:1941
_Check_return_ _Ret_maybenull_ _In_ size_t _In_ size_t _Offset
Definition: corecrt_malloc.h:159
int(__CRTDECL * _CRT_ALLOC_HOOK)(int, void *, size_t, int, long, unsigned char const *, int)
Definition: crtdbg.h:51
#define _aligned_offset_recalloc_dbg(p, c, s, a, o, f, l)
Definition: crtdbg.h:257
#define _CrtGetReportHook()
Definition: crtdbg.h:599
#define _wgetcwd_dbg(s, le, t, f, l)
Definition: crtdbg.h:275
#define _wcsdup_dbg(s, t, f, l)
Definition: crtdbg.h:272
#define _Post_writable_byte_size_(size)
Definition: sal.h:649
#define _malloc_dbg(s, t, f, l)
Definition: crtdbg.h:247
#define _aligned_msize_dbg(p, a, o)
Definition: crtdbg.h:254
#define _Success_(expr)
Definition: sal.h:256
char * va_list
Definition: vadefs.h:39
#define _CrtReportBlockType(p)
Definition: crtdbg.h:142
#define _Pre_notnull_
Definition: sal.h:677
#define _CrtSetDbgFlag(f)
Definition: crtdbg.h:144
_In_ int _SizeInBytes
Definition: direct.h:61
#define _CrtSetReportHookW2(t, f)
Definition: crtdbg.h:602
#define _CrtSetDebugFillThreshold(t)
Definition: crtdbg.h:596
#define _aligned_recalloc_dbg(p, c, s, a, f, l)
Definition: crtdbg.h:259
#define _CrtSetReportMode(t, f)
Definition: crtdbg.h:598
_Check_return_opt_ _In_opt_ _locale_t const va_list _ArgList
Definition: corecrt_wconio.h:295