From 4b4e7cee5c2580bcf3b47b6af99b0e5bf0e5c9c5 Mon Sep 17 00:00:00 2001 From: Thomas Radke Date: Tue, 26 Jul 2005 12:23:00 +0000 Subject: Carpet{IOScalar,IOHDF5,IOStreamedHDF5}: use C++ strings (rather than Util_asprintf()) to construct C output strings There was a small memory leak in using Util_asprintf() to continuously append to an allocated string buffer. The code has now been rewritten to use C++ string class objects which are destroyed automatically. This closes http://bugs.carpetcode.org/show_bug.cgi?id=89. darcs-hash:20050726122331-776a0-874ccd0d5766b85b1110fcd6f501a7e39c35e965.gz --- .../CarpetIOStreamedHDF5/src/CarpetIOStreamedHDF5.cc | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'Carpet/CarpetIOStreamedHDF5') diff --git a/Carpet/CarpetIOStreamedHDF5/src/CarpetIOStreamedHDF5.cc b/Carpet/CarpetIOStreamedHDF5/src/CarpetIOStreamedHDF5.cc index 92a47ff5a..bc3b38df5 100644 --- a/Carpet/CarpetIOStreamedHDF5/src/CarpetIOStreamedHDF5.cc +++ b/Carpet/CarpetIOStreamedHDF5/src/CarpetIOStreamedHDF5.cc @@ -3,7 +3,6 @@ #include "cctk.h" #include "cctk_Arguments.h" #include "cctk_Parameters.h" -#include "util_String.h" #include "util_Network.h" #ifdef HAVE_SYS_TIME_H @@ -189,22 +188,21 @@ static void CheckSteerableParameters (const cGH *const cctkGH, // notify the user about the new setting if (not CCTK_Equals (verbose, "none")) { - char *msg = NULL; + int count = 0; + string msg ("Periodic streamed HDF5 output requested for '"); for (int i = CCTK_NumVars () - 1; i >= 0; i--) { if (myGH->requests[i]) { - char *fullname = CCTK_FullName (i); - if (not msg) { - Util_asprintf (&msg, "Periodic streamed HDF5 output requested " - "for '%s'", fullname); - } else { - Util_asprintf (&msg, "%s, '%s'", msg, fullname); + if (count++) { + msg += "', '"; } + char *fullname = CCTK_FullName (i); + msg += fullname; free (fullname); } } - if (msg) { - CCTK_INFO (msg); - free (msg); + if (count) { + msg += "'"; + CCTK_INFO (msg.c_str()); } } -- cgit v1.2.3