Skip to content

Commit b995f1c

Browse files
author
srsampson
committed
Change alloc to malloc/free in fsk.c
1 parent 410b475 commit b995f1c

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

src/fsk.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@
3535
/* This needs square roots, may take more cpu time than it's worth */
3636
#define EST_EBNO
3737

38-
/* This is a flag to make the mod/demod allocate their memory on the stack instead of the heap */
39-
/* At large sample rates, there's not enough stack space to run the demod */
40-
#define DEMOD_ALLOC_STACK
41-
4238
/* This is a flag for the freq. estimator to use a precomputed/rt computed hann window table
4339
On platforms with slow cosf, this will produce a substantial speedup at the cost of a small
4440
amount of memory
@@ -472,14 +468,8 @@ void fsk_demod_freq_est(struct FSK *fsk, COMP fsk_in[], float *freqs, int M) {
472468
int freqi[M];
473469
int st,en,f_zero;
474470

475-
/* Array to do complex FFT from using kiss_fft */
476-
#ifdef DEMOD_ALLOC_STACK
477-
kiss_fft_cpx *fftin = (kiss_fft_cpx*)alloca(sizeof(kiss_fft_cpx)*Ndft);
478-
kiss_fft_cpx *fftout = (kiss_fft_cpx*)alloca(sizeof(kiss_fft_cpx)*Ndft);
479-
#else
480471
kiss_fft_cpx *fftin = (kiss_fft_cpx*)malloc(sizeof(kiss_fft_cpx)*Ndft);
481472
kiss_fft_cpx *fftout = (kiss_fft_cpx*)malloc(sizeof(kiss_fft_cpx)*Ndft);
482-
#endif
483473

484474
st = (fsk->est_min*Ndft)/Fs + Ndft/2; if (st < 0) st = 0;
485475
en = (fsk->est_max*Ndft)/Fs + Ndft/2; if (en > Ndft) en = Ndft;
@@ -605,14 +595,13 @@ void fsk_demod_freq_est(struct FSK *fsk, COMP fsk_in[], float *freqs, int M) {
605595
//fprintf(stderr, "fsk->tone_spacing: %d\n",fsk->tone_spacing);
606596
for (int m=0; m<M; m++)
607597
fsk->f2_est[m] = foff + m*fsk->tone_spacing;
598+
608599
#ifdef MODEMPROBE_ENABLE
609600
modem_probe_samp_f("t_f2_est",fsk->f2_est,M);
610601
#endif
611602

612-
#ifndef DEMOD_ALLOC_STACK
613603
free(fftin);
614604
free(fftout);
615-
#endif
616605
}
617606

618607
/* core demodulator function */

0 commit comments

Comments
 (0)