this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Testting buffers for NULL befor usage

+26 -10
+26 -10
kiss_fft.c
··· 203 203 int Norig = st->nfft; 204 204 205 205 kiss_fft_cpx * scratch = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC(sizeof(kiss_fft_cpx)*p); 206 + if (scratch == NULL){ 207 + KISS_FFT_ERROR("Memory allocation failed."); 208 + return; 209 + } 206 210 207 211 for ( u=0; u<m; ++u ) { 208 212 k=u; ··· 244 248 const kiss_fft_cpx * Fout_end = Fout + p*m; 245 249 246 250 #ifdef _OPENMP 247 - // use openmp extensions at the 251 + // use openmp extensions at the 248 252 // top-level (not recursive) 249 253 if (fstride==1 && p<=5 && m!=1) 250 254 { ··· 252 256 253 257 // execute the p different work units in different threads 254 258 # pragma omp parallel for 255 - for (k=0;k<p;++k) 259 + for (k=0;k<p;++k) 256 260 kf_work( Fout +k*m, f+ fstride*in_stride*k,fstride*p,in_stride,factors,st); 257 261 // all threads have joined by this point 258 262 259 263 switch (p) { 260 264 case 2: kf_bfly2(Fout,fstride,st,m); break; 261 - case 3: kf_bfly3(Fout,fstride,st,m); break; 265 + case 3: kf_bfly3(Fout,fstride,st,m); break; 262 266 case 4: kf_bfly4(Fout,fstride,st,m); break; 263 - case 5: kf_bfly5(Fout,fstride,st,m); break; 267 + case 5: kf_bfly5(Fout,fstride,st,m); break; 264 268 default: kf_bfly_generic(Fout,fstride,st,m,p); break; 265 269 } 266 270 return; ··· 276 280 do{ 277 281 // recursive call: 278 282 // DFT of size m*p performed by doing 279 - // p instances of smaller DFTs of size m, 283 + // p instances of smaller DFTs of size m, 280 284 // each one takes a decimated version of the input 281 285 kf_work( Fout , f, fstride*p, in_stride, factors,st); 282 286 f += fstride*in_stride; ··· 285 289 286 290 Fout=Fout_beg; 287 291 288 - // recombine the p smaller DFTs 292 + // recombine the p smaller DFTs 289 293 switch (p) { 290 294 case 2: kf_bfly2(Fout,fstride,st,m); break; 291 - case 3: kf_bfly3(Fout,fstride,st,m); break; 295 + case 3: kf_bfly3(Fout,fstride,st,m); break; 292 296 case 4: kf_bfly4(Fout,fstride,st,m); break; 293 - case 5: kf_bfly5(Fout,fstride,st,m); break; 297 + case 5: kf_bfly5(Fout,fstride,st,m); break; 294 298 default: kf_bfly_generic(Fout,fstride,st,m,p); break; 295 299 } 296 300 } 297 301 298 302 /* facbuf is populated by p1,m1,p2,m2, ... 299 - where 303 + where 300 304 p[i] * m[i] = m[i-1] 301 305 m0 = n */ 302 - static 306 + static 303 307 void kf_factor(int n,int * facbuf) 304 308 { 305 309 int p=4; ··· 369 373 if (fin == fout) { 370 374 //NOTE: this is not really an in-place FFT algorithm. 371 375 //It just performs an out-of-place FFT into a temp buffer 376 + if (fout == NULL){ 377 + KISS_FFT_ERROR("fout buffer NULL."); 378 + return; 379 + } 380 + 372 381 kiss_fft_cpx * tmpbuf = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC( sizeof(kiss_fft_cpx)*st->nfft); 382 + if (tmpbuf == NULL){ 383 + KISS_FFT_ERROR("Memory allocation error."); 384 + return; 385 + } 386 + 387 + 388 + 373 389 kf_work(tmpbuf,fin,1,in_stride, st->factors,st); 374 390 memcpy(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft); 375 391 KISS_FFT_TMP_FREE(tmpbuf);