aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2001-11-16 16:39:07 +0000
committertradke <tradke@b589c3ab-70e8-4b4d-a09f-cba2dd200880>2001-11-16 16:39:07 +0000
commit9edc564f5809cf1bd92bd8f4b5841d92946b1c8d (patch)
tree11c2d78b210b531cdd18986c1f7111d4ed1428e3
parentaefccf7f6c7d23f01120009ea144546575cdd289 (diff)
For reduction output: use the reduction operator as a suffix in the resulting
output filename. Also fixed a potential bug in memory allocation. Closes PR CactusBase/IOBasic-836. git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOBasic/trunk@106 b589c3ab-70e8-4b4d-a09f-cba2dd200880
-rw-r--r--src/WriteScalar.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/WriteScalar.c b/src/WriteScalar.c
index dbd1ab3..c34143c 100644
--- a/src/WriteScalar.c
+++ b/src/WriteScalar.c
@@ -118,10 +118,7 @@ void IOBasic_WriteScalarGA (const cGH *GH,
/* get the GH extension handle for IOBasic */
myGH = (iobasicGH *) CCTK_GHExtension (GH, "IOBasic");
- /* allocate strings for the filename and the reduction operator */
- filename = (char *) malloc (strlen (myGH->outdirScalar) + strlen (alias) +
- strlen (reductions.const_ptr) +
- strlen (file_extension) + 3);
+ /* allocate string for the reduction operator */
reduction_op = (char *) malloc (strlen (reductions.const_ptr) + 1);
/* now loop over all reduction operators */
@@ -168,9 +165,12 @@ void IOBasic_WriteScalarGA (const cGH *GH,
if (ierr == 0 && CCTK_MyProc (GH) == 0)
{
- /* build the filename */
if (new_filename_scheme)
{
+ /* allocate filename string buffer and build the filename */
+ filename = (char *) malloc (strlen (myGH->outdirScalar) +
+ strlen (alias) + strlen (reduction_op) +
+ strlen (file_extension) + 2);
sprintf (filename, "%s%s_%s%s", myGH->outdirScalar, alias,
reduction_op, file_extension);
}
@@ -195,8 +195,12 @@ void IOBasic_WriteScalarGA (const cGH *GH,
}
else
{
- file_extension = "unknown";
+ file_extension = reduction_op;
}
+
+ /* allocate filename string buffer and build the filename */
+ filename = (char *) malloc (strlen (myGH->outdirScalar) +
+ strlen (alias) + strlen (file_extension)+5);
sprintf (filename, "%s%s_%s.tl", myGH->outdirScalar, alias,
file_extension);
}
@@ -215,12 +219,12 @@ void IOBasic_WriteScalarGA (const cGH *GH,
"IOBasic_WriteScalarGA: Could not open output file '%s'",
filename);
}
+ free (filename);
}
}
/* free allocated resources */
free (reduction_op);
- free (filename);
}