From ab07d4da83e00e1618cd2581403f50ab9d15638e Mon Sep 17 00:00:00 2001 From: "peterv@propagandism.org" Date: Thu, 7 Feb 2008 03:37:18 -0800 Subject: [PATCH] Part 2 of the fix for bug 413281 (Firefox leaks when Yahoo Toolbar is installed). r/sr=sicking. --- xpcom/ds/nsArray.cpp | 13 ++++++++++++- xpcom/ds/nsArray.h | 4 +++- xpcom/ds/xpcomds.gqi | 6 +++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/xpcom/ds/nsArray.cpp b/xpcom/ds/nsArray.cpp index 91cbb21a1652..2eeb0054804c 100644 --- a/xpcom/ds/nsArray.cpp +++ b/xpcom/ds/nsArray.cpp @@ -54,7 +54,18 @@ nsArray::~nsArray() { Clear(); } - + +NS_IMPL_CYCLE_COLLECTING_ADDREF(nsArray) +NS_IMPL_CYCLE_COLLECTING_RELEASE(nsArray) + +NS_IMPL_CYCLE_COLLECTION_CLASS(nsArray) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsArray) + tmp->Clear(); +NS_IMPL_CYCLE_COLLECTION_UNLINK_END +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsArray) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mArray) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END + NS_IMETHODIMP nsArray::GetLength(PRUint32* aLength) { diff --git a/xpcom/ds/nsArray.h b/xpcom/ds/nsArray.h index 7b74dd540b86..7f59888eb70d 100644 --- a/xpcom/ds/nsArray.h +++ b/xpcom/ds/nsArray.h @@ -42,6 +42,7 @@ #include "nsIMutableArray.h" #include "nsCOMArray.h" #include "nsCOMPtr.h" +#include "nsCycleCollectionParticipant.h" #define NS_ARRAY_CLASSNAME \ "nsIArray implementation" @@ -63,7 +64,8 @@ public: nsArray(const nsCOMArray_base& aBaseArray) : mArray(aBaseArray) { } - NS_DECL_ISUPPORTS + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + NS_DECL_CYCLE_COLLECTION_CLASS(nsArray) NS_DECL_NSIARRAY NS_DECL_NSIMUTABLEARRAY diff --git a/xpcom/ds/xpcomds.gqi b/xpcom/ds/xpcomds.gqi index a41d0e9d7868..cc07f811904c 100644 --- a/xpcom/ds/xpcomds.gqi +++ b/xpcom/ds/xpcomds.gqi @@ -34,7 +34,11 @@ %pseudo-iid nsIByteBuffer e4a6e4b0-93b4-11d1-895b-006008911b81 %pseudo-iid nsIUnicharBuffer 14cf6970-93b5-11d1-895b-006008911b81 -NS_IMPL_ISUPPORTS2(nsArray, nsIArray, nsIMutableArray) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsArray) + NS_INTERFACE_MAP_ENTRY(nsIArray) + NS_INTERFACE_MAP_ENTRY(nsIMutableArray) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMutableArray) +NS_INTERFACE_MAP_END NS_IMPL_ISUPPORTS1(nsSimpleProperty, nsIProperty)