From 920f29e2889ff5b88d6462176880fc2eea459bd1 Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Thu, 27 Jul 2000 06:14:06 +0000 Subject: [PATCH] bug 46413. r/a=valeski@netscape.com Clean up memory leaks. --- chrome/src/nsChromeRegistry.cpp | 20 ++++++++++++++++++++ rdf/chrome/src/nsChromeRegistry.cpp | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp index 527d3e12f280..b1d4debcc826 100644 --- a/chrome/src/nsChromeRegistry.cpp +++ b/chrome/src/nsChromeRegistry.cpp @@ -252,8 +252,28 @@ nsChromeRegistry::nsChromeRegistry() } } + +static PRBool DatasourceEnumerator(nsHashKey *aKey, void *aData, void* closure) +{ + if (!closure || !aData) + return PR_FALSE; + + nsIRDFCompositeDataSource* compositeDS = (nsIRDFCompositeDataSource*) closure; + + nsCOMPtr supports = (nsISupports*)aData; + + nsCOMPtr dataSource = do_QueryInterface(supports); + if (!dataSource) + return PR_FALSE; + + compositeDS->RemoveDataSource(dataSource); + return PR_TRUE; +} + + nsChromeRegistry::~nsChromeRegistry() { + mDataSourceTable->Enumerate(DatasourceEnumerator, mChromeDataSource); delete mDataSourceTable; if (mRDFService) { diff --git a/rdf/chrome/src/nsChromeRegistry.cpp b/rdf/chrome/src/nsChromeRegistry.cpp index 527d3e12f280..b1d4debcc826 100644 --- a/rdf/chrome/src/nsChromeRegistry.cpp +++ b/rdf/chrome/src/nsChromeRegistry.cpp @@ -252,8 +252,28 @@ nsChromeRegistry::nsChromeRegistry() } } + +static PRBool DatasourceEnumerator(nsHashKey *aKey, void *aData, void* closure) +{ + if (!closure || !aData) + return PR_FALSE; + + nsIRDFCompositeDataSource* compositeDS = (nsIRDFCompositeDataSource*) closure; + + nsCOMPtr supports = (nsISupports*)aData; + + nsCOMPtr dataSource = do_QueryInterface(supports); + if (!dataSource) + return PR_FALSE; + + compositeDS->RemoveDataSource(dataSource); + return PR_TRUE; +} + + nsChromeRegistry::~nsChromeRegistry() { + mDataSourceTable->Enumerate(DatasourceEnumerator, mChromeDataSource); delete mDataSourceTable; if (mRDFService) {