diff options
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/GHOST_ISystem.h | 9 | ||||
-rw-r--r-- | intern/ghost/GHOST_ISystemPaths.h | 5 | ||||
-rw-r--r-- | intern/ghost/GHOST_ITimerTask.h | 9 | ||||
-rw-r--r-- | intern/ghost/GHOST_Types.h | 6 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_CallbackEventConsumer.h | 4 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_DisplayManager.h | 5 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_EventManager.h | 5 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_SystemPaths.h | 3 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_TimerManager.h | 5 | ||||
-rw-r--r-- | intern/guardedalloc/cpp/mallocn.cpp | 30 |
10 files changed, 57 insertions, 24 deletions
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index bd4f3aed5aa..0bc09077f39 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -415,14 +415,9 @@ protected: /** The one and only system */ static GHOST_ISystem *m_system; + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { - return MEM_mallocN(num_bytes, "GHOST:GHOST_ISystem"); - } - void operator delete(void *mem) { - MEM_freeN(mem); - } + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ISystem") #endif }; diff --git a/intern/ghost/GHOST_ISystemPaths.h b/intern/ghost/GHOST_ISystemPaths.h index ee8bd9d1eda..1ba4ceaaaba 100644 --- a/intern/ghost/GHOST_ISystemPaths.h +++ b/intern/ghost/GHOST_ISystemPaths.h @@ -98,6 +98,11 @@ public: private: /** The one and only system paths*/ static GHOST_ISystemPaths *m_systemPaths; + + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ISystemPaths") +#endif }; #endif diff --git a/intern/ghost/GHOST_ITimerTask.h b/intern/ghost/GHOST_ITimerTask.h index bb4a81be5f8..08c4890939f 100644 --- a/intern/ghost/GHOST_ITimerTask.h +++ b/intern/ghost/GHOST_ITimerTask.h @@ -84,14 +84,9 @@ public: */ virtual void setUserData(const GHOST_TUserDataPtr userData) = 0; + #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { - return MEM_mallocN(num_bytes, "GHOST:GHOST_ITimerTask"); - } - void operator delete(void *mem) { - MEM_freeN(mem); - } + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_ITimerTask") #endif }; diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 8454f338645..4921acde670 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -37,7 +37,11 @@ #include "MEM_guardedalloc.h" #endif -#define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name +#if defined(WITH_CXX_GUARDEDALLOC) && defined(__cplusplus) +# define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; MEM_CXX_CLASS_ALLOC_FUNCS(#name) } *name +#else +# define GHOST_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name +#endif typedef char GHOST_TInt8; typedef unsigned char GHOST_TUns8; diff --git a/intern/ghost/intern/GHOST_CallbackEventConsumer.h b/intern/ghost/intern/GHOST_CallbackEventConsumer.h index 61aef742a48..e13a56c38f4 100644 --- a/intern/ghost/intern/GHOST_CallbackEventConsumer.h +++ b/intern/ghost/intern/GHOST_CallbackEventConsumer.h @@ -73,6 +73,10 @@ protected: GHOST_EventCallbackProcPtr m_eventCallback; /** The data passed back though the call-back routine. */ GHOST_TUserDataPtr m_userData; + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_CallbackEventConsumer") +#endif }; #endif // __GHOST_CALLBACKEVENTCONSUMER_H__ diff --git a/intern/ghost/intern/GHOST_DisplayManager.h b/intern/ghost/intern/GHOST_DisplayManager.h index 3e867054d01..7893f0936b3 100644 --- a/intern/ghost/intern/GHOST_DisplayManager.h +++ b/intern/ghost/intern/GHOST_DisplayManager.h @@ -133,6 +133,11 @@ protected: bool m_settingsInitialized; /** The list with display settings for the main display. */ std::vector<GHOST_DisplaySettings> m_settings; + + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_DisplayManager") +#endif }; diff --git a/intern/ghost/intern/GHOST_EventManager.h b/intern/ghost/intern/GHOST_EventManager.h index f941dac9fb4..eec00789800 100644 --- a/intern/ghost/intern/GHOST_EventManager.h +++ b/intern/ghost/intern/GHOST_EventManager.h @@ -168,6 +168,11 @@ protected: /** The list with event consumers. */ TConsumerVector m_consumers; + + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_EventManager") +#endif }; #endif // __GHOST_EVENTMANAGER_H__ diff --git a/intern/ghost/intern/GHOST_SystemPaths.h b/intern/ghost/intern/GHOST_SystemPaths.h index 75acbf885e3..f53d4f4a7b7 100644 --- a/intern/ghost/intern/GHOST_SystemPaths.h +++ b/intern/ghost/intern/GHOST_SystemPaths.h @@ -57,7 +57,7 @@ public: */ virtual const GHOST_TUns8 *getSystemDir(int version, const char *versionstr) const = 0; - /** + /** * Determine the base dir in which user configuration is stored, including versioning. * If needed, it will create the base directory. * @return Unsigned char string pointing to user dir (eg ~/.blender/). @@ -74,7 +74,6 @@ public: * Add the file to the operating system most recently used files */ virtual void addToSystemRecentFiles(const char *filename) const = 0; - }; #endif diff --git a/intern/ghost/intern/GHOST_TimerManager.h b/intern/ghost/intern/GHOST_TimerManager.h index 0b189cf3aa9..88d27088c1d 100644 --- a/intern/ghost/intern/GHOST_TimerManager.h +++ b/intern/ghost/intern/GHOST_TimerManager.h @@ -119,6 +119,11 @@ protected: typedef std::vector<GHOST_TimerTask *> TTimerVector; /** The list with event consumers. */ TTimerVector m_timers; + + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("GHOST:GHOST_TimerManager") +#endif }; #endif // __GHOST_TIMERMANAGER_H__ diff --git a/intern/guardedalloc/cpp/mallocn.cpp b/intern/guardedalloc/cpp/mallocn.cpp index 130fcb6960b..21f5e323cf2 100644 --- a/intern/guardedalloc/cpp/mallocn.cpp +++ b/intern/guardedalloc/cpp/mallocn.cpp @@ -28,20 +28,36 @@ #include <new> #include "../MEM_guardedalloc.h" -void* operator new (size_t size) +/* not default but can be used when needing to set a string */ +void *operator new(size_t size, const char *str) { - return MEM_mallocN(size, "C++/anonymous"); + return MEM_mallocN(size, str); } - -/* not default but can be used when needing to set a string */ -void* operator new (size_t size, const char *str) +void *operator new[](size_t size, const char *str) { return MEM_mallocN(size, str); } -void operator delete (void *p) + +void *operator new(size_t size) +{ + return MEM_mallocN(size, "C++/anonymous"); +} +void *operator new[](size_t size) +{ + return MEM_mallocN(size, "C++/anonymous[]"); +} + + +void operator delete(void *p) +{ + /* delete NULL is valid in c++ */ + if (p) + MEM_freeN(p); +} +void operator delete[](void *p) { /* delete NULL is valid in c++ */ - if(p) + if (p) MEM_freeN(p); } |