compmgr-more
author Benjamin Smedberg <benjamin@smedbergs.us>
Sat, 26 Jul 2008 22:49:39 -0400
changeset 167 a4da40849f5436e629c5732f4368c6c48189637f
parent 95 b35cbfa6ad4f8bac97b5a0ae2a3bfc18ed88de35
permissions -rw-r--r--
State as of now

diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -168,7 +168,7 @@ nsGetServiceFromCategory::get(const nsII
 {
     nsresult rv;
     nsXPIDLCString value;
-    nsCOMPtr<nsICategoryManager> catman;
+    nsICategoryManager* catman = nsnull;
     void *result = NULL;
     nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
     if (!compMgr) {
@@ -184,7 +184,7 @@ nsGetServiceFromCategory::get(const nsII
 
     rv = compMgr->nsComponentManagerImpl::GetService(kCategoryManagerCID,
                                                      NS_GET_IID(nsICategoryManager),
-                                                     getter_AddRefs(catman));
+                                                     (void**)&catman);
     if (NS_FAILED(rv)) goto error;
 
     /* find the contractID for category.entry */
@@ -515,12 +515,12 @@ ConvertFactoryEntryToCID(PLDHashTable *t
                          void *data, nsISupports **retval)
 {
     nsresult rv;
-    nsCOMPtr<nsISupportsID> wrapper;
+    nsISupportsID* wrapper = nsnull;
 
     nsComponentManagerImpl *cm = static_cast<nsComponentManagerImpl *>(data);
 
     rv = cm->CreateInstanceByContractID(NS_SUPPORTS_ID_CONTRACTID, nsnull,
-           NS_GET_IID(nsISupportsID), getter_AddRefs(wrapper));
+           NS_GET_IID(nsISupportsID), (void**)&wrapper);
 
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -545,12 +545,12 @@ ConvertContractIDKeyToString(PLDHashTabl
                              void *data, nsISupports **retval)
 {
     nsresult rv;
-    nsCOMPtr<nsISupportsCString> wrapper;
+    nsISupportsCString* wrapper = nsnull;
 
     nsComponentManagerImpl *cm = static_cast<nsComponentManagerImpl *>(data);
 
     rv = cm->CreateInstanceByContractID(NS_SUPPORTS_CSTRING_CONTRACTID, nsnull,
-                NS_GET_IID(nsISupportsCString), getter_AddRefs(wrapper));
+                NS_GET_IID(nsISupportsCString), (void**)&wrapper);
 
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -568,10 +568,10 @@ static nsresult GetLocationFromDirectory
 static nsresult GetLocationFromDirectoryService(const char* prop,
                                                 nsIFile** aDirectory)
 {
-    nsCOMPtr<nsIProperties> directoryService;
+    nsIProperties* directoryService = nsnull;
     nsDirectoryService::Create(nsnull,
                                NS_GET_IID(nsIProperties),
-                               getter_AddRefs(directoryService));
+                               (void**)&directoryService);
 
     if (!directoryService)
         return NS_ERROR_FAILURE;
@@ -847,12 +847,12 @@ nsComponentManagerImpl::ReadPersistentRe
         return NS_ERROR_FILE_NOT_FOUND;
     }
 
-    nsCOMPtr<nsIFile> file;
-    mRegistryFile->Clone(getter_AddRefs(file));
+    nsIFile* file = nsnull;
+    mRegistryFile->Clone(&file);
     if (!file)
         return NS_ERROR_OUT_OF_MEMORY;
 
-    nsCOMPtr<nsILocalFile> localFile(do_QueryInterface(file));
+    nsILocalFile* localFile(do_QueryInterface(file));
 
     rv = localFile->OpenNSPRFileDesc(PR_RDONLY, 0444, &fd);
     if (NS_FAILED(rv))
@@ -927,13 +927,13 @@ nsComponentManagerImpl::ReadPersistentRe
 
         PRInt64 a = nsCRT::atoll(values[1]);
 
-        nsCOMPtr<nsILocalFile> lf;
+        nsILocalFile* lf = nsnull;
         rv = FileForRegistryLocation(nsDependentCString(values[0], lengths[0]),
-                                     getter_AddRefs(lf));
+                                     &lf);
         if (NS_FAILED(rv))
             continue;
 
-        nsCOMPtr<nsIHashable> lfhash(do_QueryInterface(lf));
+        nsIHashable* lfhash(do_QueryInterface(lf));
         if (!lf) {
             NS_ERROR("nsLocalFile does not implement nsIHashable");
             continue;
@@ -1165,7 +1165,7 @@ ClassIDWriter(PLDHashTable *table,
 
     char *contractID = nsnull, *className = nsnull;
 
-    nsCOMPtr<nsIClassInfo> classInfo = do_QueryInterface(factoryEntry->mFactory);
+    nsIClassInfo* classInfo = do_QueryInterface(factoryEntry->mFactory);
     if (classInfo)
     {
         classInfo->GetContractID(&contractID);
@@ -1210,7 +1210,7 @@ AutoRegEntryWriter(nsIHashable *aKey, PR
 {
     PRFileDesc* fd = (PRFileDesc*) aClosure;
 
-    nsCOMPtr<nsILocalFile> lf(do_QueryInterface(aKey));
+    nsILocalFile* lf(do_QueryInterface(aKey));
 
     nsCAutoString location;
     nsComponentManagerImpl::gComponentManager->
@@ -1227,12 +1227,12 @@ nsComponentManagerImpl::WritePersistentR
     if (!mRegistryFile)
         return NS_ERROR_FAILURE;  // this should have been set by Init().
 
-    nsCOMPtr<nsIFile> file;
-    mRegistryFile->Clone(getter_AddRefs(file));
+    nsIFile* file = nsnull;
+    mRegistryFile->Clone(&file);
     if (!file)
         return NS_ERROR_OUT_OF_MEMORY;
 
-    nsCOMPtr<nsILocalFile> localFile(do_QueryInterface(file));
+    nsILocalFile* localFile(do_QueryInterface(file));
 
     nsCAutoString originalLeafName;
     localFile->GetNativeLeafName(originalLeafName);
@@ -1312,8 +1312,8 @@ out:
     if(exists && NS_FAILED(mRegistryFile->Remove(PR_FALSE)))
         return PR_FALSE;
 
-    nsCOMPtr<nsIFile> parent;
-    mRegistryFile->GetParent(getter_AddRefs(parent));
+    nsIFile* parent = nsnull;
+    mRegistryFile->GetParent(&parent);
 
     rv = localFile->MoveToNative(parent, originalLeafName);
     mRegistryDirty = PR_FALSE;
@@ -1453,7 +1453,7 @@ nsComponentManagerImpl::GetClassObject(c
 {
     nsresult rv;
 
-    nsCOMPtr<nsIFactory> factory;
+    nsIFactory* factory = nsnull;
 
 #ifdef PR_LOGGING
     if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_DEBUG))
@@ -1467,7 +1467,7 @@ nsComponentManagerImpl::GetClassObject(c
 
     PR_ASSERT(aResult != nsnull);
 
-    rv = FindFactory(aClass, getter_AddRefs(factory));
+    rv = FindFactory(aClass, &factory);
     if (NS_FAILED(rv)) return rv;
 
     rv = factory->QueryInterface(aIID, aResult);
@@ -1486,7 +1486,7 @@ nsComponentManagerImpl::GetClassObjectBy
 {
     nsresult rv;
 
-    nsCOMPtr<nsIFactory> factory;
+    nsIFactory* factory = nsnull;
 
 #ifdef PR_LOGGING
     if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_DEBUG))
@@ -1497,7 +1497,7 @@ nsComponentManagerImpl::GetClassObjectBy
 
     PR_ASSERT(aResult != nsnull);
 
-    rv = FindFactory(contractID, strlen(contractID), getter_AddRefs(factory));
+    rv = FindFactory(contractID, strlen(contractID), &factory);
     if (NS_FAILED(rv)) return rv;
 
     rv = factory->QueryInterface(aIID, aResult);
@@ -1862,7 +1862,7 @@ nsComponentManagerImpl::GetService(const
     }
 
     if (entry && entry->mServiceObject) {
-        nsCOMPtr<nsISupports> supports = entry->mServiceObject;
+        nsISupports* supports = entry->mServiceObject;
         mon.Exit();
         return supports->QueryInterface(aIID, result);
     }
@@ -1872,13 +1872,13 @@ nsComponentManagerImpl::GetService(const
     if (NS_FAILED(rv))
         return rv; // NOP_AND_BREAK
 #endif
-    nsCOMPtr<nsISupports> service;
+    nsISupports* service = nsnull;
     // We need to not be holding the service manager's monitor while calling
     // CreateInstance, because it invokes user code which could try to re-enter
     // the service manager:
     mon.Exit();
 
-    rv = CreateInstance(aClass, nsnull, aIID, getter_AddRefs(service));
+    rv = CreateInstance(aClass, nsnull, aIID, (void**)&service);
 
     mon.Enter();
 
@@ -1902,7 +1902,7 @@ nsComponentManagerImpl::GetService(const
     }
 
     entry->mServiceObject = service;
-    *result = service.get();
+    *result = service;
     if (!*result) {
         NS_ERROR("Factory did not return an object but returned success!");
         return NS_ERROR_SERVICE_NOT_FOUND;
@@ -2052,8 +2052,8 @@ nsComponentManagerImpl::IsServiceInstant
     }
 
     if (entry && entry->mServiceObject) {
-        nsCOMPtr<nsISupports> service;
-        rv = entry->mServiceObject->QueryInterface(aIID, getter_AddRefs(service));
+        nsISupports* service = nsnull;
+        rv = entry->mServiceObject->QueryInterface(aIID, (void**)&service);
         *result = (service!=nsnull);
     }
     return rv;
@@ -2097,8 +2097,8 @@ NS_IMETHODIMP nsComponentManagerImpl::Is
     }   // exit monitor
 
     if (entry && entry->mServiceObject) {
-        nsCOMPtr<nsISupports> service;
-        rv = entry->mServiceObject->QueryInterface(aIID, getter_AddRefs(service));
+        nsISupports* service = nsnull;
+        rv = entry->mServiceObject->QueryInterface(aIID, (void**)&service);
         *result = (service!=nsnull);
     }
     return rv;
@@ -2163,7 +2163,7 @@ nsComponentManagerImpl::GetServiceByCont
 
     if (entry) {
         if (entry->mServiceObject) {
-            nsCOMPtr<nsISupports> serviceObject = entry->mServiceObject;
+            nsISupports* serviceObject = entry->mServiceObject;
 
             // We need to not be holding the service manager's monitor while calling
             // QueryInterface, because it invokes user code which could try to re-enter
@@ -2179,13 +2179,13 @@ nsComponentManagerImpl::GetServiceByCont
 #endif
     }
 
-    nsCOMPtr<nsISupports> service;
+    nsISupports* service = nsnull;
     // We need to not be holding the service manager's monitor while calling
     // CreateInstance, because it invokes user code which could try to re-enter
     // the service manager:
     mon.Exit();
 
-    rv = CreateInstanceByContractID(aContractID, nsnull, aIID, getter_AddRefs(service));
+    rv = CreateInstanceByContractID(aContractID, nsnull, aIID, (void**)&service);
 
     mon.Enter();
 
@@ -2211,8 +2211,7 @@ nsComponentManagerImpl::GetServiceByCont
     }
 
     entry->mServiceObject = service;
-    *result = service.get();
-    NS_ADDREF(static_cast<nsISupports*>(*result));
+    *result = service;
     return rv;
 }
 
@@ -2647,13 +2646,13 @@ nsComponentManagerImpl::LoaderForType(Lo
                  "LoaderType out of range");
 
     if (!mLoaderData[aType].loader) {
-        nsCOMPtr<nsIModuleLoader> loader;
+        nsIModuleLoader* loader = nsnull;
         loader = do_GetServiceFromCategory("module-loader",
                                            mLoaderData[aType].type.get());
         if (!loader)
             return nsnull;
 
-        loader.swap(mLoaderData[aType].loader);
+        swap(loader, mLoaderData[aType].loader);
     }
 
     return mLoaderData[aType].loader;
@@ -2664,10 +2663,10 @@ nsComponentManagerImpl::GetAllLoaders()
 {
     NS_ASSERTION(mCategoryManager, "nsComponentManager used uninitialized");
 
-    nsCOMPtr<nsISimpleEnumerator> loaderEnum;
+    nsISimpleEnumerator* loaderEnum = nsnull;
     mCategoryManager->EnumerateCategory("module-loader",
-                                        getter_AddRefs(loaderEnum));
-    nsCOMPtr<nsIUTF8StringEnumerator>
+                                        &loaderEnum);
+    nsIUTF8StringEnumerator*
         loaderStrings(do_QueryInterface(loaderEnum));
     if (loaderStrings) {
         PRBool hasMore;
@@ -2846,7 +2845,7 @@ nsresult
 nsresult
 nsComponentManagerImpl::AutoRegisterImpl(nsIFile   *inDirSpec,
                           nsCOMArray<nsILocalFile> &aLeftovers,
-                          nsTArray<DeferredModule> &aDeferred)
+                          nsTArray<DeferredModule, GCAllocator> &aDeferred)
 {
     NS_ASSERTION(inDirSpec, "inDirSpec must not be null");
 
@@ -2860,7 +2859,7 @@ nsComponentManagerImpl::AutoRegisterImpl
     if (isDir)
         return AutoRegisterDirectory(inDirSpec, aLeftovers, aDeferred);
 
-    nsCOMPtr<nsILocalFile> lf(do_QueryInterface(inDirSpec));
+    nsILocalFile* lf(do_QueryInterface(inDirSpec));
     if (!lf)
         return NS_NOINTERFACE;
 
@@ -2873,19 +2872,19 @@ nsresult
 nsresult
 nsComponentManagerImpl::AutoRegisterDirectory(nsIFile *inDirSpec,
                           nsCOMArray<nsILocalFile>    &aLeftovers,
-                          nsTArray<DeferredModule>    &aDeferred)
+                          nsTArray<DeferredModule, GCAllocator>    &aDeferred)
 {
-    nsCOMPtr<nsISimpleEnumerator> entries;
-    nsresult rv = inDirSpec->GetDirectoryEntries(getter_AddRefs(entries));
+    nsISimpleEnumerator* entries = nsnull;
+    nsresult rv = inDirSpec->GetDirectoryEntries(&entries);
     if (NS_FAILED(rv))
         return rv;
 
     PRBool hasMore;
-    nsCOMPtr<nsISupports> elem;
+    nsISupports* elem = nsnull;
 
     while (NS_SUCCEEDED(entries->HasMoreElements(&hasMore)) && hasMore) {
-        entries->GetNext(getter_AddRefs(elem));
-        nsCOMPtr<nsILocalFile> lf(do_QueryInterface(elem));
+        entries->GetNext(&elem);
+        nsILocalFile* lf(do_QueryInterface(elem));
         if (!lf) {
             NS_ERROR("Directory enumerator misbehaving");
             continue;
@@ -2912,13 +2911,13 @@ nsComponentManagerImpl::AutoRegisterComp
 nsComponentManagerImpl::AutoRegisterComponent(PRInt32 unused,
                                               nsIFile *component)
 {
-    nsCOMPtr<nsILocalFile> lf(do_QueryInterface(component));
+    nsILocalFile* lf(do_QueryInterface(component));
     if (!lf)
         return NS_NOINTERFACE;
 
     GetAllLoaders();
 
-    nsTArray<DeferredModule> deferred;
+    nsTArray<DeferredModule, GCAllocator> deferred;
 
     nsresult rv = AutoRegisterComponent(lf, deferred);
     if (deferred.Length())
@@ -2929,7 +2928,7 @@ nsComponentManagerImpl::AutoRegisterComp
 
 nsresult
 nsComponentManagerImpl::AutoRegisterComponent(nsILocalFile*  aComponentFile,
-                                   nsTArray<DeferredModule> &aDeferred,
+                                   nsTArray<DeferredModule, GCAllocator> &aDeferred,
                                    LoaderType                minLoader)
 {
     nsresult rv;
@@ -2946,7 +2945,7 @@ nsComponentManagerImpl::AutoRegisterComp
         extension.LowerCaseEqualsLiteral(".xpt"))
         return NS_OK;
 
-    nsCOMPtr<nsIHashable> lfhash(do_QueryInterface(aComponentFile));
+    nsIHashable* lfhash(do_QueryInterface(aComponentFile));
     if (!lfhash) {
         NS_ERROR("localfile not implementing nsIHashable!");
         return NS_NOINTERFACE;
@@ -2962,11 +2961,11 @@ nsComponentManagerImpl::AutoRegisterComp
 
     const char *registryType = nsnull;
 
-    nsCOMPtr<nsIModule> module;
+    nsIModule* module = nsnull;
 
     if (minLoader == NS_LOADER_TYPE_NATIVE) {
         rv = mNativeModuleLoader.LoadModule(aComponentFile,
-                                            getter_AddRefs(module));
+                                            &module);
         if (NS_SUCCEEDED(rv)) {
             if (!module) {
                 NS_ERROR("Module loader succeeded without returning a module");
@@ -2984,7 +2983,7 @@ nsComponentManagerImpl::AutoRegisterComp
             if (!loader)
                 continue;
 
-            rv = loader->LoadModule(aComponentFile, getter_AddRefs(module));
+            rv = loader->LoadModule(aComponentFile, &module);
             if (NS_SUCCEEDED(rv)) {
                 if (!module) {
                     NS_ERROR("Module loader succeeded without returning a module.");
@@ -3023,7 +3022,7 @@ void
 void
 nsComponentManagerImpl::LoadLeftoverComponents(
   nsCOMArray<nsILocalFile> &aLeftovers,
-  nsTArray<DeferredModule> &aDeferred,
+  nsTArray<DeferredModule, GCAllocator> &aDeferred,
   LoaderType                minLoader)
 {
     NS_ASSERTION(minLoader >= GetLoaderCount(), "Corrupted minLoader");
@@ -3053,7 +3052,7 @@ nsComponentManagerImpl::LoadLeftoverComp
 }
 
 void
-nsComponentManagerImpl::LoadDeferredModules(nsTArray<DeferredModule> &aDeferred)
+nsComponentManagerImpl::LoadDeferredModules(nsTArray<DeferredModule, GCAllocator> &aDeferred)
 {
     // We keep looping through deferred components until one of
     // 1) they're all gone
@@ -3072,7 +3071,7 @@ nsComponentManagerImpl::LoadDeferredModu
                                                  d.location.get(),
                                                  d.type);
             if (NS_SUCCEEDED(rv) && d.modTime != 0) {
-                nsCOMPtr<nsIHashable> lfhash(do_QueryInterface(d.file));
+                nsIHashable* lfhash(do_QueryInterface(d.file));
                 if (lfhash)
                     mAutoRegEntries.Put(lfhash, d.modTime);
             }
@@ -3097,19 +3096,19 @@ nsComponentManagerImpl::AutoUnregisterCo
     if (NS_FAILED(rv))
         return rv;
 
-    nsCOMPtr<nsILocalFile> lf(do_QueryInterface(component));
+    nsILocalFile* lf(do_QueryInterface(component));
     if (!lf)
         return NS_NOINTERFACE;
 
-    nsCOMPtr<nsIModule> module;
-    rv = mNativeModuleLoader.LoadModule(lf, getter_AddRefs(module));
+    nsIModule* module = nsnull;
+    rv = mNativeModuleLoader.LoadModule(lf, &module);
     if (NS_FAILED(rv)) {
         for (LoaderType i = 0; i < mLoaderData.Length(); ++i) {
             nsIModuleLoader* loader = LoaderForType(i);
             if (!loader)
                 continue;
 
-            if (NS_SUCCEEDED(loader->LoadModule(lf, getter_AddRefs(module))) &&
+            if (NS_SUCCEEDED(loader->LoadModule(lf, &module)) &&
                 module) {
                 break;
             }
@@ -3121,7 +3120,7 @@ nsComponentManagerImpl::AutoUnregisterCo
 
     rv = module->UnregisterSelf(this, lf, location.get());
 
-    nsCOMPtr<nsIHashable> lfhash(do_QueryInterface(lf));
+    nsIHashable* lfhash(do_QueryInterface(lf));
     mAutoRegEntries.Remove(lfhash);
 
     return rv;
@@ -3192,7 +3191,7 @@ nsComponentManagerImpl::EnumerateContrac
 
 static void
 RegisterStaticModule(const char *key, nsIModule* module,
-                     nsTArray<DeferredModule> &deferred)
+                     nsTArray<DeferredModule, GCAllocator> &deferred)
 {
     nsresult rv = module->
         RegisterSelf(nsComponentManagerImpl::gComponentManager,
@@ -3238,7 +3237,7 @@ nsComponentManagerImpl::AutoRegister(nsI
                                   aSpec, "start");
 
     nsCOMArray<nsILocalFile> leftovers;
-    nsTArray<DeferredModule> deferred;
+    nsTArray<DeferredModule, GCAllocator> deferred;
 
     if (!aSpec) {
         mStaticModuleLoader.EnumerateModules(RegisterStaticModule,
@@ -3275,18 +3274,18 @@ nsComponentManagerImpl::AutoRegister(nsI
             NS_WARNING("Couldn't register mComponentsDir");
         }
 
-        nsCOMPtr<nsISimpleEnumerator> dirList;
+        nsISimpleEnumerator* dirList = nsnull;
         rv = nsDirectoryService::gService->Get(NS_XPCOM_COMPONENT_DIR_LIST,
                                                NS_GET_IID(nsISimpleEnumerator),
-                                               getter_AddRefs(dirList));
+                                               (void**)&dirList);
         if (NS_SUCCEEDED(rv) && dirList) {
             PRBool hasMore;
-            nsCOMPtr<nsISupports> elem;
+            nsISupports* elem = nsnull;
 
             while (NS_SUCCEEDED(dirList->HasMoreElements(&hasMore)) &&
                    hasMore) {
-                dirList->GetNext(getter_AddRefs(elem));
-                nsCOMPtr<nsIFile> dir(do_QueryInterface(elem));
+                dirList->GetNext(&elem);
+                nsIFile* dir(do_QueryInterface(elem));
                 if (dir) {
                     AutoRegisterImpl(dir, leftovers, deferred);
                 }
@@ -3306,7 +3305,7 @@ nsComponentManagerImpl::AutoRegister(nsI
         if (deferred.Length())
             LoadDeferredModules(deferred);
 
-        nsCOMPtr<nsIConsoleService>
+        nsIConsoleService*
             cs(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
 
         if (cs) {
@@ -3521,19 +3520,19 @@ nsFactoryEntry::GetFactory(nsIFactory **
         if (mLoaderType == NS_LOADER_TYPE_INVALID)
             return NS_ERROR_FAILURE;
 
-        nsCOMPtr<nsIModule> module;
+        nsIModule* module = nsnull;
 
         if (mLoaderType == NS_LOADER_TYPE_STATIC) {
             rv = nsComponentManagerImpl::gComponentManager->
                 mStaticModuleLoader.
                 GetModuleFor(mLocationKey,
-                             getter_AddRefs(module));
+                             &module);
         }
         else {
-            nsCOMPtr<nsILocalFile> moduleFile;
+            nsILocalFile* moduleFile = nsnull;
             rv = nsComponentManagerImpl::gComponentManager->
                 FileForRegistryLocation(nsDependentCString(mLocationKey),
-                                        getter_AddRefs(moduleFile));
+                                        &moduleFile);
             NS_ENSURE_SUCCESS(rv, rv);
 
             nsIModuleLoader* loader =
@@ -3543,7 +3542,7 @@ nsFactoryEntry::GetFactory(nsIFactory **
                 return NS_ERROR_FAILURE;
 
             rv = loader->LoadModule(moduleFile,
-                                    getter_AddRefs(module));
+                                    &module);
         }
 
         if (NS_FAILED(rv))
diff --git a/xpcom/components/nsComponentManager.h b/xpcom/components/nsComponentManager.h
--- a/xpcom/components/nsComponentManager.h
+++ b/xpcom/components/nsComponentManager.h
@@ -218,18 +218,18 @@ public:
     void DeleteContractIDEntriesByCID(const nsCID* aClass, nsIFactory* factory);
     nsresult AutoRegisterImpl(nsIFile*                  inDirSpec,
                               nsCOMArray<nsILocalFile> &aLeftovers,
-                              nsTArray<DeferredModule> &aDeferred);
+                              nsTArray<DeferredModule, GCAllocator> &aDeferred);
     nsresult AutoRegisterDirectory(nsIFile*                  aComponentFile,
                                    nsCOMArray<nsILocalFile> &aLeftovers,
-                                   nsTArray<DeferredModule> &aDeferred);
+                                   nsTArray<DeferredModule, GCAllocator> &aDeferred);
     nsresult AutoRegisterComponent(nsILocalFile*             aComponentFile,
-                                   nsTArray<DeferredModule> &aDeferred,
+                                   nsTArray<DeferredModule, GCAllocator> &aDeferred,
                                    LoaderType                minLoader = NS_LOADER_TYPE_NATIVE);
     void LoadLeftoverComponents(nsCOMArray<nsILocalFile> &aLeftovers,
-                                nsTArray<DeferredModule> &aDeferred,
+                                nsTArray<DeferredModule, GCAllocator> &aDeferred,
                                 LoaderType                minLoader);
 
-    void LoadDeferredModules(nsTArray<DeferredModule> &aDeferred);
+    void LoadDeferredModules(nsTArray<DeferredModule, GCAllocator> &aDeferred);
 
     PLDHashTable        mFactories;
     PLDHashTable        mContractIDs;
diff --git a/xpcom/components/nsStaticComponentLoader.cpp b/xpcom/components/nsStaticComponentLoader.cpp
--- a/xpcom/components/nsStaticComponentLoader.cpp
+++ b/xpcom/components/nsStaticComponentLoader.cpp
@@ -131,7 +131,7 @@ nsStaticModuleLoader::Init(nsStaticModul
 
 void
 nsStaticModuleLoader::EnumerateModules(StaticLoaderCallback cb,
-                                       nsTArray<DeferredModule> &deferred)
+                                       nsTArray<DeferredModule, GCAllocator> &deferred)
 {
     for (StaticModuleInfo *c = mFirst; c; c = c->next) {
         if (!c->module) {
@@ -175,6 +175,6 @@ nsStaticModuleLoader::GetModuleFor(const
             return rv;
     }
 
-    NS_ADDREF(*aResult = info->module);
+    *aResult = info->module;
     return NS_OK;
 }
diff --git a/xpcom/components/nsStaticComponentLoader.h b/xpcom/components/nsStaticComponentLoader.h
--- a/xpcom/components/nsStaticComponentLoader.h
+++ b/xpcom/components/nsStaticComponentLoader.h
@@ -51,7 +51,7 @@ struct DeferredModule;
 
 typedef void (*StaticLoaderCallback)(const char               *key,
                                      nsIModule*                module,
-                                     nsTArray<DeferredModule> &deferred);
+                                     nsTArray<DeferredModule, GCAllocator> &deferred);
 
 class nsStaticModuleLoader
 {
@@ -71,7 +71,7 @@ public:
     }
 
     void EnumerateModules(StaticLoaderCallback      cb,
-                          nsTArray<DeferredModule> &deferred);
+                          nsTArray<DeferredModule, GCAllocator> &deferred);
     nsresult GetModuleFor(const char *key, nsIModule* *aResult);
 
 private: