mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 09:48:45 -05:00
Fixed possible memory leak in green FFT (g_fft)
This commit is contained in:
parent
790e5d3bc8
commit
ffbc08841e
@ -36,7 +36,7 @@
|
|||||||
template <typename FFT_TYPE>
|
template <typename FFT_TYPE>
|
||||||
class g_fft {
|
class g_fft {
|
||||||
|
|
||||||
#define FFT_RECIPLN2 1.442695040888963407359924681001892137426 // 1.0/log(2)
|
#define FFT_RECIPLN2 1.442695040888963407359924681001892137426 // 1.0/log(2)
|
||||||
|
|
||||||
// some useful conversions between a number and its power of 2
|
// some useful conversions between a number and its power of 2
|
||||||
#define LOG2(a) (FFT_RECIPLN2*log(a)) // floating point logarithm base 2
|
#define LOG2(a) (FFT_RECIPLN2*log(a)) // floating point logarithm base 2
|
||||||
@ -102,7 +102,7 @@ private:
|
|||||||
void bitrevR2(FFT_TYPE *ioptr, int M, short *BRLow);
|
void bitrevR2(FFT_TYPE *ioptr, int M, short *BRLow);
|
||||||
void fftBRInit(int M, short *BRLow);
|
void fftBRInit(int M, short *BRLow);
|
||||||
void fftCosInit(int M, FFT_TYPE *Utbl);
|
void fftCosInit(int M, FFT_TYPE *Utbl);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
g_fft (int M = 8192)
|
g_fft (int M = 8192)
|
||||||
{
|
{
|
||||||
@ -3247,7 +3247,9 @@ void g_fft<FFT_TYPE>::fftInit()
|
|||||||
FFT_table_2[FFT_N/2] = new short[POW2(FFT_N/2 - 1)];
|
FFT_table_2[FFT_N/2] = new short[POW2(FFT_N/2 - 1)];
|
||||||
fftBRInit(FFT_N, FFT_table_2[FFT_N/2]);
|
fftBRInit(FFT_N, FFT_table_2[FFT_N/2]);
|
||||||
|
|
||||||
FFT_table_2[(FFT_N - 1) / 2] = new short[POW2((FFT_N - 1) / 2 - 1)];
|
if ((FFT_N % 2) == 0) { // FFT_N/2 = (FFT_N-1)/2 if FFT_N is odd. Prevents memory leak
|
||||||
|
FFT_table_2[(FFT_N - 1) / 2] = new short[POW2((FFT_N - 1) / 2 - 1)];
|
||||||
|
}
|
||||||
fftBRInit(FFT_N - 1, FFT_table_2[(FFT_N - 1) / 2]);
|
fftBRInit(FFT_N - 1, FFT_table_2[(FFT_N - 1) / 2]);
|
||||||
|
|
||||||
Utbl = ((FFT_TYPE**) FFT_table_1)[FFT_N];
|
Utbl = ((FFT_TYPE**) FFT_table_1)[FFT_N];
|
||||||
|
Loading…
Reference in New Issue
Block a user