|
4 | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
5 | 5 | */
|
6 | 6 | #include <crtdefs.h>
|
| 7 | +#include <sal.h> |
7 | 8 |
|
8 | 9 | #ifndef _INC_CRTDBG
|
9 | 10 | #define _INC_CRTDBG
|
@@ -107,6 +108,8 @@ extern "C" {
|
107 | 108 | #endif
|
108 | 109 | #endif
|
109 | 110 |
|
| 111 | +#ifndef _DEBUG |
| 112 | + |
110 | 113 | #ifndef _ASSERT
|
111 | 114 | #define _ASSERT(expr) ((void)0)
|
112 | 115 | #endif
|
@@ -214,6 +217,227 @@ extern "C" {
|
214 | 217 | #define _CrtSetCheckCount(f) ((int)0)
|
215 | 218 | #define _CrtGetCheckCount() ((int)0)
|
216 | 219 |
|
| 220 | +#else /* _DEBUG */ |
| 221 | + |
| 222 | +_CRTIMP long * __cdecl __p__crtAssertBusy(void); |
| 223 | +#define _crtAssertBusy (*__p__crtAssertBusy()) |
| 224 | + |
| 225 | +_CRTIMP _CRT_REPORT_HOOK __cdecl _CrtGetReportHook(void); |
| 226 | +_CRTIMP _CRT_REPORT_HOOK __cdecl _CrtSetReportHook(_CRT_REPORT_HOOK _PFnNewHook); |
| 227 | +_CRTIMP int __cdecl _CrtSetReportHook2(int _Mode, _CRT_REPORT_HOOK _PFnNewHook); |
| 228 | +_CRTIMP int __cdecl _CrtSetReportHookW2(int _Mode, _CRT_REPORT_HOOKW _PFnNewHook); |
| 229 | +_CRTIMP int __cdecl _CrtSetReportMode(int _ReportType, int _ReportMode); |
| 230 | +_CRTIMP _HFILE __cdecl _CrtSetReportFile(int _ReportType, _HFILE _ReportFile); |
| 231 | +_CRTIMP int __cdecl _CrtDbgReport(int _ReportType, const char * _Filename, int _Linenumber, const char * _ModuleName, const char * _Format, ...); |
| 232 | +_CRTIMP size_t __cdecl _CrtSetDebugFillThreshold(size_t _NewDebugFillThreshold); |
| 233 | +_CRTIMP int __cdecl _CrtDbgReportW(int _ReportType, const wchar_t * _Filename, int _LineNumber, const wchar_t * _ModuleName, const wchar_t * _Format, ...); |
| 234 | + |
| 235 | +#define _ASSERT_EXPR(expr, msg) \ |
| 236 | + (void) ((!!(expr)) || \ |
| 237 | + (1 != _CrtDbgReportW(_CRT_ASSERT, _CRT_WIDE(__FILE__), __LINE__, NULL, msg)) || \ |
| 238 | + (_CrtDbgBreak(), 0)) |
| 239 | + |
| 240 | +#ifndef _ASSERT |
| 241 | +#define _ASSERT(expr) _ASSERT_EXPR((expr), NULL) |
| 242 | +#endif |
| 243 | + |
| 244 | +#ifndef _ASSERTE |
| 245 | +#define _ASSERTE(expr) _ASSERT_EXPR((expr), _CRT_WIDE(#expr)) |
| 246 | +#endif |
| 247 | + |
| 248 | +#ifndef _ASSERT_BASE |
| 249 | +#define _ASSERT_BASE _ASSERT_EXPR |
| 250 | +#endif |
| 251 | + |
| 252 | +#define _RPT_BASE(args) \ |
| 253 | + (void) ((1 != _CrtDbgReport args) || \ |
| 254 | + (_CrtDbgBreak(), 0)) |
| 255 | + |
| 256 | +#define _RPT_BASE_W(args) \ |
| 257 | + (void) ((1 != _CrtDbgReportW args) || \ |
| 258 | + (_CrtDbgBreak(), 0)) |
| 259 | + |
| 260 | +#define _RPT0(rptno, msg) \ |
| 261 | + _RPT_BASE((rptno, NULL, 0, NULL, "%s", msg)) |
| 262 | + |
| 263 | +#define _RPTW0(rptno, msg) \ |
| 264 | + _RPT_BASE_W((rptno, NULL, 0, NULL, L"%s", msg)) |
| 265 | + |
| 266 | +#define _RPT1(rptno, msg, arg1) \ |
| 267 | + _RPT_BASE((rptno, NULL, 0, NULL, msg, arg1)) |
| 268 | + |
| 269 | +#define _RPTW1(rptno, msg, arg1) \ |
| 270 | + _RPT_BASE_W((rptno, NULL, 0, NULL, msg, arg1)) |
| 271 | + |
| 272 | +#define _RPT2(rptno, msg, arg1, arg2) \ |
| 273 | + _RPT_BASE((rptno, NULL, 0, NULL, msg, arg1, arg2)) |
| 274 | + |
| 275 | +#define _RPTW2(rptno, msg, arg1, arg2) \ |
| 276 | + _RPT_BASE_W((rptno, NULL, 0, NULL, msg, arg1, arg2)) |
| 277 | + |
| 278 | +#define _RPT3(rptno, msg, arg1, arg2, arg3) \ |
| 279 | + _RPT_BASE((rptno, NULL, 0, NULL, msg, arg1, arg2, arg3)) |
| 280 | + |
| 281 | +#define _RPTW3(rptno, msg, arg1, arg2, arg3) \ |
| 282 | + _RPT_BASE_W((rptno, NULL, 0, NULL, msg, arg1, arg2, arg3)) |
| 283 | + |
| 284 | +#define _RPT4(rptno, msg, arg1, arg2, arg3, arg4) \ |
| 285 | + _RPT_BASE((rptno, NULL, 0, NULL, msg, arg1, arg2, arg3, arg4)) |
| 286 | + |
| 287 | +#define _RPTW4(rptno, msg, arg1, arg2, arg3, arg4) \ |
| 288 | + _RPT_BASE_W((rptno, NULL, 0, NULL, msg, arg1, arg2, arg3, arg4)) |
| 289 | + |
| 290 | +#define _RPT5(rptno, msg, arg1, arg2, arg3, arg4, arg5) \ |
| 291 | + _RPT_BASE((rptno, NULL, 0, NULL, msg, arg1, arg2, arg3, arg4, arg5)) |
| 292 | + |
| 293 | +#define _RPTW5(rptno, msg, arg1, arg2, arg3, arg4, arg5) \ |
| 294 | + _RPT_BASE_W((rptno, NULL, 0, NULL, msg, arg1, arg2, arg3, arg4, arg5)) |
| 295 | + |
| 296 | +#define _RPTF0(rptno, msg) \ |
| 297 | + _RPT_BASE((rptno, __FILE__, __LINE__, NULL, "%s", msg)) |
| 298 | + |
| 299 | +#define _RPTFW0(rptno, msg) \ |
| 300 | + _RPT_BASE_W((rptno, _CRT_WIDE(__FILE__), __LINE__, NULL, L"%s", msg)) |
| 301 | + |
| 302 | +#define _RPTF1(rptno, msg, arg1) \ |
| 303 | + _RPT_BASE((rptno, __FILE__, __LINE__, NULL, msg, arg1)) |
| 304 | + |
| 305 | +#define _RPTFW1(rptno, msg, arg1) \ |
| 306 | + _RPT_BASE_W((rptno, _CRT_WIDE(__FILE__), __LINE__, NULL, msg, arg1)) |
| 307 | + |
| 308 | +#define _RPTF2(rptno, msg, arg1, arg2) \ |
| 309 | + _RPT_BASE((rptno, __FILE__, __LINE__, NULL, msg, arg1, arg2)) |
| 310 | + |
| 311 | +#define _RPTFW2(rptno, msg, arg1, arg2) \ |
| 312 | + _RPT_BASE_W((rptno, _CRT_WIDE(__FILE__), __LINE__, NULL, msg, arg1, arg2)) |
| 313 | + |
| 314 | +#define _RPTF3(rptno, msg, arg1, arg2, arg3) \ |
| 315 | + _RPT_BASE((rptno, __FILE__, __LINE__, NULL, msg, arg1, arg2, arg3)) |
| 316 | + |
| 317 | +#define _RPTFW3(rptno, msg, arg1, arg2, arg3) \ |
| 318 | + _RPT_BASE_W((rptno, _CRT_WIDE(__FILE__), __LINE__, NULL, msg, arg1, arg2, arg3)) |
| 319 | + |
| 320 | +#define _RPTF4(rptno, msg, arg1, arg2, arg3, arg4) \ |
| 321 | + _RPT_BASE((rptno, __FILE__, __LINE__, NULL, msg, arg1, arg2, arg3, arg4)) |
| 322 | + |
| 323 | +#define _RPTFW4(rptno, msg, arg1, arg2, arg3, arg4) \ |
| 324 | + _RPT_BASE_W((rptno, _CRT_WIDE(__FILE__), __LINE__, NULL, msg, arg1, arg2, arg3, arg4)) |
| 325 | + |
| 326 | +#define _RPTF5(rptno, msg, arg1, arg2, arg3, arg4, arg5) \ |
| 327 | + _RPT_BASE((rptno, __FILE__, __LINE__, NULL, msg, arg1, arg2, arg3, arg4, arg5)) |
| 328 | + |
| 329 | +#define _RPTFW5(rptno, msg, arg1, arg2, arg3, arg4, arg5) \ |
| 330 | + _RPT_BASE_W((rptno, _CRT_WIDE(__FILE__), __LINE__, NULL, msg, arg1, arg2, arg3, arg4, arg5)) |
| 331 | + |
| 332 | +#define _CrtDbgBreak() __debugbreak() |
| 333 | + |
| 334 | +#ifdef _CRTDBG_MAP_ALLOC |
| 335 | + |
| 336 | +#define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 337 | +#define calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 338 | +#define realloc(p, s) _realloc_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 339 | +#define _recalloc(p, c, s) _recalloc_dbg(p, c, s, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 340 | +#define _expand(p, s) _expand_dbg(p, s, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 341 | +#define free(p) _free_dbg(p, _NORMAL_BLOCK) |
| 342 | +#define _msize(p) _msize_dbg(p, _NORMAL_BLOCK) |
| 343 | +#define _aligned_msize(p, a, o) _aligned_msize_dbg(p, a, o) |
| 344 | +#define _aligned_malloc(s, a) _aligned_malloc_dbg(s, a, __FILE__, __LINE__) |
| 345 | +#define _aligned_realloc(p, s, a) _aligned_realloc_dbg(p, s, a, __FILE__, __LINE__) |
| 346 | +#define _aligned_recalloc(p, c, s, a) _aligned_recalloc_dbg(p, c, s, a, __FILE__, __LINE__) |
| 347 | +#define _aligned_offset_malloc(s, a, o) _aligned_offset_malloc_dbg(s, a, o, __FILE__, __LINE__) |
| 348 | +#define _aligned_offset_realloc(p, s, a, o) _aligned_offset_realloc_dbg(p, s, a, o, __FILE__, __LINE__) |
| 349 | +#define _aligned_offset_recalloc(p, c, s, a, o) _aligned_offset_recalloc_dbg(p, c, s, a, o, __FILE__, __LINE__) |
| 350 | +#define _aligned_free(p) _aligned_free_dbg(p) |
| 351 | + |
| 352 | +#define _malloca(s) _malloca_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 353 | +#define _freea(p) _freea_dbg(p, _NORMAL_BLOCK) |
| 354 | + |
| 355 | +#define _strdup(s) _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 356 | +#define _wcsdup(s) _wcsdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 357 | +#define _mbsdup(s) _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 358 | +#define _tempnam(s1, s2) _tempnam_dbg(s1, s2, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 359 | +#define _wtempnam(s1, s2) _wtempnam_dbg(s1, s2, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 360 | +#define _fullpath(s1, s2, le) _fullpath_dbg(s1, s2, le, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 361 | +#define _wfullpath(s1, s2, le) _wfullpath_dbg(s1, s2, le, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 362 | +#define _getcwd(s, le) _getcwd_dbg(s, le, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 363 | +#define _wgetcwd(s, le) _wgetcwd_dbg(s, le, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 364 | +#define _getdcwd(d, s, le) _getdcwd_dbg(d, s, le, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 365 | +#define _wgetdcwd(d, s, le) _wgetdcwd_dbg(d, s, le, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 366 | +#define _getdcwd_nolock(d, s, le) _getdcwd_lk_dbg(d, s, le, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 367 | +#define _wgetdcwd_nolock(d, s, le) _wgetdcwd_lk_dbg(d, s, le, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 368 | +#define _dupenv_s(ps1, size, s2) _dupenv_s_dbg(ps1, size, s2, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 369 | +#define _wdupenv_s(ps1, size, s2) _wdupenv_s_dbg(ps1, size, s2, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 370 | + |
| 371 | +#define strdup(s) _strdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 372 | +#define wcsdup(s) _wcsdup_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 373 | +#define tempnam(s1, s2) _tempnam_dbg(s1, s2, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 374 | +#define getcwd(s, le) _getcwd_dbg(s, le, _NORMAL_BLOCK, __FILE__, __LINE__) |
| 375 | + |
| 376 | +#endif /* _CRTDBG_MAP_ALLOC */ |
| 377 | + |
| 378 | +_CRTIMP long * __cdecl __p__crtBreakAlloc(void); |
| 379 | +#define _crtBreakAlloc (*__p__crtBreakAlloc()) |
| 380 | + |
| 381 | +_CRTIMP long __cdecl _CrtSetBreakAlloc(long _BreakAlloc); |
| 382 | + |
| 383 | +_CRTIMP __checkReturn void * __cdecl _malloc_dbg(size_t _Size, int _BlockType, const char * _Filename, int _LineNumber); |
| 384 | +_CRTIMP __checkReturn void * __cdecl _calloc_dbg(size_t _NumOfElements, size_t _SizeOfElements, int _BlockType, const char * _Filename, int _LineNumber); |
| 385 | +_CRTIMP __checkReturn void * __cdecl _realloc_dbg(void * _Memory, size_t _NewSize, int _BlockType, const char * _Filename, int _LineNumber); |
| 386 | +_CRTIMP __checkReturn void * __cdecl _recalloc_dbg(void * _Memory, size_t _NumOfElements, size_t _SizeOfElements, int _BlockType, const char * _Filename, int _LineNumber); |
| 387 | +_CRTIMP __checkReturn void * __cdecl _expand_dbg(void * _Memory, size_t _NewSize, int _BlockType, const char * _Filename, int _LineNumber); |
| 388 | +_CRTIMP void __cdecl _free_dbg(void * _Memory, int _BlockType); |
| 389 | +_CRTIMP size_t __cdecl _msize_dbg(void * _Memory, int _BlockType); |
| 390 | +_CRTIMP size_t __cdecl _aligned_msize_dbg(void * _Memory, size_t _Alignment, size_t _Offset); |
| 391 | +_CRTIMP __checkReturn void * __cdecl _aligned_malloc_dbg(size_t _Size, size_t _Alignment, const char * _Filename, int _LineNumber); |
| 392 | +_CRTIMP __checkReturn void * __cdecl _aligned_realloc_dbg(void * _Memory, size_t _Size, size_t _Alignment, const char * _Filename, int _LineNumber); |
| 393 | +_CRTIMP __checkReturn void * __cdecl _aligned_recalloc_dbg(void * _Memory, size_t _NumOfElements, size_t _SizeOfElements, size_t _Alignment, const char * _Filename, int _LineNumber); |
| 394 | +_CRTIMP __checkReturn void * __cdecl _aligned_offset_malloc_dbg(size_t _Size, size_t _Alignment, size_t _Offset, const char * _Filename, int _LineNumber); |
| 395 | +_CRTIMP __checkReturn void * __cdecl _aligned_offset_realloc_dbg(void * _Memory, size_t _Size, size_t _Alignment, size_t _Offset, const char * _Filename, int _LineNumber); |
| 396 | +_CRTIMP __checkReturn void * __cdecl _aligned_offset_recalloc_dbg(void * _Memory, size_t _NumOfElements, size_t _SizeOfElements, size_t _Alignment, size_t _Offset, const char * _Filename, int _LineNumber); |
| 397 | +_CRTIMP void __cdecl _aligned_free_dbg(void * _Memory); |
| 398 | +_CRTIMP __checkReturn char * __cdecl _strdup_dbg(const char * _Str, int _BlockType, const char * _Filename, int _LineNumber); |
| 399 | +_CRTIMP __checkReturn wchar_t * __cdecl _wcsdup_dbg(const wchar_t * _Str, int _BlockType, const char * _Filename, int _LineNumber); |
| 400 | +_CRTIMP __checkReturn char * __cdecl _tempnam_dbg(const char * _DirName, const char * _FilePrefix, int _BlockType, const char * _Filename, int _LineNumber); |
| 401 | +_CRTIMP __checkReturn wchar_t * __cdecl _wtempnam_dbg(const wchar_t * _DirName, const wchar_t * _FilePrefix, int _BlockType, const char * _Filename, int _LineNumber); |
| 402 | +_CRTIMP __checkReturn char * __cdecl _fullpath_dbg(char * _FullPath, const char * _Path, size_t _SizeInBytes, int _BlockType, const char * _Filename, int _LineNumber); |
| 403 | +_CRTIMP __checkReturn wchar_t * __cdecl _wfullpath_dbg(wchar_t * _FullPath, const wchar_t * _Path, size_t _SizeInWords, int _BlockType, const char * _Filename, int _LineNumber); |
| 404 | +_CRTIMP __checkReturn char * __cdecl _getcwd_dbg(char * _DstBuf, int _SizeInBytes, int _BlockType, const char * _Filename, int _LineNumber); |
| 405 | +_CRTIMP __checkReturn wchar_t * __cdecl _wgetcwd_dbg(wchar_t * _DstBuf, int _SizeInWords, int _BlockType, const char * _Filename, int _LineNumber); |
| 406 | +_CRTIMP __checkReturn char * __cdecl _getdcwd_dbg(int _Drive, char * _DstBuf, int _SizeInBytes, int _BlockType, const char * _Filename, int _LineNumber); |
| 407 | +_CRTIMP __checkReturn wchar_t * __cdecl _wgetdcwd_dbg(int _Drive, wchar_t * _DstBuf, int _SizeInWords, int _BlockType, const char * _Filename, int _LineNumber); |
| 408 | +__checkReturn char * __cdecl _getdcwd_lk_dbg(int _Drive, char * _DstBuf, int _SizeInBytes, int _BlockType, const char * _Filename, int _LineNumber); |
| 409 | +__checkReturn wchar_t * __cdecl _wgetdcwd_lk_dbg(int _Drive, wchar_t * _DstBuf, int _SizeInWords, int _BlockType, const char * _Filename, int _LineNumber); |
| 410 | +_CRTIMP __checkReturn errno_t __cdecl _dupenv_s_dbg(char ** _PBuffer, size_t * _PBufferSizeInBytes, const char * _VarName, int _BlockType, const char * _Filename, int _LineNumber); |
| 411 | +_CRTIMP __checkReturn errno_t __cdecl _wdupenv_s_dbg(wchar_t ** _PBuffer, size_t * _PBufferSizeInWords, const wchar_t * _VarName, int _BlockType, const char * _Filename, int _LineNumber); |
| 412 | + |
| 413 | +#define _malloca_dbg(s, t, f, l) _malloc_dbg(s, t, f, l) |
| 414 | +#define _freea_dbg(p, t) _free_dbg(p, t) |
| 415 | + |
| 416 | +_CRTIMP _CRT_ALLOC_HOOK __cdecl _CrtGetAllocHook(void); |
| 417 | +_CRTIMP _CRT_ALLOC_HOOK __cdecl _CrtSetAllocHook(_CRT_ALLOC_HOOK _PfnNewHook); |
| 418 | + |
| 419 | +_CRTIMP int * __cdecl __p__crtDbgFlag(void); |
| 420 | +#define _crtDbgFlag (*__p__crtDbgFlag()) |
| 421 | + |
| 422 | +_CRTIMP int __cdecl _CrtCheckMemory(void); |
| 423 | +_CRTIMP int __cdecl _CrtSetDbgFlag(int _NewFlag); |
| 424 | +_CRTIMP void __cdecl _CrtDoForAllClientObjects(void (__cdecl *_PFn)(void *, void *), void * _Context); |
| 425 | +_CRTIMP __checkReturn int __cdecl _CrtIsValidPointer(const void * _Ptr, unsigned int _Bytes, int _ReadWrite); |
| 426 | +_CRTIMP __checkReturn int __cdecl _CrtIsValidHeapPointer(const void * _HeapPtr); |
| 427 | +_CRTIMP int __cdecl _CrtIsMemoryBlock(const void * _Memory, unsigned int _Bytes, long * _RequestNumber, char ** _Filename, int * _LineNumber); |
| 428 | +_CRTIMP __checkReturn int __cdecl _CrtReportBlockType(const void * _Memory); |
| 429 | +_CRTIMP _CRT_DUMP_CLIENT __cdecl _CrtGetDumpClient(void); |
| 430 | +_CRTIMP _CRT_DUMP_CLIENT __cdecl _CrtSetDumpClient(_CRT_DUMP_CLIENT _PFnNewDump); |
| 431 | +_CRTIMP _CRT_MANAGED_HEAP_DEPRECATE void __cdecl _CrtMemCheckpoint(_CrtMemState * _State); |
| 432 | +_CRTIMP _CRT_MANAGED_HEAP_DEPRECATE int __cdecl _CrtMemDifference(_CrtMemState * _State, const _CrtMemState * _OldState, const _CrtMemState * _NewState); |
| 433 | +_CRTIMP void __cdecl _CrtMemDumpAllObjectsSince(const _CrtMemState * _State); |
| 434 | +_CRTIMP void __cdecl _CrtMemDumpStatistics(const _CrtMemState * _State); |
| 435 | +_CRTIMP int __cdecl _CrtDumpMemoryLeaks(void); |
| 436 | +_CRTIMP int __cdecl _CrtSetCheckCount(int _CheckCount); |
| 437 | +_CRTIMP int __cdecl _CrtGetCheckCount(void); |
| 438 | + |
| 439 | +#endif /* _DEBUG */ |
| 440 | + |
217 | 441 | #ifdef __cplusplus
|
218 | 442 | }
|
219 | 443 | /*
|
|
0 commit comments