Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. dbgnew.hxx
  6. Abstract:
  7. Debug new header file
  8. Author:
  9. Steve Kiraly (SteveKi) 23-June-1998
  10. Revision History:
  11. --*/
  12. #ifndef _DBGNEW_HXX_
  13. #define _DBGNEW_HXX_
  14. /********************************************************************
  15. Debug memory macros.
  16. ********************************************************************/
  17. #if DBG
  18. /********************************************************************
  19. Debug memory macros when using the CRT for memory debug support.
  20. ********************************************************************/
  21. #if DBG_MEMORY_CRT
  22. #ifndef _DEBUG
  23. #define _DEBUG
  24. #endif
  25. #ifndef _CRTDBG_MAP_ALLOC
  26. #define _CRTDBG_MAP_ALLOC
  27. #endif
  28. #include <crtdbg.h>
  29. #define DBG_MEMORY_INIT()\
  30. TDebugNew_CrtMemoryInitalize();\
  31. _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | (_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF));\
  32. #define DBG_MEMORY_RELEASE()\
  33. do {\
  34. if (TDebugNew_IsCrtMemoryInitalized())\
  35. {\
  36. _CrtDumpMemoryLeaks();\
  37. _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & ~(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF));\
  38. }\
  39. } while (0)
  40. #define DBG_MEMORY_DUMP_LEAKS()\
  41. do {\
  42. if (TDebugNew_IsCrtMemoryInitalized())\
  43. {\
  44. _CrtDumpMemoryLeaks();\
  45. }\
  46. } while (0)
  47. #define DBG_MEMORY_VALIDATE()\
  48. do {\
  49. if (TDebugNew_IsCrtMemoryInitalized())\
  50. {\
  51. _CrtCheckMemory();\
  52. }\
  53. } while (0)
  54. #else // not DBG_MEMORY_CRT
  55. #define DBG_MEMORY_INIT() ((void)0) // Stubbed out
  56. #define DBG_MEMORY_RELEASE() ((void)0) // Stubbed out
  57. #define DBG_MEMORY_DUMP_LEAKS() ((void)0) // Stubbed out
  58. #define DBG_MEMORY_VALIDATE() ((void)0) // Stubbed out
  59. #endif // DBG_MEMORY_CRT
  60. #else // not DBG
  61. #define DBG_MEMORY_INIT() // Empty
  62. #define DBG_MEMORY_RELEASE() // Empty
  63. #define DBG_MEMORY_DUMP_LEAKS() // Empty
  64. #define DBG_MEMORY_VALIDATE() // Empty
  65. #endif // DBG
  66. /********************************************************************
  67. Debug memory functions.
  68. ********************************************************************/
  69. #ifdef __cplusplus
  70. extern "C" {
  71. #endif
  72. BOOL
  73. TDebugNew_CrtMemoryInitalize(
  74. VOID
  75. );
  76. BOOL
  77. TDebugNew_IsCrtMemoryInitalized(
  78. VOID
  79. );
  80. #ifdef __cplusplus
  81. }
  82. #endif
  83. #endif // DBGNEW_HXX