diff --git a/mozilla/xpcom/base/nsAutoPtr.h b/mozilla/xpcom/base/nsAutoPtr.h index 5b3757561d1..d078254074a 100644 --- a/mozilla/xpcom/base/nsAutoPtr.h +++ b/mozilla/xpcom/base/nsAutoPtr.h @@ -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 /* diff --git a/mozilla/xpcom/glue/nsCOMPtr.h b/mozilla/xpcom/glue/nsCOMPtr.h index c4799e22d5f..22bd959b124 100644 --- a/mozilla/xpcom/glue/nsCOMPtr.h +++ b/mozilla/xpcom/glue/nsCOMPtr.h @@ -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 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