From 0d2f3cf6b7df04cb865353af3c85dea0f4d7dec9 Mon Sep 17 00:00:00 2001 From: Felix Dollack Date: Fri, 15 May 2026 13:49:52 +0900 Subject: [PATCH 1/2] Fix Group B memory bugs (issues #74, #55) and Group A headers (issue #84) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix delete→free in Morlet::getWavelet() for malloc-allocated memory - Fix memory leak: free lastscalemem with _aligned_free/_aligned_malloc on Windows, free/aligned_alloc on POSIX - Add missing include (issue #84) - Also fix indentation in convolve() else branch Co-Authored-By: Oz --- src/fcwt/fcwt.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/fcwt/fcwt.cpp b/src/fcwt/fcwt.cpp index 5194cf5..f96766d 100644 --- a/src/fcwt/fcwt.cpp +++ b/src/fcwt/fcwt.cpp @@ -37,6 +37,7 @@ limitations under the License. */ #include "fcwt.h" +#include Morlet::Morlet(float bandwidth) { four_wavelen = 0.9876f; @@ -100,8 +101,8 @@ void Morlet::getWavelet(float scale, complex* pwav, int pn) { pwav[t].imag(imag[t]); } - delete real; - delete imag; + free(real); + free(imag); }; //==============================================================// @@ -403,9 +404,15 @@ void FCWT::convolve(fftwf_plan p, fftwf_complex *Ihat, fftwf_complex *O1, comple #endif memset(lastscalemem,0,sizeof(fftwf_complex)*newsize); - fftbased(p, Ihat, O1, (float*)lastscalemem, wav->mother, newsize, scale, wav->imag_frequency, wav->doublesided); + 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; From daee14ed7529511f37a6bb82b34d239268e2473a Mon Sep 17 00:00:00 2001 From: Felix Dollack Date: Fri, 15 May 2026 15:03:06 +0900 Subject: [PATCH 2/2] Fix test_plan to use string flag parameter The create_FFT_optimization_plan method expects a string flag (e.g., "FFTW_ESTIMATE") not an integer. This fixes the TypeError. Co-Authored-By: Oz --- tests/test_fcwt.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_fcwt.py b/tests/test_fcwt.py index 5302766..60b0956 100644 --- a/tests/test_fcwt.py +++ b/tests/test_fcwt.py @@ -239,13 +239,13 @@ def test_plan(): morl = Morlet(2.0) fcwt = FCWT(morl, 1, True, False) - fcwt.create_FFT_optimization_plan(2048,0) + fcwt.create_FFT_optimization_plan(2048, "FFTW_ESTIMATE") fname = "n2048_t1.wis" assert os.path.isfile(fname) fcwt = FCWT(morl, 8, True, False) - fcwt.create_FFT_optimization_plan(2048,0) + fcwt.create_FFT_optimization_plan(2048, "FFTW_ESTIMATE") fname = "n2048_t8.wis" - assert os.path.isfile(fname) \ No newline at end of file + assert os.path.isfile(fname)