]> git.mxchange.org Git - simgear.git/commitdiff
Fix use count for deleted, reference counted objects.
authorThomas Geymayer <tomgey@gmail.com>
Wed, 7 May 2014 23:42:25 +0000 (01:42 +0200)
committerThomas Geymayer <tomgey@gmail.com>
Wed, 7 May 2014 23:43:41 +0000 (01:43 +0200)
Remove inconsitency of returning 0 or ~0. If the object
has been deleted there are no more references, so always
return 0.

simgear/structure/SGReferenced.hxx
simgear/structure/SGWeakReferenced.hxx

index 69788b3f13aa42f4aa70565fcd23590d05db2672..67e4fb1ed18ba36b7d42d206dfd9155047d0a0ee 100644 (file)
@@ -42,11 +42,11 @@ public:
   { return *this; }
 
   static unsigned get(const SGReferenced* ref)
-  { if (ref) return ++(ref->_refcount); else return ~0u; }
+  { if (ref) return ++(ref->_refcount); else return 0; }
   static unsigned put(const SGReferenced* ref)
-  { if (ref) return --(ref->_refcount); else return ~0u; }
+  { if (ref) return --(ref->_refcount); else return 0; }
   static unsigned count(const SGReferenced* ref)
-  { if (ref) return ref->_refcount; else return ~0u; }
+  { if (ref) return ref->_refcount; else return 0; }
   static bool shared(const SGReferenced* ref)
   { if (ref) return 1u < ref->_refcount; else return false; }
 
index dbe50574a0061533ea15a1fb8f8c066d31b39cba..7a2bcaf5fae97961181da0a7a826ca516ccf7672 100644 (file)
@@ -71,11 +71,11 @@ public:
   /// The usual operations on weak pointers.
   /// The interface should stay the same then what we have in Referenced.
   static unsigned get(const SGWeakReferenced* ref)
-  { if (ref) return ++(ref->mWeakData->mRefcount); else return 0u; }
+  { if (ref) return ++(ref->mWeakData->mRefcount); else return 0; }
   static unsigned put(const SGWeakReferenced* ref)
-  { if (ref) return --(ref->mWeakData->mRefcount); else return ~0u; }
+  { if (ref) return --(ref->mWeakData->mRefcount); else return 0; }
   static unsigned count(const SGWeakReferenced* ref)
-  { if (ref) return ref->mWeakData->mRefcount; else return 0u; }
+  { if (ref) return ref->mWeakData->mRefcount; else return 0; }
 
 private:
   /// Support for weak references, not increasing the reference count