diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-25 14:35:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-25 14:35:24 +0400 |
commit | 3c8a4c458bc66cfe54e83c00f2d4460a52e04535 (patch) | |
tree | 151c0fa579ac0fcdc7230e8224bfdaf3c3c2ed87 /intern/guardedalloc | |
parent | cc0784c1b9c4d813837dedddd5b2b4c52fe291f0 (diff) |
more guardedalloc use in C++, also make compositorMutex a static var, was allocated and never freed.
Diffstat (limited to 'intern/guardedalloc')
-rw-r--r-- | intern/guardedalloc/cpp/mallocn.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
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); } |