summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2003-02-17 17:41:15 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>2003-02-17 17:41:15 +0000
commite9a9dd09ca268db0faafbbbf773a0d2af3034f39 (patch)
tree54a1f79d60e2a69d45db7ba337932c006451536b /src
parent08dc979087660675bc153de2dedd93526dd3b786 (diff)
Added a check against scheduling items with the same name in a schedule bin
or group. Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@3148 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src')
-rw-r--r--src/main/ScheduleInterface.c14
-rw-r--r--src/schedule/ScheduleCreater.c31
2 files changed, 34 insertions, 11 deletions
diff --git a/src/main/ScheduleInterface.c b/src/main/ScheduleInterface.c
index b7607dc2..1f9ced64 100644
--- a/src/main/ScheduleInterface.c
+++ b/src/main/ScheduleInterface.c
@@ -415,6 +415,12 @@ int CCTKi_ScheduleFunction(void *function,
retcode = CCTKi_DoScheduleFunction(where, name, function, modifier, (void *)attribute);
+ if(retcode == -2)
+ {
+ CCTK_VWarn (0, __LINE__, __FILE__, "Cactus",
+ "Tried to schedule duplicate item '%s' from thorn '%s' in '%s'",
+ name, thorn, where);
+ }
#ifdef DEBUG
fprintf(stderr, "Scheduled %s at %s\n", name, where);
#endif
@@ -560,6 +566,14 @@ int CCTKi_ScheduleGroup(const char *realname,
if(attribute && (modifier || (n_before == 0 && n_after == 0 && n_while == 0)))
{
retcode = CCTKi_DoScheduleGroup(where, name, realname, modifier, (void *)attribute);
+
+ if(retcode == -2)
+ {
+ CCTK_VWarn (0, __LINE__, __FILE__, "Cactus",
+ "Tried to schedule duplicate item '%s' from thorn '%s' in '%s'",
+ name, thorn, where);
+ }
+
#ifdef DEBUG
fprintf(stderr, "Scheduled %s at %s\n", name, where);
#endif
diff --git a/src/schedule/ScheduleCreater.c b/src/schedule/ScheduleCreater.c
index 51a186b8..958223f3 100644
--- a/src/schedule/ScheduleCreater.c
+++ b/src/schedule/ScheduleCreater.c
@@ -577,6 +577,7 @@ static t_sched_item *ScheduleCreateItem(const char *name, t_sched_modifier *modi
@returndesc
0 - success
-1 - memory failure
+ -2 - duplicate item
@endreturndesc
@@*/
static int ScheduleAddItem(int ghandle, t_sched_item *item)
@@ -587,27 +588,35 @@ static int ScheduleAddItem(int ghandle, t_sched_item *item)
this_group = (t_sched_group *)Util_GetHandledData(schedule_groups, ghandle);
- this_group->n_scheditems++;
+ if(ScheduleItemNumber(this_group, item->name) == -1)
+ {
+ this_group->n_scheditems++;
- temp = (t_sched_item *)realloc(this_group->scheditems, this_group->n_scheditems*sizeof(t_sched_item));
+ temp = (t_sched_item *)realloc(this_group->scheditems, this_group->n_scheditems*sizeof(t_sched_item));
- if(temp)
- {
- this_group->scheditems = temp;
- this_group->scheditems[this_group->n_scheditems-1] = *item;
+ if(temp)
+ {
+ this_group->scheditems = temp;
+ this_group->scheditems[this_group->n_scheditems-1] = *item;
#ifdef DEBUG_SCHEDULAR
- printf("Added item '%s' to group '%s'\n", item->name, this_group->name);
+ printf("Added item '%s' to group '%s'\n", item->name, this_group->name);
#endif
- free(item);
+ free(item);
- retcode = 0;
+ retcode = 0;
+ }
+ else
+ {
+ this_group->n_scheditems--;
+ retcode = -1;
+ }
}
else
{
- this_group->n_scheditems--;
- retcode = -1;
+ /* Item already existed. */
+ retcode = -2;
}
return retcode;