From 9238d4066d25feec2fdf5912e0c492dbb0fae488 Mon Sep 17 00:00:00 2001 From: "warren%netscape.com" Date: Wed, 28 Jul 1999 08:01:03 +0000 Subject: [PATCH] Added destructor/cleanup code. git-svn-id: svn://10.0.0.236/trunk@41451 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xpcom/components/nsComponentManager.cpp | 36 +++++++++++++++++-- mozilla/xpcom/components/nsComponentManager.h | 16 ++++----- mozilla/xpcom/components/nsIServiceManager.h | 3 ++ mozilla/xpcom/components/xcDll.cpp | 1 + 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/mozilla/xpcom/components/nsComponentManager.cpp b/mozilla/xpcom/components/nsComponentManager.cpp index 64d6f07c29a..20d5c2ecf26 100644 --- a/mozilla/xpcom/components/nsComponentManager.cpp +++ b/mozilla/xpcom/components/nsComponentManager.cpp @@ -145,6 +145,30 @@ nsComponentManagerImpl::nsComponentManagerImpl() NS_INIT_REFCNT(); } +PRBool +nsFactoryEntry_Destroy(nsHashKey *aKey, void *aData, void* closure) +{ + nsFactoryEntry* entry = NS_STATIC_CAST(nsFactoryEntry*, aData); + delete entry; + return PR_TRUE; +} + +PRBool +nsCID_Destroy(nsHashKey *aKey, void *aData, void* closure) +{ + nsCID* entry = NS_STATIC_CAST(nsCID*, aData); + delete entry; + return PR_TRUE; +} + +PRBool +nsDll_Destroy(nsHashKey *aKey, void *aData, void* closure) +{ + nsDll* entry = NS_STATIC_CAST(nsDll*, aData); + delete entry; + return PR_TRUE; +} + nsresult nsComponentManagerImpl::Init(void) { if (nsComponentManagerLog == NULL) @@ -153,12 +177,16 @@ nsresult nsComponentManagerImpl::Init(void) } if (mFactories == NULL) { - mFactories = new nsHashtable(256, /* Thread Safe */ PR_TRUE); + mFactories = new nsObjectHashtable(nsnull, nsnull, // should never be copied + nsFactoryEntry_Destroy, nsnull, + 256, /* Thread Safe */ PR_TRUE); if (mFactories == NULL) return NS_ERROR_OUT_OF_MEMORY; } if (mProgIDs == NULL) { - mProgIDs = new nsHashtable(256, /* Thread Safe */ PR_TRUE); + mProgIDs = new nsObjectHashtable(nsnull, nsnull, // should never be copied + nsCID_Destroy, nsnull, + 256, /* Thread Safe */ PR_TRUE); if (mProgIDs == NULL) return NS_ERROR_OUT_OF_MEMORY; } @@ -168,7 +196,9 @@ nsresult nsComponentManagerImpl::Init(void) return NS_ERROR_OUT_OF_MEMORY; } if (mDllStore == NULL) { - mDllStore = new nsHashtable(256, /* Thead Safe */ PR_TRUE); + mDllStore = new nsObjectHashtable(nsnull, nsnull, // should never be copied + nsDll_Destroy, nsnull, + 256, /* Thead Safe */ PR_TRUE); if (mDllStore == NULL) return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/xpcom/components/nsComponentManager.h b/mozilla/xpcom/components/nsComponentManager.h index 479814c1b94..f2f9b017b91 100644 --- a/mozilla/xpcom/components/nsComponentManager.h +++ b/mozilla/xpcom/components/nsComponentManager.h @@ -168,14 +168,14 @@ protected: void PlatformSetFileInfo(nsIRegistry::Key Key, PRUint32 lastModifiedTime, PRUint32 fileSize); protected: - nsHashtable* mFactories; - nsHashtable* mProgIDs; - PRMonitor* mMon; - nsHashtable* mDllStore; - nsIRegistry* mRegistry; - nsIRegistry::Key mXPCOMKey; - nsIRegistry::Key mClassesKey; - nsIRegistry::Key mCLSIDKey; + nsObjectHashtable* mFactories; + nsObjectHashtable* mProgIDs; + PRMonitor* mMon; + nsObjectHashtable* mDllStore; + nsIRegistry* mRegistry; + nsIRegistry::Key mXPCOMKey; + nsIRegistry::Key mClassesKey; + nsIRegistry::Key mCLSIDKey; }; #define NS_MAX_FILENAME_LEN 1024 diff --git a/mozilla/xpcom/components/nsIServiceManager.h b/mozilla/xpcom/components/nsIServiceManager.h index ed6f39b1615..0c7c200c58f 100644 --- a/mozilla/xpcom/components/nsIServiceManager.h +++ b/mozilla/xpcom/components/nsIServiceManager.h @@ -338,6 +338,9 @@ NS_NewServiceManager(nsIServiceManager* *result); extern NS_COM nsresult NS_InitXPCOM(nsIServiceManager* *result); +extern NS_COM nsresult +NS_ShutdownXPCOM(nsIServiceManager* servMgr); + //////////////////////////////////////////////////////////////////////////////// #endif /* nsIServiceManager_h___ */ diff --git a/mozilla/xpcom/components/xcDll.cpp b/mozilla/xpcom/components/xcDll.cpp index 664dce9638e..c6f419a3c76 100644 --- a/mozilla/xpcom/components/xcDll.cpp +++ b/mozilla/xpcom/components/xcDll.cpp @@ -136,6 +136,7 @@ nsDll::Init(const char *libPersistentDescriptor) } Init(dllSpec); + NS_RELEASE(dllSpec); }