aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2003-01-07 10:04:27 +0000
committertradke <tradke@94b1c47f-dcfd-45ef-a468-0854c0e9e350>2003-01-07 10:04:27 +0000
commit2dd4e31b8191a6d65f74126ff3d04d88164cf5aa (patch)
treea6e5a5af5d42073982834416a843ae7994af760a /src
parent5712bf402ea251fc48ae1f440c380a69330a4f6a (diff)
Copy pointer to string parameter into local variable before modifying it.
This prevents future problems when string parameter pointer will be made read-only. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@139 94b1c47f-dcfd-45ef-a468-0854c0e9e350
Diffstat (limited to 'src')
-rw-r--r--src/Startup.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/Startup.c b/src/Startup.c
index 3de9bea..05d16a8 100644
--- a/src/Startup.c
+++ b/src/Startup.c
@@ -28,21 +28,24 @@ CCTK_FILEVERSION(CactusBase_IOASCII_Startup_c)
********************************************************************/
#define CREATE_OUTDIR(method, dir) \
{ \
+ const char *_dir = dir; \
+ \
+ \
/* check whether "dir" was set; if not default to "IO::out_dir" */ \
- if (*dir == 0) \
+ if (*_dir == 0) \
{ \
- dir = out_dir; \
+ _dir = out_dir; \
} \
\
/* omit the directory name if it's the current working dir */ \
- if (strcmp (dir, ".") == 0) \
+ if (strcmp (_dir, ".") == 0) \
{ \
myGH->dir = strdup (""); \
} \
else \
{ \
- myGH->dir = (char *) malloc (strlen (dir) + 2); \
- sprintf (myGH->dir, "%s/", dir); \
+ myGH->dir = malloc (strlen (_dir) + 2); \
+ sprintf (myGH->dir, "%s/", _dir); \
} \
\
/* create the directory */ \
@@ -143,7 +146,7 @@ static void *IOASCII_SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
(void) (GH + 0);
/* allocate the GH extension and its components */
- myGH = (asciiioGH *) malloc (sizeof (asciiioGH));
+ myGH = malloc (sizeof (asciiioGH));
if (! myGH)
{
CCTK_WARN (0, "IOASCII_SetupGH: Unable to allocate memory for GH");
@@ -181,12 +184,12 @@ static void *IOASCII_SetupGH (tFleshConfig *config, int conv_level, cGH *GH)
}
numvars = CCTK_NumVars ();
- myGH->out1D_every = (CCTK_INT *) malloc (numvars * sizeof (CCTK_INT));
- myGH->out2D_every = (CCTK_INT *) malloc (numvars * sizeof (CCTK_INT));
- myGH->out3D_every = (CCTK_INT *) malloc (numvars * sizeof (CCTK_INT));
- myGH->out1D_last = (int *) malloc (numvars * sizeof (int));
- myGH->out2D_last = (int *) malloc (numvars * sizeof (int));
- myGH->out3D_last = (int *) malloc (numvars * sizeof (int));
+ myGH->out1D_every = malloc (numvars * sizeof (CCTK_INT));
+ myGH->out2D_every = malloc (numvars * sizeof (CCTK_INT));
+ myGH->out3D_every = malloc (numvars * sizeof (CCTK_INT));
+ myGH->out1D_last = malloc (numvars * sizeof (int));
+ myGH->out2D_last = malloc (numvars * sizeof (int));
+ myGH->out3D_last = malloc (numvars * sizeof (int));
for (i = 0; i < numvars; i++)
{