summaryrefslogtreecommitdiff
path: root/utils/tfstats/memdbg.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/tfstats/memdbg.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'utils/tfstats/memdbg.h')
-rw-r--r--utils/tfstats/memdbg.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/utils/tfstats/memdbg.h b/utils/tfstats/memdbg.h
new file mode 100644
index 0000000..a9aa169
--- /dev/null
+++ b/utils/tfstats/memdbg.h
@@ -0,0 +1,55 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: declarations to track allocations via replacing the global new operator
+// some of this code was written by Paul Andre LeBlanc
+// <[email protected]> I got it off of dejanews.com
+// usage: new TRACKED object-type
+//
+// $Workfile: $
+// $Date: $
+//
+//------------------------------------------------------------------------------------------------------
+// $Log: $
+//
+// $NoKeywords: $
+//=============================================================================//
+#ifndef MEMDBG_H
+#define MEMDBG_H
+#ifdef WIN32
+#pragma once
+#endif
+
+#ifdef _DEBUG
+#ifdef _MEMDEBUG
+#define _MDEBUG
+#endif
+#endif
+
+#ifdef _MDEBUG
+ #define TRACKED (__FILE__, __LINE__)
+#else
+ #define TRACKED
+#endif
+
+#ifdef _MDEBUG
+void *operator new(size_t size, const char *file, const int line);
+void *operator new[](size_t size, const char *file, const int line);
+void operator delete(void *ptr, const char *file, const int line);
+void operator delete[](void *ptr, const char *file, const int line);
+
+
+//replacing global new for debugging purposes.
+//these were written by me, wes cumberland, not paul andre leblanc
+void* operator new(size_t size);
+void* operator new[](size_t size);
+void operator delete(void* v);
+void operator delete[](void* v);
+#endif
+
+//leave this in, even for release build
+int TFStats_win32_new_handler(size_t sz);
+void TFStats_linux_new_handler(void);
+
+void TFStats_setNewHandler();
+
+#endif // MEMDBG_H