Skip to content

Commit fc17344

Browse files
committed
prepare for resize
1 parent 924c2da commit fc17344

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

fft.c

+8-9
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#include "fft.h"
2727

2828
static fftw_plan plan;
29-
static double *in;
3029
static fftw_complex *out;
30+
static double *in;
3131
static size_t sz;
3232
static double *window;
3333
static double *sq;
@@ -65,17 +65,16 @@ squares(size_t n)
6565
}
6666

6767
int
68-
init_fft(size_t n)
68+
init_fft(size_t maxn, size_t n)
6969
{
70-
sz = n;
71-
in = fftw_malloc(sz * sizeof(double));
72-
out = fftw_malloc(sz * sizeof(fftw_complex) / 2);
70+
in = fftw_malloc(maxn * sizeof(double));
71+
out = fftw_malloc(maxn * sizeof(fftw_complex) / 2);
7372
assert(in && out);
7473

75-
window = hamming(sz);
76-
sq = squares(sz);
77-
78-
plan = fftw_plan_dft_r2c_1d(sz, in, out, FFTW_MEASURE);
74+
plan = fftw_plan_dft_r2c_1d(n, in, out, FFTW_MEASURE);
75+
window = hamming(n);
76+
sq = squares(n);
77+
sz = n;
7978

8079
return 0;
8180
}

0 commit comments

Comments
 (0)