commit acdb993e10514607ac46c1ef71a00995ba9c3814
parent c99be90be0a3f855366f4a5b132e3b239e4ae992
Author: fundamental <[email protected]>
Date: Mon, 22 Aug 2011 16:41:21 -0400
Tests: fixing memory leaks & invalid deletes
Diffstat:
4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/Synth/ADnote.cpp b/src/Synth/ADnote.cpp
@@ -1744,10 +1744,12 @@ void ADnote::Voice::releasekey()
template<class T>
static inline void nullify(T &t) {delete t; t=NULL;}
+template<class T>
+static inline void arrayNullify(T &t) {delete [] t; t=NULL;}
void ADnote::Voice::kill()
{
- nullify(OscilSmp);
+ arrayNullify(OscilSmp);
nullify(FreqEnvelope);
nullify(FreqLfo);
nullify(AmpEnvelope);
diff --git a/src/Tests/AdNoteTest.h b/src/Tests/AdNoteTest.h
@@ -17,6 +17,7 @@ class AdNoteTest:public CxxTest::TestSuite
ADnote *note;
Master *master;
+ FFTwrapper *fft;
Controller *controller;
unsigned char testnote;
@@ -42,9 +43,9 @@ class AdNoteTest:public CxxTest::TestSuite
//phew, glad to get thouse out of my way. took me a lot of sweat and gdb to get this far...
+ fft = new FFTwrapper(OSCIL_SIZE);
//prepare the default settings
- ADnoteParameters *defaultPreset = new ADnoteParameters(
- new FFTwrapper(OSCIL_SIZE));
+ ADnoteParameters *defaultPreset = new ADnoteParameters(fft);
//Assert defaults
TS_ASSERT(!defaultPreset->VoicePar[1].Enabled);
@@ -81,6 +82,9 @@ class AdNoteTest:public CxxTest::TestSuite
0,
testnote,
false);
+
+ delete defaultPreset;
+ delete wrap;
}
void willNoteBeRunButIsHereForLinkingReasonsHowsThisForCamelCaseEh()
@@ -90,6 +94,11 @@ class AdNoteTest:public CxxTest::TestSuite
void tearDown() {
delete note;
+ delete controller;
+ delete fft;
+ delete [] outL;
+ delete [] outR;
+ delete [] denormalkillbuf;
}
void testDefaults() {
diff --git a/src/Tests/OscilGenTest.h b/src/Tests/OscilGenTest.h
@@ -62,6 +62,7 @@ class OscilGenTest:public CxxTest::TestSuite
delete[] outL;
delete[] outR;
delete[] denormalkillbuf;
+ FFT_cleanup();
}
//verifies that initialization occurs
diff --git a/src/Tests/SubNoteTest.h b/src/Tests/SubNoteTest.h
@@ -53,7 +53,6 @@ class SubNoteTest:public CxxTest::TestSuite
TS_ASSERT(wrap->enterbranch("INSTRUMENT_KIT_ITEM", 0));
TS_ASSERT(wrap->enterbranch("SUB_SYNTH_PARAMETERS"));
defaultPreset->getfromXML(wrap);
- //defaultPreset->defaults();
controller = new Controller();
@@ -68,6 +67,8 @@ class SubNoteTest:public CxxTest::TestSuite
0,
testnote,
false);
+ delete wrap;
+ delete defaultPreset;
}
void willNoteBeRunButIsHereForLinkingReasonsHowsThisForCamelCaseEh()
@@ -76,7 +77,11 @@ class SubNoteTest:public CxxTest::TestSuite
}
void tearDown() {
+ delete controller;
delete note;
+ delete [] outL;
+ delete [] outR;
+ delete [] denormalkillbuf;
}
void testDefaults() {