diff options
| author | Adam <Adam@anope.org> | 2012-12-27 21:43:19 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2012-12-28 10:43:30 -0500 |
| commit | 379b2ccf92b6124f2026a5ec683cfc98f08e223a (patch) | |
| tree | 9cec160f53a579a83950656d5978301823f4312d /include | |
| parent | 3fb4cf56b651eb500b1bbafb14c0d328d81e1f3c (diff) | |
The timestamp column in SQL should actually be null sometimes, and fixed some valgrind errors with db_sql_live
Diffstat (limited to 'include')
| -rw-r--r-- | include/base.h | 26 | ||||
| -rw-r--r-- | include/serialize.h | 46 |
2 files changed, 44 insertions, 28 deletions
diff --git a/include/base.h b/include/base.h index 6fb974ec4..3bf9eefef 100644 --- a/include/base.h +++ b/include/base.h @@ -73,6 +73,22 @@ class Reference : public ReferenceBase ref->DelReference(this); } + inline Reference<T>& operator=(const Reference<T> &other) + { + if (this != &other) + { + if (*this) + this->ref->DelReference(this); + + this->ref = other.ref; + this->invalid = other.invalid; + + if (*this) + this->ref->AddReference(this); + } + return *this; + } + /* We explicitly call operator bool here in several places to prevent other * operators, such operator T*, from being called instead, which will mess * with any class inheriting from this that overloads this operator. @@ -105,16 +121,6 @@ class Reference : public ReferenceBase return NULL; } - inline void operator=(T *newref) - { - if (operator bool()) - this->ref->DelReference(this); - this->ref = newref; - this->invalid = false; - if (operator bool()) - this->ref->AddReference(this); - } - inline bool operator<(const Reference<T> &other) const { return this < &other; diff --git a/include/serialize.h b/include/serialize.h index edbf1facf..a7ac33dfa 100644 --- a/include/serialize.h +++ b/include/serialize.h @@ -258,18 +258,34 @@ class Serialize::Reference : public ReferenceBase obj->AddReference(this); } - Reference(const Reference<T> &other) : ref(other.ref) + Reference(const Reference<T> &other) : ReferenceBase(other), ref(other.ref) { - if (*this) + if (ref && !invalid) this->ref->AddReference(this); } ~Reference() { - if (*this) + if (ref && !invalid) this->ref->DelReference(this); } + inline Reference<T>& operator=(const Reference<T> &other) + { + if (this != &other) + { + if (ref && !invalid) + this->ref->DelReference(this); + + this->ref = other.ref; + this->invalid = other.invalid; + + if (ref && !invalid) + this->ref->AddReference(this); + } + return *this; + } + inline operator bool() const { if (!this->invalid) @@ -277,25 +293,15 @@ class Serialize::Reference : public ReferenceBase return false; } - inline void operator=(T *newref) - { - if (*this) - this->ref->DelReference(this); - - this->ref = newref; - this->invalid = false; - - if (newref) - this->ref->AddReference(this); - } - inline operator T*() const { if (!this->invalid) { if (this->ref) + // This can invalidate me this->ref->QueueUpdate(); - return this->ref; + if (!this->invalid) + return this->ref; } return NULL; } @@ -305,8 +311,10 @@ class Serialize::Reference : public ReferenceBase if (!this->invalid) { if (this->ref) + // This can invalidate me this->ref->QueueUpdate(); - return this->ref; + if (!this->invalid) + return this->ref; } return NULL; } @@ -316,8 +324,10 @@ class Serialize::Reference : public ReferenceBase if (!this->invalid) { if (this->ref) + // This can invalidate me this->ref->QueueUpdate(); - return this->ref; + if (!this->invalid) + return this->ref; } return NULL; } |
