diff options
author | allen <allen@94b1c47f-dcfd-45ef-a468-0854c0e9e350> | 2001-10-31 10:42:18 +0000 |
---|---|---|
committer | allen <allen@94b1c47f-dcfd-45ef-a468-0854c0e9e350> | 2001-10-31 10:42:18 +0000 |
commit | 656cfd79fd70b398a7c156226bb3e94da32175f7 (patch) | |
tree | 16c395ff64cfa08df2a6df1d06eee1c068180ccc /src | |
parent | 77f23dafc9761a0887a97cc9c888955489dc5225 (diff) |
Fixed a memory leak I had put in
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/IOASCII/trunk@82 94b1c47f-dcfd-45ef-a468-0854c0e9e350
Diffstat (limited to 'src')
-rw-r--r-- | src/Output1D.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/Output1D.c b/src/Output1D.c index c77df14..5571579 100644 --- a/src/Output1D.c +++ b/src/Output1D.c @@ -268,6 +268,7 @@ int IOASCII_TriggerOutput1D (cGH *GH, int vindex) static void CheckSteerableParameters (asciiioGH *myGH) { int i, num_vars, out_old, times_set; + int verboselength; char *fullname, *msg; static int out1D_vars_lastset = -1; DECLARE_CCTK_PARAMETERS @@ -305,21 +306,28 @@ static void CheckSteerableParameters (asciiioGH *myGH) if (CCTK_Equals (newverbose, "standard") || CCTK_Equals (newverbose, "full")) { - msg = NULL; + + /* Count the length of the string */ + verboselength = 0; + for (i = 0; i < num_vars; i++) + { + if (myGH->do_out1D[i]) + { + fullname = CCTK_FullName (i); + verboselength += strlen(fullname)+1; + free (fullname); + } + } + verboselength += strlen("IOASCII_1D: Output requested for "); + msg = (char *)malloc((verboselength+1)*sizeof(char)); + + sprintf(msg,"IOASCII_1D: Output requested for "); for (i = 0; i < num_vars; i++) { if (myGH->do_out1D[i]) { fullname = CCTK_FullName (i); - if (! msg) - { - Util_asprintf (&msg, "IOASCII_1D: Output requested for %s", - fullname); - } - else - { - Util_asprintf (&msg, "%s %s", msg, fullname); - } + sprintf (msg, "%s %s",msg,fullname); free (fullname); } } |