@@ -40,10 +40,22 @@ static double squ(double x) { return x * x; }
4040double check_cf (int n ) {
4141 fftw_complex * in = (fftw_complex * ) fftw_malloc (sizeof (fftw_complex ) * n );
4242 fftw_complex * out = (fftw_complex * ) fftw_malloc (sizeof (fftw_complex ) * n );
43+
44+ if (!in || !out ) {
45+ fprintf (stderr , "Memory allocation failed" );
46+ exit (-1 );
47+ }
48+
4349 fftw_plan w = fftw_plan_dft_1d (n , in , out , FFTW_FORWARD , FFTW_ESTIMATE );
4450
4551 real * sx = (real * )Sleef_malloc (n * 2 * sizeof (real ));
4652 real * sy = (real * )Sleef_malloc (n * 2 * sizeof (real ));
53+
54+ if (!sx || !sy ) {
55+ fprintf (stderr , "Memory allocation failed" );
56+ exit (-1 );
57+ }
58+
4759 struct SleefDFT * p = SleefDFT_init1d (n , sx , sy , MODE );
4860
4961 for (int i = 0 ;i < n ;i ++ ) {
@@ -79,10 +91,22 @@ double check_cf(int n) {
7991double check_cb (int n ) {
8092 fftw_complex * in = (fftw_complex * ) fftw_malloc (sizeof (fftw_complex ) * n );
8193 fftw_complex * out = (fftw_complex * ) fftw_malloc (sizeof (fftw_complex ) * n );
94+
95+ if (!in || !out ) {
96+ fprintf (stderr , "Memory allocation failed" );
97+ exit (-1 );
98+ }
99+
82100 fftw_plan w = fftw_plan_dft_1d (n , in , out , FFTW_BACKWARD , FFTW_ESTIMATE );
83101
84102 real * sx = (real * )Sleef_malloc (n * 2 * sizeof (real ));
85103 real * sy = (real * )Sleef_malloc (n * 2 * sizeof (real ));
104+
105+ if (!sx || !sy ) {
106+ fprintf (stderr , "Memory allocation failed" );
107+ exit (-1 );
108+ }
109+
86110 struct SleefDFT * p = SleefDFT_init1d (n , sx , sy , SLEEF_MODE_BACKWARD | MODE );
87111
88112 for (int i = 0 ;i < n ;i ++ ) {
@@ -118,10 +142,22 @@ double check_cb(int n) {
118142double check_rf (int n ) {
119143 double * in = (double * ) fftw_malloc (sizeof (double ) * n );
120144 fftw_complex * out = (fftw_complex * ) fftw_malloc (sizeof (fftw_complex ) * (n /2 + 1 ));
145+
146+ if (!in || !out ) {
147+ fprintf (stderr , "Memory allocation failed" );
148+ exit (-1 );
149+ }
150+
121151 fftw_plan w = fftw_plan_dft_r2c_1d (n , in , out , FFTW_ESTIMATE );
122152
123153 real * sx = (real * )Sleef_malloc (n * sizeof (real ));
124154 real * sy = (real * )Sleef_malloc ((n /2 + 1 )* sizeof (real )* 2 );
155+
156+ if (!sx || !sy ) {
157+ fprintf (stderr , "Memory allocation failed" );
158+ exit (-1 );
159+ }
160+
125161 struct SleefDFT * p = SleefDFT_init1d (n , sx , sy , SLEEF_MODE_REAL | MODE );
126162
127163 for (int i = 0 ;i < n ;i ++ ) {
@@ -155,10 +191,22 @@ double check_rf(int n) {
155191double check_rb (int n ) {
156192 fftw_complex * in = (fftw_complex * ) fftw_malloc (sizeof (fftw_complex ) * (n /2 + 1 ));
157193 double * out = (double * ) fftw_malloc (sizeof (double ) * n );
194+
195+ if (!in || !out ) {
196+ fprintf (stderr , "Memory allocation failed" );
197+ exit (-1 );
198+ }
199+
158200 fftw_plan w = fftw_plan_dft_c2r_1d (n , in , out , FFTW_ESTIMATE );
159201
160202 real * sx = (real * )Sleef_malloc ((n /2 + 1 ) * sizeof (real )* 2 );
161203 real * sy = (real * )Sleef_malloc (sizeof (real )* n );
204+
205+ if (!sx || !sy ) {
206+ fprintf (stderr , "Memory allocation failed" );
207+ exit (-1 );
208+ }
209+
162210 struct SleefDFT * p = SleefDFT_init1d (n , sx , sy , SLEEF_MODE_REAL | SLEEF_MODE_BACKWARD | MODE );
163211
164212 for (int i = 0 ;i < n /2 ;i ++ ) {
0 commit comments