summaryrefslogtreecommitdiff
path: root/src/main/ScheduleInterface.c
diff options
context:
space:
mode:
authorschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2004-04-06 09:39:14 +0000
committerschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2004-04-06 09:39:14 +0000
commit7c963f6a9114e5632b6706224028d9ebc0dfd07b (patch)
tree9a1fb83839555eb240c8a6080ed47d99cb4522f3 /src/main/ScheduleInterface.c
parent3a809caeb7219de0efe71b891f5715088296d13a (diff)
Create timers with unique names by using an integer serial number.
This removes spurious timer warnings. Check malloc return value. Change message from "[...] at [group]" to "[...] in [group]". git-svn-id: http://svn.cactuscode.org/flesh/trunk@3646 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main/ScheduleInterface.c')
-rw-r--r--src/main/ScheduleInterface.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/main/ScheduleInterface.c b/src/main/ScheduleInterface.c
index ac5066c8..61ede556 100644
--- a/src/main/ScheduleInterface.c
+++ b/src/main/ScheduleInterface.c
@@ -1238,6 +1238,7 @@ static t_attribute *CreateAttribute(const char *where,
const int *timelevels,
va_list *ap)
{
+ static int timernum = 0;
char *timername;
t_attribute *this;
int i;
@@ -1323,15 +1324,25 @@ static t_attribute *CreateAttribute(const char *where,
/* Add a timer to the item */
timername = malloc (strlen (thorn) + strlen (description) +
- strlen (where) + 7);
- sprintf (timername, "%s: %s at %s", thorn, description, where);
- this->timer_handle = CCTK_TimerCreate(timername);
- if (this->timer_handle < 0)
+ strlen (where) + 100);
+ if (!timername)
{
CCTK_VWarn (1, __LINE__, __FILE__, "Cactus",
- "Couldn't create timer with name '%s'", timername);
+ "Could not allocate memory for timer");
+ this->timer_handle = -1;
+ }
+ else
+ {
+ sprintf (timername, "[%04d] %s: %s in %s",
+ timernum++, thorn, description, where);
+ this->timer_handle = CCTK_TimerCreate(timername);
+ if (this->timer_handle < 0)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, "Cactus",
+ "Could not create timer with name '%s'", timername);
+ }
+ free (timername);
}
- free (timername);
}
else
{