зеркало из https://github.com/mozilla/pjs.git
removing dynamically allocated hashtable in xpcom where possible. r=alecf, b=204634
This commit is contained in:
Родитель
2334f53748
Коммит
fda508d773
|
@ -52,13 +52,6 @@
|
|||
#include "prlog.h"
|
||||
extern PRLogModuleInfo *nsComponentManagerLog;
|
||||
|
||||
nsNativeComponentLoader::nsNativeComponentLoader() :
|
||||
mCompMgr(nsnull),
|
||||
mLoadedDependentLibs(nsnull),
|
||||
mDllStore(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
static PRBool PR_CALLBACK
|
||||
DLLStore_Destroy(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
|
@ -67,11 +60,17 @@ DLLStore_Destroy(nsHashKey *aKey, void *aData, void* closure)
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsNativeComponentLoader::nsNativeComponentLoader() :
|
||||
mCompMgr(nsnull),
|
||||
mLoadedDependentLibs(16, PR_TRUE),
|
||||
mDllStore(nsnull, nsnull, DLLStore_Destroy,
|
||||
nsnull, 256, PR_TRUE)
|
||||
{
|
||||
}
|
||||
|
||||
nsNativeComponentLoader::~nsNativeComponentLoader()
|
||||
{
|
||||
mCompMgr = nsnull;
|
||||
delete mDllStore;
|
||||
delete mLoadedDependentLibs;
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsNativeComponentLoader,
|
||||
|
@ -158,20 +157,6 @@ nsNativeComponentLoader::Init(nsIComponentManager *aCompMgr, nsISupports *aReg)
|
|||
if (!mCompMgr)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
mDllStore = new nsObjectHashtable(nsnull,
|
||||
nsnull,
|
||||
DLLStore_Destroy,
|
||||
nsnull,
|
||||
256,
|
||||
PR_TRUE);
|
||||
if (!mDllStore)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
mLoadedDependentLibs = new nsHashtable(16, PR_TRUE);
|
||||
|
||||
if (!mLoadedDependentLibs)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -641,7 +626,7 @@ nsNativeComponentLoader::AutoUnregisterComponent(PRInt32 when,
|
|||
|
||||
// Remove any autoreg info about this dll
|
||||
nsCStringKey key(persistentDescriptor);
|
||||
mDllStore->RemoveAndDelete(&key);
|
||||
mDllStore.RemoveAndDelete(&key);
|
||||
|
||||
nsCOMPtr<nsIComponentLoaderManager> manager = do_QueryInterface(mCompMgr);
|
||||
NS_ASSERTION(manager, "Something is terribly wrong");
|
||||
|
@ -872,7 +857,7 @@ nsNativeComponentLoader::AutoRegisterComponent(PRInt32 when,
|
|||
dll = new nsDll(component, this);
|
||||
if (dll == NULL)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
mDllStore->Put(&key, (void *) dll);
|
||||
mDllStore.Put(&key, (void *) dll);
|
||||
} // dll == NULL
|
||||
|
||||
// Either we are seeing the dll for the first time or the dll has
|
||||
|
@ -973,9 +958,7 @@ nsNativeComponentLoader::UnloadAll(PRInt32 aWhen)
|
|||
callData.when = aWhen;
|
||||
|
||||
// Cycle through the dlls checking to see if they want to be unloaded
|
||||
if (mDllStore) {
|
||||
mDllStore->Enumerate(nsFreeLibraryEnum, &callData);
|
||||
}
|
||||
mDllStore.Enumerate(nsFreeLibraryEnum, &callData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1008,7 +991,7 @@ nsNativeComponentLoader::CreateDll(nsIFile *aSpec,
|
|||
nsresult rv;
|
||||
|
||||
nsCStringKey key(aLocation);
|
||||
dll = (nsDll *)mDllStore->Get(&key);
|
||||
dll = (nsDll *)mDllStore.Get(&key);
|
||||
if (dll)
|
||||
{
|
||||
*aDll = dll;
|
||||
|
@ -1039,7 +1022,7 @@ nsNativeComponentLoader::CreateDll(nsIFile *aSpec,
|
|||
}
|
||||
|
||||
*aDll = dll;
|
||||
mDllStore->Put(&key, dll);
|
||||
mDllStore.Put(&key, dll);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,10 +41,10 @@ class nsNativeComponentLoader : public nsIComponentLoader, public nsINativeCompo
|
|||
virtual ~nsNativeComponentLoader();
|
||||
|
||||
nsIComponentManager* mCompMgr; // weak reference -- backpointer
|
||||
nsHashtable* mLoadedDependentLibs;
|
||||
nsHashtable mLoadedDependentLibs;
|
||||
|
||||
private:
|
||||
nsObjectHashtable* mDllStore;
|
||||
nsObjectHashtable mDllStore;
|
||||
nsVoidArray mDeferredComponents;
|
||||
|
||||
NS_IMETHOD RegisterComponentsInDir(PRInt32 when, nsIFile *dir);
|
||||
|
|
|
@ -144,11 +144,6 @@ PRBool nsDll::Load(void)
|
|||
// on the dependent libraries with the assumption that the
|
||||
// component library holds a reference via the OS so loader.
|
||||
|
||||
if (!m_loader->mLoadedDependentLibs) {
|
||||
NS_ERROR("huh? no dependent libs");
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
#if defined(XP_UNIX)
|
||||
nsCOMPtr<nsIComponentLoaderManager> manager = do_QueryInterface(m_loader->mCompMgr);
|
||||
if (!manager)
|
||||
|
@ -188,12 +183,12 @@ PRBool nsDll::Load(void)
|
|||
while (token!=nsnull)
|
||||
{
|
||||
nsCStringKey key(token);
|
||||
if (m_loader->mLoadedDependentLibs->Get(&key)) {
|
||||
if (m_loader.mLoadedDependentLibs->Get(&key)) {
|
||||
token = nsCRT::strtok(newStr, " ", &newStr);
|
||||
continue;
|
||||
}
|
||||
|
||||
m_loader->mLoadedDependentLibs->Put(&key, (void*)1);
|
||||
m_loader.mLoadedDependentLibs->Put(&key, (void*)1);
|
||||
|
||||
nsXPIDLCString libpath;
|
||||
file->SetNativeLeafName(nsDependentCString(token));
|
||||
|
|
|
@ -74,7 +74,6 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsObserverService, nsIObserverService)
|
|||
nsObserverService::nsObserverService()
|
||||
: mObserverTopicTable(nsnull)
|
||||
{
|
||||
mObserverTopicTable = nsnull;
|
||||
}
|
||||
|
||||
nsObserverService::~nsObserverService(void)
|
||||
|
|
|
@ -523,7 +523,7 @@ nsGREDirServiceProvider::AddGRELocationToPath()
|
|||
}
|
||||
|
||||
if (mPathEnvString)
|
||||
PR_Free(mPathEnvString);
|
||||
PR_smprintf_free(mPathEnvString);
|
||||
|
||||
mPathEnvString = PR_smprintf("%s=%s;%s",
|
||||
XPCOM_SEARCH_KEY,
|
||||
|
|
|
@ -182,15 +182,15 @@ public:
|
|||
|
||||
static void Shutdown();
|
||||
|
||||
nsHashtable* GetRealObjectToProxyObjectMap() const { return mProxyObjectMap;}
|
||||
nsHashtable* GetIIDToProxyClassMap() const { return mProxyClassMap; }
|
||||
nsHashtable* GetRealObjectToProxyObjectMap() { return &mProxyObjectMap;}
|
||||
nsHashtable* GetIIDToProxyClassMap() { return &mProxyClassMap; }
|
||||
|
||||
PRMonitor* GetMonitor() const { return mProxyCreationMonitor; }
|
||||
|
||||
private:
|
||||
static nsProxyObjectManager* mInstance;
|
||||
nsHashtable *mProxyObjectMap;
|
||||
nsHashtable *mProxyClassMap;
|
||||
nsHashtable mProxyObjectMap;
|
||||
nsHashtable mProxyClassMap;
|
||||
PRMonitor *mProxyCreationMonitor;
|
||||
};
|
||||
|
||||
|
|
|
@ -114,10 +114,9 @@ nsProxyObjectManager* nsProxyObjectManager::mInstance = nsnull;
|
|||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsProxyObjectManager, nsIProxyObjectManager)
|
||||
|
||||
nsProxyObjectManager::nsProxyObjectManager()
|
||||
: mProxyClassMap(256, PR_TRUE),
|
||||
mProxyObjectMap(256, PR_TRUE)
|
||||
{
|
||||
mProxyClassMap = new nsHashtable(256, PR_TRUE);
|
||||
mProxyObjectMap = new nsHashtable(256, PR_TRUE);
|
||||
|
||||
mProxyCreationMonitor = PR_NewMonitor();
|
||||
}
|
||||
|
||||
|
@ -130,13 +129,7 @@ static PRBool PurgeProxyClasses(nsHashKey *aKey, void *aData, void* closure)
|
|||
|
||||
nsProxyObjectManager::~nsProxyObjectManager()
|
||||
{
|
||||
if (mProxyClassMap)
|
||||
{
|
||||
mProxyClassMap->Reset((nsHashtableEnumFunc)PurgeProxyClasses, nsnull);
|
||||
delete mProxyClassMap;
|
||||
}
|
||||
|
||||
delete mProxyObjectMap;
|
||||
mProxyClassMap.Reset((nsHashtableEnumFunc)PurgeProxyClasses, nsnull);
|
||||
|
||||
if (mProxyCreationMonitor) {
|
||||
PR_DestroyMonitor(mProxyCreationMonitor);
|
||||
|
|
Загрузка…
Ссылка в новой задаче