Bug 396369 - "Overload forget method on nsCOMPtr/nsRefPtr to work with out parameters". r=dbaron, sr=bsmedberg, a=damons.
git-svn-id: svn://10.0.0.236/trunk@239143 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1042,6 +1042,17 @@ class nsRefPtr
|
||||
return temp;
|
||||
}
|
||||
|
||||
void
|
||||
forget( T** 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.
|
||||
{
|
||||
NS_ASSERTION(rhs, "Null pointer passed to forget!");
|
||||
*rhs = 0;
|
||||
swap(*rhs);
|
||||
}
|
||||
|
||||
T*
|
||||
get() const
|
||||
/*
|
||||
|
||||
@@ -829,6 +829,17 @@ class nsCOMPtr
|
||||
return temp;
|
||||
}
|
||||
|
||||
void
|
||||
forget( T** 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.
|
||||
{
|
||||
NS_ASSERTION(rhs, "Null pointer passed to forget!");
|
||||
*rhs = 0;
|
||||
swap(*rhs);
|
||||
}
|
||||
|
||||
T*
|
||||
get() const
|
||||
/*
|
||||
@@ -1139,6 +1150,16 @@ class nsCOMPtr<nsISupports>
|
||||
mRawPtr = temp;
|
||||
}
|
||||
|
||||
void
|
||||
forget( nsISupports** 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.
|
||||
{
|
||||
NS_ASSERTION(rhs, "Null pointer passed to forget!");
|
||||
*rhs = 0;
|
||||
swap(*rhs);
|
||||
}
|
||||
|
||||
// Other pointer operators
|
||||
|
||||
|
||||
Reference in New Issue
Block a user