Bug 489705 - nsRefPtr should be able to forget a base class to a pure virtual interface it inherits from

r=bsmedberg
sr=dbaron
This commit is contained in:
Shawn Wilsher 2009-05-07 15:13:18 -04:00
parent 6cd1ca156d
commit 46166ad09a

View File

@ -1042,15 +1042,17 @@ class nsRefPtr
return temp;
}
template <typename I>
void
forget( T** rhs )
forget( I** rhs)
// Set the target of rhs to the value of mRawPtr and null out mRawPtr.
// Useful to avoid unnecessary AddRef/Release pairs with "out"
// parameters.
// parameters where rhs bay be a T** or an I** where I is a base class
// of T.
{
NS_ASSERTION(rhs, "Null pointer passed to forget!");
*rhs = 0;
swap(*rhs);
*rhs = mRawPtr;
mRawPtr = 0;
}
T*