Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-08-18 19:37:31 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-08-18 19:37:31 +0400
commit14d33b3c1fd629ca3ebc2f369b38d9d2ebc09e2e (patch)
tree5304235c3b0bb3f850a0b8e38c96618e9a6cb5aa /source/gameengine/Expressions
parent368262461641f23239c1a7bd2e6fa9d5057902e7 (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/Expressions')
-rw-r--r--source/gameengine/Expressions/BoolValue.h7
-rw-r--r--source/gameengine/Expressions/ConstExpr.h7
-rw-r--r--source/gameengine/Expressions/EmptyValue.h7
-rw-r--r--source/gameengine/Expressions/ErrorValue.h7
-rw-r--r--source/gameengine/Expressions/Expression.h13
-rw-r--r--source/gameengine/Expressions/FloatValue.h6
-rw-r--r--source/gameengine/Expressions/IdentifierExpr.h7
-rw-r--r--source/gameengine/Expressions/IfExpr.h7
-rw-r--r--source/gameengine/Expressions/InputParser.h8
-rw-r--r--source/gameengine/Expressions/IntValue.h6
-rw-r--r--source/gameengine/Expressions/KX_HashedPtr.h11
-rw-r--r--source/gameengine/Expressions/Operator1Expr.h7
-rw-r--r--source/gameengine/Expressions/Operator2Expr.h8
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.h12
-rw-r--r--source/gameengine/Expressions/StringValue.h7
-rw-r--r--source/gameengine/Expressions/Value.h19
-rw-r--r--source/gameengine/Expressions/VectorValue.h7
-rw-r--r--source/gameengine/Expressions/VoidValue.h7
18 files changed, 149 insertions, 4 deletions
diff --git a/source/gameengine/Expressions/BoolValue.h b/source/gameengine/Expressions/BoolValue.h
index 726619e7193..4d0103ec1dd 100644
--- a/source/gameengine/Expressions/BoolValue.h
+++ b/source/gameengine/Expressions/BoolValue.h
@@ -49,6 +49,13 @@ public:
private:
bool m_bool;
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CBoolValue"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif // !defined _BOOLVALUE_H
diff --git a/source/gameengine/Expressions/ConstExpr.h b/source/gameengine/Expressions/ConstExpr.h
index b117140fe70..f48b8d34355 100644
--- a/source/gameengine/Expressions/ConstExpr.h
+++ b/source/gameengine/Expressions/ConstExpr.h
@@ -41,6 +41,13 @@ public:
private:
CValue* m_value;
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CConstExpr"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif // !defined(AFX_CONSTEXPR_H__061ECFC3_BE87_11D1_A51C_00A02472FC58__INCLUDED_)
diff --git a/source/gameengine/Expressions/EmptyValue.h b/source/gameengine/Expressions/EmptyValue.h
index fb6b4a477a6..01029d1655d 100644
--- a/source/gameengine/Expressions/EmptyValue.h
+++ b/source/gameengine/Expressions/EmptyValue.h
@@ -34,6 +34,13 @@ public:
CValue * Calc(VALUE_OPERATOR op, CValue *val);
CValue * CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
virtual CValue* GetReplica();
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CEmptyValue"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif // !defined _EMPTYVALUE_H
diff --git a/source/gameengine/Expressions/ErrorValue.h b/source/gameengine/Expressions/ErrorValue.h
index b4b758feea7..2f65850c4f1 100644
--- a/source/gameengine/Expressions/ErrorValue.h
+++ b/source/gameengine/Expressions/ErrorValue.h
@@ -33,6 +33,13 @@ public:
private:
STR_String m_strErrorText;
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CErrorValue"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif // !defined _ERRORVALUE_H
diff --git a/source/gameengine/Expressions/Expression.h b/source/gameengine/Expressions/Expression.h
index 400a2b7c789..bd346fd0552 100644
--- a/source/gameengine/Expressions/Expression.h
+++ b/source/gameengine/Expressions/Expression.h
@@ -63,6 +63,12 @@ class CBrokenLinkInfo
CExpression* m_pExpr;
bool m_bRestored;
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CBrokenLinkInfo"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
@@ -126,6 +132,13 @@ public:
protected:
int m_refcount;
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CExpression"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif // !defined _EXPRESSION_H
diff --git a/source/gameengine/Expressions/FloatValue.h b/source/gameengine/Expressions/FloatValue.h
index fb75b7c702b..442f0eb6cf8 100644
--- a/source/gameengine/Expressions/FloatValue.h
+++ b/source/gameengine/Expressions/FloatValue.h
@@ -42,6 +42,12 @@ protected:
float m_float;
STR_String* m_pstrRep;
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CFloatValue"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif // !defined _FLOATVALUE_H
diff --git a/source/gameengine/Expressions/IdentifierExpr.h b/source/gameengine/Expressions/IdentifierExpr.h
index b307228c8b9..7c14329f755 100644
--- a/source/gameengine/Expressions/IdentifierExpr.h
+++ b/source/gameengine/Expressions/IdentifierExpr.h
@@ -46,6 +46,13 @@ public:
virtual CExpression* CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks);
virtual void ClearModified();
virtual void BroadcastOperators(VALUE_OPERATOR op);
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CIdentifierExpr"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif //__IDENTIFIER_EXPR
diff --git a/source/gameengine/Expressions/IfExpr.h b/source/gameengine/Expressions/IfExpr.h
index 9ab13dca413..f06718c851f 100644
--- a/source/gameengine/Expressions/IfExpr.h
+++ b/source/gameengine/Expressions/IfExpr.h
@@ -44,6 +44,13 @@ public:
virtual CExpression* CheckLink(std::vector<CBrokenLinkInfo*>& brokenlinks);
virtual void ClearModified();
virtual void BroadcastOperators(VALUE_OPERATOR op);
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CIfExpr"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif // !defined(AFX_IFEXPR_H__1F691841_C5C7_11D1_A863_0000B4542BD8__INCLUDED_)
diff --git a/source/gameengine/Expressions/InputParser.h b/source/gameengine/Expressions/InputParser.h
index 810bdc244a8..0d7eab27aeb 100644
--- a/source/gameengine/Expressions/InputParser.h
+++ b/source/gameengine/Expressions/InputParser.h
@@ -102,7 +102,13 @@ private:
int Priority(int optor);
CExpression *Ex(int i);
CExpression *Expr();
-
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CParser"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif
diff --git a/source/gameengine/Expressions/IntValue.h b/source/gameengine/Expressions/IntValue.h
index 06bf1755749..0513026c4cf 100644
--- a/source/gameengine/Expressions/IntValue.h
+++ b/source/gameengine/Expressions/IntValue.h
@@ -56,6 +56,12 @@ private:
cInt m_int;
STR_String* m_pstrRep;
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CIntValue"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif // !defined _INTVALUE_H
diff --git a/source/gameengine/Expressions/KX_HashedPtr.h b/source/gameengine/Expressions/KX_HashedPtr.h
index b11efb99d68..0b54436147b 100644
--- a/source/gameengine/Expressions/KX_HashedPtr.h
+++ b/source/gameengine/Expressions/KX_HashedPtr.h
@@ -29,6 +29,10 @@
#ifndef __KX_HASHEDPTR
#define __KX_HASHEDPTR
+#ifdef WITH_CXX_GUARDEDALLOC
+#include "MEM_guardedalloc.h"
+#endif
+
unsigned int KX_Hash(void * inDWord);
class CHashedPtr
@@ -44,6 +48,13 @@ public:
{
return rhs.m_valptr == lhs.m_valptr;
}
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CHashedPtr"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif //__KX_HASHEDPTR
diff --git a/source/gameengine/Expressions/Operator1Expr.h b/source/gameengine/Expressions/Operator1Expr.h
index 4a1deb0eca3..c2bc68076a0 100644
--- a/source/gameengine/Expressions/Operator1Expr.h
+++ b/source/gameengine/Expressions/Operator1Expr.h
@@ -46,6 +46,13 @@ public:
private:
VALUE_OPERATOR m_op;
CExpression * m_lhs;
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:COperator1Expr"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif // !defined(AFX_OPERATOR1EXPR_H__A1653901_BF41_11D1_A51C_00A02472FC58__INCLUDED_)
diff --git a/source/gameengine/Expressions/Operator2Expr.h b/source/gameengine/Expressions/Operator2Expr.h
index 4064890bbae..bb26b7c03be 100644
--- a/source/gameengine/Expressions/Operator2Expr.h
+++ b/source/gameengine/Expressions/Operator2Expr.h
@@ -52,7 +52,13 @@ protected:
private:
VALUE_OPERATOR m_op;
-
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:COperator2Expr"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif // !defined _OPERATOR2EXPR_H
diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h
index d68aa9f0410..e9e81dddaaa 100644
--- a/source/gameengine/Expressions/PyObjectPlus.h
+++ b/source/gameengine/Expressions/PyObjectPlus.h
@@ -102,7 +102,7 @@ typedef struct {
// This must be the first line of each
// PyC++ class
-#define Py_Header \
+#define __Py_Header \
public: \
static PyTypeObject Type; \
static PyMethodDef Methods[]; \
@@ -111,6 +111,16 @@ typedef struct {
virtual PyObject *GetProxy() {return GetProxy_Ext(this, &Type);}; \
virtual PyObject *NewProxy(bool py_owns) {return NewProxy_Ext(this, &Type, py_owns);}; \
+
+#ifdef WITH_CXX_GUARDEDALLOC
+#define Py_Header __Py_Header \
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, Type.tp_name); } \
+ void operator delete( void *mem ) { MEM_freeN(mem); } \
+
+#else
+#define Py_Header __Py_Header
+#endif
+
/*
* nonzero values are an error for setattr
* however because of the nested lookups we need to know if the errors
diff --git a/source/gameengine/Expressions/StringValue.h b/source/gameengine/Expressions/StringValue.h
index c580e8fd23a..069eb8d9c24 100644
--- a/source/gameengine/Expressions/StringValue.h
+++ b/source/gameengine/Expressions/StringValue.h
@@ -46,6 +46,13 @@ public:
private:
// data member
STR_String m_strString;
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CStringValue"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif
diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h
index 8c9f99b335e..5f08736afde 100644
--- a/source/gameengine/Expressions/Value.h
+++ b/source/gameengine/Expressions/Value.h
@@ -42,6 +42,10 @@
#include <map> // array functionality for the propertylist
#include "STR_String.h" // STR_String class
+#ifdef WITH_CXX_GUARDEDALLOC
+#include "MEM_guardedalloc.h"
+#endif
+
#ifndef GEN_NO_ASSERT
#undef assert
#define assert(exp) ((void)NULL)
@@ -173,6 +177,13 @@ public:
virtual ~CAction(){
};
virtual void Execute() const =0;
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CAction"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
//
@@ -407,7 +418,6 @@ public: \
class CPropValue : public CValue
{
public:
-
#ifndef NO_EXP_PYTHON_EMBEDDING
CPropValue() :
CValue(),
@@ -436,6 +446,13 @@ public:
protected:
STR_String m_strNewName; // Identification
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CPropValue"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif // !defined _VALUEBASECLASS_H
diff --git a/source/gameengine/Expressions/VectorValue.h b/source/gameengine/Expressions/VectorValue.h
index 19c7dd30076..49fb1e7ea08 100644
--- a/source/gameengine/Expressions/VectorValue.h
+++ b/source/gameengine/Expressions/VectorValue.h
@@ -79,6 +79,13 @@ public:
protected:
double m_vec[3];
double m_transformedvec[3];
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CVectorValue"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif // !defined _VECTORVALUE_H
diff --git a/source/gameengine/Expressions/VoidValue.h b/source/gameengine/Expressions/VoidValue.h
index 10a6ff9ad3d..50ec4ff1ee7 100644
--- a/source/gameengine/Expressions/VoidValue.h
+++ b/source/gameengine/Expressions/VoidValue.h
@@ -59,6 +59,13 @@ public:
/// Data members
bool m_bDeleteOnDestruct;
void* m_pAnything;
+
+
+#ifdef WITH_CXX_GUARDEDALLOC
+public:
+ void *operator new( unsigned int num_bytes) { return MEM_mallocN(num_bytes, "GE:CVoidValue"); }
+ void operator delete( void *mem ) { MEM_freeN(mem); }
+#endif
};
#endif // !defined _VOIDVALUE_H