Fix memset size

In the call to memset(), the size of the pointer to mag2buf was
erroneously used instead of size of what mag2buf pointed to (float).
This leads to problems on systems where the size of the pointer is
different from the size of floats. Instead of just fixing the size,
use calloc() instead of malloc() to directly set the memory to 0.
This commit is contained in:
Rikard Falkeborn 2018-11-27 23:21:25 +01:00
parent 07e6dd04aa
commit d8ccb037a0

View File

@ -129,9 +129,7 @@ void transform_signal(void)
CHECKNULL( inbuf=(short*)malloc(sizeof(short)*2*nfft ) );
CHECKNULL( tbuf=(kiss_fft_scalar*)malloc(sizeof(kiss_fft_scalar)*nfft ) );
CHECKNULL( fbuf=(kiss_fft_cpx*)malloc(sizeof(kiss_fft_cpx)*nfreqs ) );
CHECKNULL( mag2buf=(float*)malloc(sizeof(float)*nfreqs ) );
memset(mag2buf,0,sizeof(mag2buf)*nfreqs);
CHECKNULL( mag2buf=(float*)calloc(nfreqs,sizeof(float) ) );
while (1) {
if (stereo) {