aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorallen <allen@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2001-04-10 15:40:02 +0000
committerallen <allen@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2001-04-10 15:40:02 +0000
commit5220f84a6160b738afd1475ac7c34370aca2a1eb (patch)
treecff33ebb5d114c35972e960d460e60106f8009ad
parent424b79deda35444f640079511fe250f1a3bd15fe (diff)
Fixed small memory problem setting up slice centers
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@56 94b1c47f-dcfd-45ef-a468-0854c0e9e350
-rw-r--r--src/Startup.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Startup.c b/src/Startup.c
index a080541..7048fbe 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -111,6 +111,7 @@ static void *IOASCII_SetupGH (tFleshConfig *config,
{
DECLARE_CCTK_PARAMETERS
int i;
+ int maxdim;
asciiioGH *newGH;
@@ -145,14 +146,16 @@ static void *IOASCII_SetupGH (tFleshConfig *config,
newGH->spxyz = (int ***) malloc (CCTK_MaxDim() * sizeof (int **));
newGH->sp2xyz = (int **) malloc (3 * sizeof (int *));
- for (i = CCTK_MaxDim () - 1; i >= 0; i--)
+ maxdim = CCTK_MaxDim();
+
+ for (i = maxdim - 1; i >= 0; i--)
{
- newGH->spxyz[i] = (int **) malloc (3 * sizeof (int *));
- newGH->spxyz[i][0] = (int *) malloc (3 * sizeof (int ));
- newGH->spxyz[i][1] = (int *) malloc (3 * sizeof (int ));
- newGH->spxyz[i][2] = (int *) malloc (3 * sizeof (int ));
+ newGH->spxyz[i] = (int **) malloc (maxdim * sizeof (int *));
+ newGH->spxyz[i][0] = (int *) calloc (maxdim, sizeof (int ));
+ newGH->spxyz[i][1] = (int *) calloc (maxdim, sizeof (int ));
+ newGH->spxyz[i][2] = (int *) calloc (maxdim, sizeof (int ));
- newGH->sp2xyz[i] = (int *) malloc (3 * sizeof (int ));
+ newGH->sp2xyz[i] = (int *) calloc (maxdim, sizeof (int ));
}
/* How often to output */