Bug 396369 - "Overload forget method on nsCOMPtr/nsRefPtr to work with out parameters". r=dbaron, sr=bsmedberg, a=damons.

This commit is contained in:
bent.mozilla@gmail.com 2007-11-11 10:56:45 -08:00
Родитель 124fe70e86
Коммит 491c9c1063
2 изменённых файлов: 32 добавлений и 0 удалений

Просмотреть файл

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