From 3563dc0887f0b5f3b294108b392249dc927375ca Mon Sep 17 00:00:00 2001 From: Lukas Schneiderbauer Date: Sun, 5 Jan 2025 21:57:10 +0100 Subject: [PATCH] attempt to fix fcwt related memory leaks discovered by valgrind --- src/fcwt.cpp | 6 ++++++ src/fcwt.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/fcwt.cpp b/src/fcwt.cpp index 7543590..20e464e 100644 --- a/src/fcwt.cpp +++ b/src/fcwt.cpp @@ -431,6 +431,12 @@ void FCWT::convolve(fftwf_plan p, fftwf_complex *Ihat, fftwf_complex *O1, comple fftbased(p, Ihat, O1, (float*)lastscalemem, wav->mother, newsize, scale, wav->imag_frequency, wav->doublesided); if(use_normalization) fft_normalize((complex*)lastscalemem, newsize); memcpy(out, (complex*)lastscalemem, sizeof(complex)*size); + + #ifdef _WIN32 + _aligned_free(lastscalemem); + #else + free(lastscalemem); + #endif } else { // if(!out) { // std::cout << "OUT NOT A POINTER" << std::endl; diff --git a/src/fcwt.h b/src/fcwt.h index 39544f8..380c425 100644 --- a/src/fcwt.h +++ b/src/fcwt.h @@ -119,6 +119,7 @@ class Morlet : public Wavelet { class Scales { public: FCWT_LIBRARY_API Scales(Wavelet *pwav, SCALETYPE st, int fs, float f0, float f1, int fn); + ~Scales() { free(scales); }; // void FCWT_LIBRARY_API getScales(float *pfreqs, int pnf); // void FCWT_LIBRARY_API getFrequencies(float *pfreqs, int pnf);