zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 368e544ca923fcf0246639564070adb07e2f145c
parent fad364d209df370314b04a4dcb9553d5e48516d5
Author: fundamental <[email protected]>
Date:   Thu,  7 Feb 2013 11:21:41 -0500

Fixing a memory leak

Diffstat:
Msrc/Misc/Master.cpp | 18++++++++++++++----
Msrc/Misc/Master.h | 1+
Msrc/main.cpp | 1+
3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/Misc/Master.cpp b/src/Misc/Master.cpp @@ -45,6 +45,8 @@ vuData::vuData(void) rmspeakl(0.0f), rmspeakr(0.0f), clipped(0) {} +static Master* masterInstance = NULL; + Master::Master() { swaplr = 0; @@ -121,11 +123,19 @@ bool Master::mutexLock(lockset request) Master &Master::getInstance() { - static Master *instance = NULL; - if(!instance) - instance = new Master; + if (!masterInstance) + masterInstance = new Master; + + return *masterInstance; +} - return *instance; +void Master::deleteInstance() +{ + if (masterInstance) + { + delete masterInstance; + masterInstance = NULL; + } } /* diff --git a/src/Misc/Master.h b/src/Misc/Master.h @@ -58,6 +58,7 @@ class Master ~Master(); static Master &getInstance(); + static void deleteInstance(); /**Saves all settings to a XML file * @return 0 for ok or <0 if there is an error*/ diff --git a/src/main.cpp b/src/main.cpp @@ -166,6 +166,7 @@ void exitprogram() delete [] denormalkillbuf; FFT_cleanup(); + Master::deleteInstance(); } int main(int argc, char *argv[])