From 364d1a9352cf1adcf08fbd4f0e793f24540d7402 Mon Sep 17 00:00:00 2001 From: John Glover Date: Fri, 14 Jun 2013 11:47:06 +0200 Subject: Add basic SndObjPeakDetection tests. Fix memory leaks. --- src/sndobj/FFT.cpp | 16 ++++++++++++++-- src/sndobj/IFGram.cpp | 9 ++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src/sndobj') diff --git a/src/sndobj/FFT.cpp b/src/sndobj/FFT.cpp index 666fe88..d527ea5 100644 --- a/src/sndobj/FFT.cpp +++ b/src/sndobj/FFT.cpp @@ -108,8 +108,20 @@ FFT::~FFT(){ fftw_destroy_plan(m_plan); fftw_free(m_fftIn); fftw_free(m_fftOut); - delete[] m_counter; - delete[] m_sigframe; + if(m_counter){ + delete[] m_counter; + m_counter = NULL; + } + for(int i = 0; i < m_frames; i++){ + if(m_sigframe[i]){ + delete[] m_sigframe[i]; + m_sigframe[i] = NULL; + } + } + if(m_sigframe){ + delete[] m_sigframe; + m_sigframe = NULL; + } } void diff --git a/src/sndobj/IFGram.cpp b/src/sndobj/IFGram.cpp index a5b374d..fb4cfa7 100644 --- a/src/sndobj/IFGram.cpp +++ b/src/sndobj/IFGram.cpp @@ -60,7 +60,14 @@ IFGram::IFGram(Table* window, SndObj* input, double scale, } IFGram::~IFGram(){ - delete[] m_diffwin; + if(m_diffwin){ + delete[] m_diffwin; + m_diffwin = NULL; + } + if(m_pdiff){ + delete[] m_pdiff; + m_pdiff = NULL; + } fftw_destroy_plan(m_diffplan); fftw_free(m_diffsig); -- cgit v1.2.3