summaryrefslogtreecommitdiff
path: root/timers.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2006-09-08 15:06:09 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2006-09-08 15:06:09 +0200
commit782f2683d9476d227c67cff7db0bb392a0bf5f09 (patch)
tree9c9f40df3b5b7beabb66e3c757940f613d638044 /timers.c
parent5ff1d3571199dfa412e8e1cb7eb2a4f920fdbdd5 (diff)
downloadvdr-782f2683d9476d227c67cff7db0bb392a0bf5f09.tar.gz
vdr-782f2683d9476d227c67cff7db0bb392a0bf5f09.tar.bz2
Fixed cTimer::operator=() in case a cTimer variable is assigned to itself; implemented a copy constructor for cTimer
Diffstat (limited to 'timers.c')
-rw-r--r--timers.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/timers.c b/timers.c
index d8d00168..18dab0ff 100644
--- a/timers.c
+++ b/timers.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: timers.c 1.63 2006/09/02 10:20:36 kls Exp $
+ * $Id: timers.c 1.64 2006/09/08 15:06:09 kls Exp $
*/
#include "timers.h"
@@ -83,6 +83,14 @@ cTimer::cTimer(const cEvent *Event)
event = NULL; // let SetEvent() be called to get a log message
}
+cTimer::cTimer(const cTimer &Timer)
+{
+ channel = NULL;
+ aux = NULL;
+ event = NULL;
+ *this = Timer;
+}
+
cTimer::~cTimer()
{
free(aux);
@@ -90,24 +98,26 @@ cTimer::~cTimer()
cTimer& cTimer::operator= (const cTimer &Timer)
{
- startTime = Timer.startTime;
- stopTime = Timer.stopTime;
- lastSetEvent = 0;
- recording = Timer.recording;
- pending = Timer.pending;
- inVpsMargin = Timer.inVpsMargin;
- flags = Timer.flags;
- channel = Timer.channel;
- day = Timer.day;
- weekdays = Timer.weekdays;
- start = Timer.start;
- stop = Timer.stop;
- priority = Timer.priority;
- lifetime = Timer.lifetime;
- strncpy(file, Timer.file, sizeof(file));
- free(aux);
- aux = Timer.aux ? strdup(Timer.aux) : NULL;
- event = NULL;
+ if (&Timer != this) {
+ startTime = Timer.startTime;
+ stopTime = Timer.stopTime;
+ lastSetEvent = 0;
+ recording = Timer.recording;
+ pending = Timer.pending;
+ inVpsMargin = Timer.inVpsMargin;
+ flags = Timer.flags;
+ channel = Timer.channel;
+ day = Timer.day;
+ weekdays = Timer.weekdays;
+ start = Timer.start;
+ stop = Timer.stop;
+ priority = Timer.priority;
+ lifetime = Timer.lifetime;
+ strncpy(file, Timer.file, sizeof(file));
+ free(aux);
+ aux = Timer.aux ? strdup(Timer.aux) : NULL;
+ event = NULL;
+ }
return *this;
}