···203203 int Norig = st->nfft;
204204205205 kiss_fft_cpx * scratch = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC(sizeof(kiss_fft_cpx)*p);
206206+ if (scratch == NULL){
207207+ KISS_FFT_ERROR("Memory allocation failed.");
208208+ return;
209209+ }
206210207211 for ( u=0; u<m; ++u ) {
208212 k=u;
···244248 const kiss_fft_cpx * Fout_end = Fout + p*m;
245249246250#ifdef _OPENMP
247247- // use openmp extensions at the
251251+ // use openmp extensions at the
248252 // top-level (not recursive)
249253 if (fstride==1 && p<=5 && m!=1)
250254 {
···252256253257 // execute the p different work units in different threads
254258# pragma omp parallel for
255255- for (k=0;k<p;++k)
259259+ for (k=0;k<p;++k)
256260 kf_work( Fout +k*m, f+ fstride*in_stride*k,fstride*p,in_stride,factors,st);
257261 // all threads have joined by this point
258262259263 switch (p) {
260264 case 2: kf_bfly2(Fout,fstride,st,m); break;
261261- case 3: kf_bfly3(Fout,fstride,st,m); break;
265265+ case 3: kf_bfly3(Fout,fstride,st,m); break;
262266 case 4: kf_bfly4(Fout,fstride,st,m); break;
263263- case 5: kf_bfly5(Fout,fstride,st,m); break;
267267+ case 5: kf_bfly5(Fout,fstride,st,m); break;
264268 default: kf_bfly_generic(Fout,fstride,st,m,p); break;
265269 }
266270 return;
···276280 do{
277281 // recursive call:
278282 // DFT of size m*p performed by doing
279279- // p instances of smaller DFTs of size m,
283283+ // p instances of smaller DFTs of size m,
280284 // each one takes a decimated version of the input
281285 kf_work( Fout , f, fstride*p, in_stride, factors,st);
282286 f += fstride*in_stride;
···285289286290 Fout=Fout_beg;
287291288288- // recombine the p smaller DFTs
292292+ // recombine the p smaller DFTs
289293 switch (p) {
290294 case 2: kf_bfly2(Fout,fstride,st,m); break;
291291- case 3: kf_bfly3(Fout,fstride,st,m); break;
295295+ case 3: kf_bfly3(Fout,fstride,st,m); break;
292296 case 4: kf_bfly4(Fout,fstride,st,m); break;
293293- case 5: kf_bfly5(Fout,fstride,st,m); break;
297297+ case 5: kf_bfly5(Fout,fstride,st,m); break;
294298 default: kf_bfly_generic(Fout,fstride,st,m,p); break;
295299 }
296300}
297301298302/* facbuf is populated by p1,m1,p2,m2, ...
299299- where
303303+ where
300304 p[i] * m[i] = m[i-1]
301305 m0 = n */
302302-static
306306+static
303307void kf_factor(int n,int * facbuf)
304308{
305309 int p=4;
···369373 if (fin == fout) {
370374 //NOTE: this is not really an in-place FFT algorithm.
371375 //It just performs an out-of-place FFT into a temp buffer
376376+ if (fout == NULL){
377377+ KISS_FFT_ERROR("fout buffer NULL.");
378378+ return;
379379+ }
380380+372381 kiss_fft_cpx * tmpbuf = (kiss_fft_cpx*)KISS_FFT_TMP_ALLOC( sizeof(kiss_fft_cpx)*st->nfft);
382382+ if (tmpbuf == NULL){
383383+ KISS_FFT_ERROR("Memory allocation error.");
384384+ return;
385385+ }
386386+387387+388388+373389 kf_work(tmpbuf,fin,1,in_stride, st->factors,st);
374390 memcpy(fout,tmpbuf,sizeof(kiss_fft_cpx)*st->nfft);
375391 KISS_FFT_TMP_FREE(tmpbuf);