From e9a9dd09ca268db0faafbbbf773a0d2af3034f39 Mon Sep 17 00:00:00 2001 From: goodale Date: Mon, 17 Feb 2003 17:41:15 +0000 Subject: 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 --- src/schedule/ScheduleCreater.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/schedule') 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; -- cgit v1.2.3