DebugNew.h 746 B

123456789101112131415161718192021222324
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. // This file overrides global new to provide file and line information to allocations for easier memory leak detection on MSVC
  4. // compilers. Do not include this file in a compilation unit that uses placement new. Include this file last after other
  5. // includes; e.g. Bullet's include files will cause a compile error if this file is included before them. Also note that
  6. // using DebugNew.h is by no means mandatory, but just a debugging convenience.
  7. #pragma once
  8. #if defined(_MSC_VER) && defined(_DEBUG)
  9. #define _CRTDBG_MAP_ALLOC
  10. #ifdef _malloca
  11. #undef _malloca
  12. #endif
  13. #include <crtdbg.h>
  14. #define _DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
  15. #define new _DEBUG_NEW
  16. #endif