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:
bent.mozilla%gmail.com
2007-11-11 18:56:45 +00:00
parent f179e0892e
commit 6577b1feae
2 changed files with 32 additions and 0 deletions

View File

@@ -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
/*

View File

@@ -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