diff options
Diffstat (limited to 'mp/src/public/tier0/validator.h')
| -rw-r--r-- | mp/src/public/tier0/validator.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/mp/src/public/tier0/validator.h b/mp/src/public/tier0/validator.h new file mode 100644 index 00000000..8a00f887 --- /dev/null +++ b/mp/src/public/tier0/validator.h @@ -0,0 +1,73 @@ +//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+
+#include "valobject.h"
+
+#ifndef VALIDATOR_H
+#define VALIDATOR_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+
+#ifdef DBGFLAG_VALIDATE
+
+
+class CValidator
+{
+public:
+ // Constructors & destructors
+ CValidator( void );
+ ~CValidator( void );
+
+ // Call this each time we enter a new Validate function
+ void Push( tchar *pchType, void *pvObj, tchar *pchName );
+
+ // Call this each time we exit a Validate function
+ void Pop( void );
+
+ // Claim ownership of a memory block
+ void ClaimMemory( void *pvMem );
+
+ // Finish performing a check and perform necessary computations
+ void Finalize( void );
+
+ // Render our results to the console
+ void RenderObjects( int cubThreshold ); // Render all reported objects
+ void RenderLeaks( void ); // Render all memory leaks
+
+ // List manipulation functions:
+ CValObject *FindObject( void *pvObj ); // Returns CValObject containing pvObj, or NULL.
+ void DiffAgainst( CValidator *pOtherValidator ); // Removes any entries from this validator that are also present in the other.
+
+ // Accessors
+ bool BMemLeaks( void ) { return m_bMemLeaks; };
+ CValObject *PValObjectFirst( void ) { return m_pValObjectFirst; };
+
+ void Validate( CValidator &validator, tchar *pchName ); // Validate our internal structures
+
+
+private:
+ CValObject *m_pValObjectFirst; // Linked list of all ValObjects
+ CValObject *m_pValObjectLast; // Last ValObject on the linked list
+
+ CValObject *m_pValObjectCur; // Object we're current processing
+
+ int m_cpvOwned; // Total # of blocks owned
+
+ int m_cpubLeaked; // # of leaked memory blocks
+ int m_cubLeaked; // Amount of leaked memory
+ bool m_bMemLeaks; // Has any memory leaked?
+};
+
+
+#endif // DBGFLAG_VALIDATE
+
+
+#endif // VALIDATOR_H
|