Backout changeset bc2bbe9836c7 (bug 834769) for bustage.

This commit is contained in:
Mike Hommey 2013-01-29 09:49:16 +01:00
parent 615ad95018
commit 7946ac6e85

View File

@ -36,20 +36,19 @@ template<typename T> OutParamRef<T> byRef(RefPtr<T>&);
* 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 is represented in DEBUG builds by refcount==-0xdead. This
* state distinguishes use-before-ref (refcount==0) from
* use-after-destroy (refcount==0xffffdead).
* use-after-destroy (refcount==-0xdead).
*/
template<typename T>
class RefCounted
{
friend class RefPtr<T>;
protected:
RefCounted() : refCnt(0) { }
~RefCounted() { MOZ_ASSERT(refCnt == 0xffffdead); }
public:
RefCounted() : refCnt(0) { }
~RefCounted() { MOZ_ASSERT(refCnt == -0xdead); }
// Compatibility with nsRefPtr.
void AddRef() {
MOZ_ASSERT(refCnt >= 0);
@ -60,7 +59,7 @@ class RefCounted
MOZ_ASSERT(refCnt > 0);
if (0 == --refCnt) {
#ifdef DEBUG
refCnt = 0xffffdead;
refCnt = -0xdead;
#endif
delete static_cast<T*>(this);
}