From 3c8a4c458bc66cfe54e83c00f2d4460a52e04535 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 25 Jun 2012 10:35:24 +0000 Subject: more guardedalloc use in C++, also make compositorMutex a static var, was allocated and never freed. --- source/blender/compositor/intern/COM_ChunkOrderHotspot.h | 9 +++++++++ source/blender/compositor/intern/COM_ExecutionSystem.cpp | 4 ++++ source/blender/compositor/intern/COM_NodeOperation.h | 4 ++++ source/blender/compositor/intern/COM_Socket.h | 4 ++++ source/blender/compositor/intern/COM_SocketReader.h | 4 ++++ source/blender/compositor/intern/COM_compositor.cpp | 15 ++++++++------- source/gameengine/Expressions/PyObjectPlus.h | 2 +- 7 files changed, 34 insertions(+), 8 deletions(-) (limited to 'source') diff --git a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h index ceb5934a7df..68140745f8b 100644 --- a/source/blender/compositor/intern/COM_ChunkOrderHotspot.h +++ b/source/blender/compositor/intern/COM_ChunkOrderHotspot.h @@ -23,6 +23,10 @@ #ifndef _COM_ChunkOrderHotSpot_h_ #define _COM_ChunkOrderHotSpot_h_ +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + class ChunkOrderHotspot { private: int x; @@ -32,6 +36,11 @@ private: public: ChunkOrderHotspot(int x, int y, float addition); double determineDistance(int x, int y); + + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:ChunkOrderHotspot") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_ExecutionSystem.cpp b/source/blender/compositor/intern/COM_ExecutionSystem.cpp index 7e09486fd0b..5001cabbd9f 100644 --- a/source/blender/compositor/intern/COM_ExecutionSystem.cpp +++ b/source/blender/compositor/intern/COM_ExecutionSystem.cpp @@ -41,6 +41,10 @@ #include "BKE_global.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + ExecutionSystem::ExecutionSystem(RenderData *rd, bNodeTree *editingtree, bool rendering) { context.setbNodeTree(editingtree); diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index f96b994685a..bf2dbd8c9c0 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -270,6 +270,10 @@ protected: * @brief set if this NodeOperation can be scheduled on a OpenCLDevice */ void setOpenCL(bool openCL) { this->openCL = openCL; } + +#ifdef WITH_CXX_GUARDEDALLOC + MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeOperation") +#endif }; #endif diff --git a/source/blender/compositor/intern/COM_Socket.h b/source/blender/compositor/intern/COM_Socket.h index 4f82a490e14..9feef1bae93 100644 --- a/source/blender/compositor/intern/COM_Socket.h +++ b/source/blender/compositor/intern/COM_Socket.h @@ -29,6 +29,10 @@ #include "DNA_node_types.h" #include "COM_defines.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + using namespace std; class SocketConnection; class NodeBase; diff --git a/source/blender/compositor/intern/COM_SocketReader.h b/source/blender/compositor/intern/COM_SocketReader.h index f4f58e6e007..df8899e8eea 100644 --- a/source/blender/compositor/intern/COM_SocketReader.h +++ b/source/blender/compositor/intern/COM_SocketReader.h @@ -25,6 +25,10 @@ #include "BLI_rect.h" #include "COM_defines.h" +#ifdef WITH_CXX_GUARDEDALLOC +#include "MEM_guardedalloc.h" +#endif + typedef enum PixelSampler { COM_PS_NEAREST, COM_PS_BILINEAR, diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp index bec9ff95eed..ccd3b2e6458 100644 --- a/source/blender/compositor/intern/COM_compositor.cpp +++ b/source/blender/compositor/intern/COM_compositor.cpp @@ -33,20 +33,21 @@ extern "C" { #include "COM_WorkScheduler.h" #include "OCL_opencl.h" -static ThreadMutex *compositorMutex; +static ThreadMutex compositorMutex = {{0}}; +static char is_compositorMutex_init = FALSE; void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) { - if (compositorMutex == NULL) { /// TODO: move to blender startup phase - compositorMutex = new ThreadMutex(); - BLI_mutex_init(compositorMutex); + if (is_compositorMutex_init == FALSE) { /// TODO: move to blender startup phase + BLI_mutex_init(&compositorMutex); OCL_init(); WorkScheduler::initialize(); ///TODO: call workscheduler.deinitialize somewhere + is_compositorMutex_init = TRUE; } - BLI_mutex_lock(compositorMutex); + BLI_mutex_lock(&compositorMutex); if (editingtree->test_break(editingtree->tbh)) { // during editing multiple calls to this method can be triggered. // make sure one the last one will be doing the work. - BLI_mutex_unlock(compositorMutex); + BLI_mutex_unlock(&compositorMutex); return; } @@ -60,5 +61,5 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) system->execute(); delete system; - BLI_mutex_unlock(compositorMutex); + BLI_mutex_unlock(&compositorMutex); } diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index af8acaa993f..2fee6aaab92 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -166,7 +166,7 @@ public: \ void *operator new(size_t num_bytes) { \ return MEM_mallocN(num_bytes, Type.tp_name); \ } \ - void operator delete( void *mem ) { \ + void operator delete(void *mem) { \ MEM_freeN(mem); \ } \ -- cgit v1.2.3