aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetIOStreamedHDF5
diff options
context:
space:
mode:
authorThomas Radke <tradke@aei.mpg.de>2005-07-26 12:23:00 +0000
committerThomas Radke <tradke@aei.mpg.de>2005-07-26 12:23:00 +0000
commit4b4e7cee5c2580bcf3b47b6af99b0e5bf0e5c9c5 (patch)
treead85a3fabb110c510b4a6944405c10c76615d25e /Carpet/CarpetIOStreamedHDF5
parent7870aa2629814950096dbb9981405b5d4b0efd73 (diff)
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
Diffstat (limited to 'Carpet/CarpetIOStreamedHDF5')
-rw-r--r--Carpet/CarpetIOStreamedHDF5/src/CarpetIOStreamedHDF5.cc20
1 files changed, 9 insertions, 11 deletions
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());
}
}