diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-08-18 19:37:31 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-08-18 19:37:31 +0400 |
commit | 14d33b3c1fd629ca3ebc2f369b38d9d2ebc09e2e (patch) | |
tree | 5304235c3b0bb3f850a0b8e38c96618e9a6cb5aa /source/gameengine/SceneGraph | |
parent | 368262461641f23239c1a7bd2e6fa9d5057902e7 (diff) |
BGE guardedalloc, Uses WITH_CXX_GUARDEDALLOC but gives a string to MEM_mallocN for better tracking memory usage.
* off by default.
* new/delete are at the bottom of each class
* python BGE objects have the new/delete in the Py_Header macro.
Diffstat (limited to 'source/gameengine/SceneGraph')
-rw-r--r-- | source/gameengine/SceneGraph/SG_BBox.h | 10 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_Controller.h | 6 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_DList.h | 11 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_IObject.h | 7 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_Node.h | 7 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_ParentRelation.h | 8 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_QList.h | 7 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_Spatial.h | 7 | ||||
-rw-r--r-- | source/gameengine/SceneGraph/SG_Tree.h | 13 |
9 files changed, 71 insertions, 5 deletions
diff --git a/source/gameengine/SceneGraph/SG_BBox.h b/source/gameengine/SceneGraph/SG_BBox.h index c39ad268e25..8dbb9869dae 100644 --- a/source/gameengine/SceneGraph/SG_BBox.h +++ b/source/gameengine/SceneGraph/SG_BBox.h @@ -38,6 +38,10 @@ #include <vector> +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class SG_Node; /** @@ -128,6 +132,12 @@ public: friend class SG_Tree; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_BBox"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif /* __SG_BBOX_H__ */ diff --git a/source/gameengine/SceneGraph/SG_Controller.h b/source/gameengine/SceneGraph/SG_Controller.h index c32885b915f..db9d7bdb464 100644 --- a/source/gameengine/SceneGraph/SG_Controller.h +++ b/source/gameengine/SceneGraph/SG_Controller.h @@ -40,6 +40,12 @@ class SG_Controller { public: + +#ifdef WITH_CXX_GUARDEDALLOC + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "SG_Controller"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif + SG_Controller( ) : m_pObject(NULL) { diff --git a/source/gameengine/SceneGraph/SG_DList.h b/source/gameengine/SceneGraph/SG_DList.h index 7bef13cc9e3..3e17fb55dc0 100644 --- a/source/gameengine/SceneGraph/SG_DList.h +++ b/source/gameengine/SceneGraph/SG_DList.h @@ -31,6 +31,10 @@ #include <stdlib.h> +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + /** * Double circular linked list */ @@ -155,6 +159,13 @@ public: { return this; } + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_DList"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__SG_DLIST diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h index 8f448a0e890..23e6c1e9c99 100644 --- a/source/gameengine/SceneGraph/SG_IObject.h +++ b/source/gameengine/SceneGraph/SG_IObject.h @@ -160,8 +160,6 @@ private : SGControllerList m_SGcontrollers; public: - - virtual ~SG_IObject(); @@ -338,6 +336,11 @@ protected : ); +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_IObject"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__SG_IOBJECT diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h index 7c6ef92f670..4281bcd11f6 100644 --- a/source/gameengine/SceneGraph/SG_Node.h +++ b/source/gameengine/SceneGraph/SG_Node.h @@ -40,7 +40,6 @@ typedef std::vector<SG_Node*> NodeList; class SG_Node : public SG_Spatial { public: - SG_Node( void* clientobj, void* clientinfo, @@ -260,6 +259,12 @@ private: */ SG_Node* m_SGparent; + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_Node"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__SG_NODE_H diff --git a/source/gameengine/SceneGraph/SG_ParentRelation.h b/source/gameengine/SceneGraph/SG_ParentRelation.h index 8f45df09b27..a6a43c19115 100644 --- a/source/gameengine/SceneGraph/SG_ParentRelation.h +++ b/source/gameengine/SceneGraph/SG_ParentRelation.h @@ -55,7 +55,6 @@ class SG_Spatial; class SG_ParentRelation { public : - /** * Update the childs local and global coordinates * based upon the parents global coordinates. @@ -128,6 +127,13 @@ protected : SG_ParentRelation( const SG_ParentRelation & ); + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_ParentRelation"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif diff --git a/source/gameengine/SceneGraph/SG_QList.h b/source/gameengine/SceneGraph/SG_QList.h index d8afc33ea4f..6399111d80b 100644 --- a/source/gameengine/SceneGraph/SG_QList.h +++ b/source/gameengine/SceneGraph/SG_QList.h @@ -151,6 +151,13 @@ public: { return m_bqlink; } + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_QList"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__SG_QLIST diff --git a/source/gameengine/SceneGraph/SG_Spatial.h b/source/gameengine/SceneGraph/SG_Spatial.h index 6e274487c9d..a818c8c81f7 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.h +++ b/source/gameengine/SceneGraph/SG_Spatial.h @@ -66,7 +66,6 @@ protected: bool m_ogldirty; // true if the openGL matrix for this object must be recomputed public: - inline void ClearModified() { m_modified = false; @@ -284,6 +283,12 @@ protected: bool& parentUpdated ); + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_Spatial"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif //__SG_SPATIAL_H diff --git a/source/gameengine/SceneGraph/SG_Tree.h b/source/gameengine/SceneGraph/SG_Tree.h index 4741af83aae..6ca3307920e 100644 --- a/source/gameengine/SceneGraph/SG_Tree.h +++ b/source/gameengine/SceneGraph/SG_Tree.h @@ -111,6 +111,13 @@ public: } }; + + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_Tree"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; @@ -148,6 +155,12 @@ public: SG_Tree* MakeTree(); + +#ifdef WITH_CXX_GUARDEDALLOC +public: + void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_TreeFactory"); } + void operator delete( void *mem ) { MEM_freeN(mem); } +#endif }; #endif /* __SG_BBOX_H__ */ |