Leaked source code of windows server 2003
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.

68 lines
1.2 KiB

  1. //
  2. // Copyright (C) 1995 Microsoft Corporation
  3. //
  4. //
  5. #ifndef __HEAPX_H__
  6. #define __HEAPX_H__
  7. #ifdef DBG
  8. #ifdef __DHCP_USE_DEBUG_HEAP__
  9. #include <stdlib.h>
  10. #include <malloc.h>
  11. #define _DEBUG
  12. #define _CRTDBG_MAP_ALLOC
  13. #include <crtdbg.h>
  14. #define HEAPX_NORMAL 0
  15. #define HEAPX_VERIFY 1
  16. #define HEAPX_RETAIN 3
  17. #define INIT_DEBUG_HEAP( Level ) \
  18. { \
  19. int nDbgFlags; \
  20. _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_DEBUG );\
  21. _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_DEBUG );\
  22. _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_DEBUG );\
  23. nDbgFlags = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG ); \
  24. \
  25. if ( Level & HEAPX_VERIFY ) \
  26. { \
  27. nDbgFlags |= _CRTDBG_CHECK_ALWAYS_DF; \
  28. } \
  29. if ( Level & HEAPX_RETAIN ) \
  30. { \
  31. nDbgFlags |= _CRTDBG_DELAY_FREE_MEM_DF; \
  32. } \
  33. _CrtSetDbgFlag( nDbgFlags ); \
  34. }
  35. #define UNINIT_DEBUG_HEAP() \
  36. _ASSERT( _CrtCheckMemory() ); \
  37. _ASSERT( !_CrtDumpMemoryLeaks() );
  38. #else // #ifdef __DHCP_USE_DEBUG_HEAP__
  39. #define INIT_DEBUG_HEAP( Level )
  40. #define UNINIT_DEBUG_HEAP()
  41. #endif
  42. #else // #ifdef DBG
  43. #define INIT_DEBUG_HEAP( Level )
  44. #define UNINIT_DEBUG_HEAP()
  45. #endif
  46. #endif