From 163a6499ea442c4f06c2e9333eb877a5acbd310f Mon Sep 17 00:00:00 2001 From: David Date: Fri, 29 May 2020 20:22:57 +0930 Subject: [PATCH] fix memory leak --- src/codec2_pitch.c | 1 + src/freq.c | 4 ++++ src/freq.h | 1 + src/lpcnet_dump.c | 3 ++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/codec2_pitch.c b/src/codec2_pitch.c index a267785..55fb5bc 100644 --- a/src/codec2_pitch.c +++ b/src/codec2_pitch.c @@ -113,6 +113,7 @@ int codec2_pitch_est(CODEC2_PITCH *pitch, float Sn[], float *f0, float *voicing) void codec2_pitch_destroy(CODEC2_PITCH *pitch) { + free(pitch->fft_fwd_cfg); nlp_destroy(pitch->nlp_states); free(pitch->w); free(pitch); diff --git a/src/freq.c b/src/freq.c index c88d071..235611e 100644 --- a/src/freq.c +++ b/src/freq.c @@ -140,6 +140,10 @@ static void check_init() { common.init = 1; } +void freq_close() { + opus_fft_free(common.kfft,0); +} + void dct(float *out, const float *in) { int i; check_init(); diff --git a/src/freq.h b/src/freq.h index 0316edd..314eabd 100644 --- a/src/freq.h +++ b/src/freq.h @@ -42,6 +42,7 @@ #define NB_BANDS 18 +void freq_close(void); void compute_band_energy(float *bandE, const kiss_fft_cpx *X); void compute_band_corr(float *bandE, const kiss_fft_cpx *X, const kiss_fft_cpx *P); diff --git a/src/lpcnet_dump.c b/src/lpcnet_dump.c index d8a8409..58f9c98 100644 --- a/src/lpcnet_dump.c +++ b/src/lpcnet_dump.c @@ -87,7 +87,8 @@ static DenoiseState *rnnoise_create() { } static void rnnoise_destroy(DenoiseState *st) { - free(st); + freq_close(); + free(st); } static short float2short(float x)