From 471c9e43493ab1d3a83ed6a8ca53bd818a2ed275 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 16 Jun 2006 23:17:46 +0000 Subject: More thorough assertion checking in CountedPtr; Adding plugins to subpatches working. git-svn-id: http://svn.drobilla.net/lad/grauph@46 a436a847-0d15-0410-975c-d299462d15a1 --- src/common/util/CountedPtr.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/common/util/CountedPtr.h') diff --git a/src/common/util/CountedPtr.h b/src/common/util/CountedPtr.h index 10c724c5..17c56cc9 100644 --- a/src/common/util/CountedPtr.h +++ b/src/common/util/CountedPtr.h @@ -73,6 +73,8 @@ public: if (copy) retain(copy._counter); + + assert(_counter == copy._counter); } /** Copy a CountedPtr to a valid base class. @@ -90,12 +92,15 @@ public: #else T* const casted_y = static_cast(y._counter->ptr); #endif - if (casted_y != NULL) { + if (casted_y) { assert(casted_y == y._counter->ptr); //release(); // FIXME: leak? retain((Counter*)y._counter); + assert(_counter == (Counter*)y._counter); } } + + assert(_counter == NULL || _counter == (Counter*)y._counter); } /** Assign to the value of a CountedPtr of the same type. */ @@ -106,6 +111,7 @@ public: release(); retain(copy._counter); } + assert(_counter == copy._counter); return *this; } @@ -118,6 +124,7 @@ public: release(); retain(y._counter); } + assert(_counter == y._counter); return *this; } @@ -179,7 +186,7 @@ private: assert(_counter == NULL || _counter == c); _counter = c; if (_counter) - ++c->count; + ++(c->count); } /** Decrement the count, delete if we're the last reference */ -- cgit v1.2.1