X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Ftimer.cpp;h=e04a186cffbbe30eaa55fadbd8584239ad6c0a7e;hb=a785f350fd584d87f3b84bbaff569ecb59c29f04;hp=ca7534a7c7409759d42808258c3162db706f019a;hpb=c88afe5b9abba09b883d59f46a7e2795df181394;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/timer.cpp b/src/timer.cpp index ca7534a7c..e04a186cf 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -1,23 +1,38 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2008 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * Copyright (C) 2008 Robin Burchell + * Copyright (C) 2007 Dennis Friis + * Copyright (C) 2006-2007 Craig Edwards + * Copyright (C) 2006 Oliver Lupton * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -/* $Core: libIRCDtimer */ + +/* $Core */ #include "inspircd.h" #include "timer.h" -TimerManager::TimerManager(InspIRCd* Instance) : ServerInstance(Instance) +TimerManager::TimerManager() +{ +} + +TimerManager::~TimerManager() { + for(std::vector::iterator i = Timers.begin(); i != Timers.end(); i++) + delete *i; } void TimerManager::TickTimers(time_t TIME) @@ -27,6 +42,9 @@ void TimerManager::TickTimers(time_t TIME) std::vector::iterator i = Timers.begin(); Timer *t = (*i); + // Probable fix: move vector manipulation to *before* we modify the vector. + Timers.erase(i); + t->Tick(TIME); if (t->GetRepeat()) { @@ -35,8 +53,6 @@ void TimerManager::TickTimers(time_t TIME) } else delete t; - - Timers.erase(i); } } @@ -54,12 +70,10 @@ void TimerManager::DelTimer(Timer* T) void TimerManager::AddTimer(Timer* T) { Timers.push_back(T); - sort(Timers.begin(), Timers.end(), TimerManager::TimerComparison); + std::sort(Timers.begin(), Timers.end(), TimerManager::TimerComparison); } bool TimerManager::TimerComparison( Timer *one, Timer *two) { return (one->GetTimer()) < (two->GetTimer()); } - -