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.

60 lines
1.4 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. //
  3. // Initialization stuff
  4. //
  5. // 9-25-97 sburns
  6. #include "headers.hxx"
  7. unsigned Burnslib::InitializationGuard::counter = 0;
  8. const wchar_t* REG_ADMIN_RUNTIME_OPTIONS = 0;
  9. Burnslib::InitializationGuard::InitializationGuard()
  10. {
  11. if (!counter)
  12. {
  13. REG_ADMIN_RUNTIME_OPTIONS =
  14. L"Software\\Microsoft\\Windows\\CurrentVersion\\AdminDebug\\";
  15. // cause assertion failures to appear in the debugger and the UI
  16. _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_WNDW | _CRTDBG_MODE_DEBUG);
  17. Heap::Initialize();
  18. }
  19. counter++;
  20. }
  21. Burnslib::InitializationGuard::~InitializationGuard()
  22. {
  23. if (--counter == 0)
  24. {
  25. #ifdef LOGGING_BUILD
  26. Log::Cleanup();
  27. #endif
  28. // we have to dump leaks ourselves, as the CRT explicitly disables the
  29. // client dump function before it dumps leaks (if you set the
  30. // _CRTDBG_LEAK_CHECK_DF flag). The downside is that we will also see
  31. // normal blocks that were allocated during static initialization.
  32. // You should pass -D_DEBUG to the compiler to get this extra heap
  33. // checking behavior. (The correct way to do this is to set DEBUG_CRTS=1
  34. // in your build environment)
  35. Heap::DumpMemoryLeaks();
  36. // this must come after the leak dump, as the leak dump resolves symbols
  37. StackTrace::Cleanup();
  38. }
  39. }