Team Fortress 2 Source Code as on 22/4/2020
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.

55 lines
1.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: declarations to track allocations via replacing the global new operator
  4. // some of this code was written by Paul Andre LeBlanc
  5. // <[email protected]> I got it off of dejanews.com
  6. // usage: new TRACKED object-type
  7. //
  8. // $Workfile: $
  9. // $Date: $
  10. //
  11. //------------------------------------------------------------------------------------------------------
  12. // $Log: $
  13. //
  14. // $NoKeywords: $
  15. //=============================================================================//
  16. #ifndef MEMDBG_H
  17. #define MEMDBG_H
  18. #ifdef WIN32
  19. #pragma once
  20. #endif
  21. #ifdef _DEBUG
  22. #ifdef _MEMDEBUG
  23. #define _MDEBUG
  24. #endif
  25. #endif
  26. #ifdef _MDEBUG
  27. #define TRACKED (__FILE__, __LINE__)
  28. #else
  29. #define TRACKED
  30. #endif
  31. #ifdef _MDEBUG
  32. void *operator new(size_t size, const char *file, const int line);
  33. void *operator new[](size_t size, const char *file, const int line);
  34. void operator delete(void *ptr, const char *file, const int line);
  35. void operator delete[](void *ptr, const char *file, const int line);
  36. //replacing global new for debugging purposes.
  37. //these were written by me, wes cumberland, not paul andre leblanc
  38. void* operator new(size_t size);
  39. void* operator new[](size_t size);
  40. void operator delete(void* v);
  41. void operator delete[](void* v);
  42. #endif
  43. //leave this in, even for release build
  44. int TFStats_win32_new_handler(size_t sz);
  45. void TFStats_linux_new_handler(void);
  46. void TFStats_setNewHandler();
  47. #endif // MEMDBG_H