Bug 837297; change RefCounted::dead to a define; r=waldo
authorNicholas Cameron <ncameron@mozilla.com>
Tue, 05 Feb 2013 16:53:57 +1300
changeset 130701 15dd558ca1018ef9d585dcbaa26900a8e56fcf06
parent 130700 687a4154ebafb42f4e62c217043317cd7f5bc465
child 130702 000b88ac40a7f1380132e33ea18f779d7320ece1
push idunknown
push userunknown
push dateunknown
reviewerswaldo
bugs837297
milestone21.0a1
Bug 837297; change RefCounted::dead to a define; r=waldo
mfbt/RefPtr.h
--- a/mfbt/RefPtr.h
+++ b/mfbt/RefPtr.h
@@ -35,40 +35,43 @@ template<typename T> OutParamRef<T> byRe
  * Live RefCounted<T> have refcount > 0.  The lifetime (refcounts) of
  * live RefCounted<T> are controlled by RefPtr<T> and
  * RefPtr<super/subclass of T>.  Upon a transition from refcounted==1
  * to 0, the RefCounted<T> "dies" and is destroyed.  The "destroyed"
  * state is represented in DEBUG builds by refcount==0xffffdead.  This
  * state distinguishes use-before-ref (refcount==0) from
  * use-after-destroy (refcount==0xffffdead).
  */
+#ifdef DEBUG
+namespace detail {
+static const int DEAD = 0xffffdead;
+}
+#endif
+
 template<typename T>
 class RefCounted
 {
     friend class RefPtr<T>;
 
-#ifdef DEBUG
-    static const int dead = 0xffffdead;
-#endif
   protected:
     RefCounted() : refCnt(0) { }
-    ~RefCounted() { MOZ_ASSERT(refCnt == dead); }
+    ~RefCounted() { MOZ_ASSERT(refCnt == detail::DEAD); }
 
   public:
     // Compatibility with nsRefPtr.
     void AddRef() {
       MOZ_ASSERT(refCnt >= 0);
       ++refCnt;
     }
 
     void Release() {
       MOZ_ASSERT(refCnt > 0);
       if (0 == --refCnt) {
 #ifdef DEBUG
-        refCnt = dead;
+        refCnt = detail::DEAD;
 #endif
         delete static_cast<T*>(this);
       }
     }
 
     // Compatibility with wtf::RefPtr.
     void ref() { AddRef(); }
     void deref() { Release(); }