aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@38c3d835-c875-442e-b0fe-21c19ce1d001>2003-01-22 10:42:47 +0000
committertradke <tradke@38c3d835-c875-442e-b0fe-21c19ce1d001>2003-01-22 10:42:47 +0000
commitc7d194500d0727555b9d14cdf0f0bea4f3384e9c (patch)
treee05ece880234eff2238878bb6fc447454e95b3b3
parent8ac81c508cd4cdc615242f9d4ef9acf65b42713f (diff)
Copy string parameter pointer into local variable before modifying it.
This closes PR CactusPUGHIO/1363. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOPanda/trunk@48 38c3d835-c875-442e-b0fe-21c19ce1d001
-rw-r--r--src/Startup.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/Startup.c b/src/Startup.c
index 178b53f..457198f 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -127,6 +127,7 @@ static void *SetupGH (tFleshConfig *config, int convergence_level, cGH *GH)
FILE *fp;
pandaGH *myGH;
const ioGH *ioUtilGH;
+ const char *my_out_dir;
DECLARE_CCTK_PARAMETERS
@@ -143,10 +144,10 @@ static void *SetupGH (tFleshConfig *config, int convergence_level, cGH *GH)
CCTK_RegisterIOMethodTriggerOutput (i, IOPanda_TriggerOutput);
/* allocate a new GH extension structure */
- myGH = (pandaGH *) malloc (sizeof (pandaGH));
+ myGH = malloc (sizeof (pandaGH));
numvars = CCTK_NumVars ();
- myGH->requests = (ioRequest **) calloc (numvars, sizeof (ioRequest *));
- myGH->out_last = (int *) malloc (numvars * sizeof (int));
+ myGH->requests = calloc (numvars, sizeof (ioRequest *));
+ myGH->out_last = malloc (numvars * sizeof (int));
myGH->out_vars = strdup ("");
myGH->out_every_default = out_every - 1;
@@ -157,26 +158,27 @@ static void *SetupGH (tFleshConfig *config, int convergence_level, cGH *GH)
}
/* get the name of IOPanda's output directory */
- if (*out_dir == 0)
+ my_out_dir = out_dir;
+ if (*my_out_dir == 0)
{
- out_dir = io_out_dir;
+ my_out_dir = io_out_dir;
}
/* skip the directory pathname if output goes into current directory */
- if (strcmp (out_dir, "."))
+ if (strcmp (my_out_dir, "."))
{
- i = strlen (out_dir);
- if (CCTK_Equals (out_mode, "onefile") || ! strstr (out_dir, "%u"))
+ i = strlen (my_out_dir);
+ if (CCTK_Equals (out_mode, "onefile") || ! strstr (my_out_dir, "%u"))
{
- myGH->out_dir = (char *) malloc (i + 2);
- strcpy (myGH->out_dir, out_dir);
+ myGH->out_dir = malloc (i + 2);
+ strcpy (myGH->out_dir, my_out_dir);
myGH->out_dir[i] = '/';
myGH->out_dir[i+1] = 0;
}
else
{
- myGH->out_dir = (char *) malloc (i + 20);
- sprintf (myGH->out_dir, out_dir, CCTK_MyProc (GH));
+ myGH->out_dir = malloc (i + 20);
+ sprintf (myGH->out_dir, my_out_dir, CCTK_MyProc (GH));
strcat (myGH->out_dir, "/");
}
}
@@ -186,7 +188,7 @@ static void *SetupGH (tFleshConfig *config, int convergence_level, cGH *GH)
}
/* create the output directory */
- ioUtilGH = (const ioGH *) CCTK_GHExtension (GH, "IO");
+ ioUtilGH = CCTK_GHExtension (GH, "IO");
i = IOUtil_CreateDirectory (GH, myGH->out_dir,
! CCTK_Equals (out_mode, "onefile"),
ioUtilGH->ioproc);