aboutsummaryrefslogtreecommitdiff
path: root/src/ReduceGA.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ReduceGA.c')
-rw-r--r--src/ReduceGA.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/ReduceGA.c b/src/ReduceGA.c
index 29ddd07..6bcc08e 100644
--- a/src/ReduceGA.c
+++ b/src/ReduceGA.c
@@ -207,12 +207,15 @@ static int ReduceGridArrays (const cGH *GH,
dim = CCTK_GroupDimFromVarI(input_array_variable_indices[0]);
/* allocate memory for the array of the dimensions of the input arrays */
- lower_array_bounds = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
- min_array_subscript = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
- array_lsh = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
- input_array_dims = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
- input_array_gz = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
-
+ if (dim >0)
+ {
+ lower_array_bounds = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
+ min_array_subscript = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
+ array_lsh = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
+ input_array_dims = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
+ input_array_gz = (CCTK_INT *)malloc (dim *sizeof(CCTK_INT));
+ }
+
/* find out the types of the input arrays and put that */
/* in an array ipughGH->GFExtras[dim]->lnsize[i]*/
for ( i = 0; i < N_input_arrays; i++)
@@ -771,12 +774,20 @@ static int ReduceGridArrays (const cGH *GH,
break;
#endif
}
+ free (local_outvals);
}
num_points = total_num_points;
weight_sum = total_weight_sum;
- free (local_outvals);
#endif
-
+ if (dim >0)
+ {
+ free (lower_array_bounds);
+ free (min_array_subscript);
+ free (array_lsh);
+ free (input_array_dims);
+ free (input_array_gz);
+ }
+
if (perform_division == 0)
{
if (weight_on == 1)