diff --git a/xpcom/components/nsCategoryManager.cpp b/xpcom/components/nsCategoryManager.cpp index 527c78719053..ccdffbf956ab 100644 --- a/xpcom/components/nsCategoryManager.cpp +++ b/xpcom/components/nsCategoryManager.cpp @@ -113,8 +113,7 @@ BaseStringEnumerator::GetNext(nsISupports** aResult) return NS_ERROR_FAILURE; } - nsSupportsDependentCString* str = - new nsSupportsDependentCString(mArray[mSimpleCurItem++]); + auto* str = new nsSupportsDependentCString(mArray[mSimpleCurItem++]); if (!str) { return NS_ERROR_OUT_OF_MEMORY; } @@ -173,7 +172,7 @@ public: EntryEnumerator* EntryEnumerator::Create(nsTHashtable& aTable) { - EntryEnumerator* enumObj = new EntryEnumerator(); + auto* enumObj = new EntryEnumerator(); if (!enumObj) { return nullptr; } @@ -337,7 +336,7 @@ CategoryEnumerator* CategoryEnumerator::Create(nsClassHashtable& aTable) { - CategoryEnumerator* enumObj = new CategoryEnumerator(); + auto* enumObj = new CategoryEnumerator(); if (!enumObj) { return nullptr; } diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index 7108b8e0ad68..f839651d5837 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -721,7 +721,7 @@ nsComponentManagerImpl::ManifestComponent(ManifestProcessingContext& aCx, *permanentCID = cid; PL_ARENA_ALLOCATE(place, &mArena, sizeof(mozilla::Module::CIDEntry)); - mozilla::Module::CIDEntry* e = new (place) mozilla::Module::CIDEntry(); + auto* e = new (place) mozilla::Module::CIDEntry(); e->cid = permanentCID; f = new nsFactoryEntry(e, km); @@ -1691,7 +1691,7 @@ nsComponentManagerImpl::EnumerateCIDs(nsISimpleEnumerator** aEnumerator) NS_IMETHODIMP nsComponentManagerImpl::EnumerateContractIDs(nsISimpleEnumerator** aEnumerator) { - nsTArray* array = new nsTArray; + auto* array = new nsTArray; for (auto iter = mContractIDs.Iter(); !iter.Done(); iter.Next()) { const nsACString& contract = iter.Key(); array->AppendElement(contract); @@ -1803,8 +1803,8 @@ nsFactoryEntry::nsFactoryEntry(const nsCID& aCID, nsIFactory* aFactory) , mModule(nullptr) , mFactory(aFactory) { - mozilla::Module::CIDEntry* e = new mozilla::Module::CIDEntry(); - nsCID* cid = new nsCID; + auto* e = new mozilla::Module::CIDEntry(); + auto* cid = new nsCID; *cid = aCID; e->cid = cid; mCIDEntry = e; diff --git a/xpcom/glue/nsEnumeratorUtils.cpp b/xpcom/glue/nsEnumeratorUtils.cpp index d1843a78ad59..4af997648ad5 100644 --- a/xpcom/glue/nsEnumeratorUtils.cpp +++ b/xpcom/glue/nsEnumeratorUtils.cpp @@ -279,8 +279,8 @@ NS_NewUnionEnumerator(nsISimpleEnumerator** aResult, } else if (!aSecondEnumerator) { *aResult = aFirstEnumerator; } else { - nsUnionEnumerator* enumer = new nsUnionEnumerator(aFirstEnumerator, - aSecondEnumerator); + auto* enumer = new nsUnionEnumerator(aFirstEnumerator, + aSecondEnumerator); if (!enumer) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/xpcom/glue/nsTArray.cpp b/xpcom/glue/nsTArray.cpp index a5b7704926d2..81a5799f18af 100644 --- a/xpcom/glue/nsTArray.cpp +++ b/xpcom/glue/nsTArray.cpp @@ -26,7 +26,7 @@ InvalidArrayIndex_CRASH(size_t aIndex, size_t aLength) // Leak the buffer on the heap to make sure that it lives long enough, as // MOZ_CRASH_ANNOTATE expects the pointer passed to it to live to the end of // the program. - char* buffer = new char[CAPACITY]; + auto* buffer = new char[CAPACITY]; snprintf(buffer, CAPACITY, "ElementAt(aIndex = %llu, aLength = %llu)", (long long unsigned) aIndex, diff --git a/xpcom/glue/standalone/nsXPCOMGlue.cpp b/xpcom/glue/standalone/nsXPCOMGlue.cpp index b657d7050e88..58dc856acde1 100644 --- a/xpcom/glue/standalone/nsXPCOMGlue.cpp +++ b/xpcom/glue/standalone/nsXPCOMGlue.cpp @@ -134,7 +134,7 @@ static DependentLib* sTop; static void AppendDependentLib(LibHandleType aLibHandle) { - DependentLib* d = new DependentLib; + auto* d = new DependentLib; if (!d) { return; } diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index 494752df7043..b509bd96228a 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -827,7 +827,7 @@ nsLocalFile::CopyToNative(nsIFile* aNewParent, const nsACString& aNewName) #endif // actually create the file. - nsLocalFile* newFile = new nsLocalFile(); + auto* newFile = new nsLocalFile(); nsCOMPtr fileRef(newFile); // release on exit rv = newFile->InitWithNativePath(newPathName); @@ -1040,7 +1040,7 @@ nsLocalFile::Remove(bool aRecursive) } if (aRecursive) { - nsDirEnumeratorUnix* dir = new nsDirEnumeratorUnix(); + auto* dir = new nsDirEnumeratorUnix(); nsCOMPtr dirRef(dir); // release on exit diff --git a/xpcom/tests/gtest/TestCOMPtr.cpp b/xpcom/tests/gtest/TestCOMPtr.cpp index e17331c65e91..c74436fdf896 100644 --- a/xpcom/tests/gtest/TestCOMPtr.cpp +++ b/xpcom/tests/gtest/TestCOMPtr.cpp @@ -102,7 +102,7 @@ nsresult CreateIFoo( void** result ) // a typical factory function (that calls AddRef) { - IFoo* foop = new IFoo; + auto* foop = new IFoo; foop->AddRef(); *result = foop; @@ -190,7 +190,7 @@ nsresult CreateIBar( void** result ) // a typical factory function (that calls AddRef) { - IBar* barp = new IBar; + auto* barp = new IBar; barp->AddRef(); *result = barp; @@ -332,10 +332,10 @@ void Comparison() void DontAddRef() { { - IFoo* raw_foo1p = new IFoo; + auto* raw_foo1p = new IFoo; raw_foo1p->AddRef(); - IFoo* raw_foo2p = new IFoo; + auto* raw_foo2p = new IFoo; raw_foo2p->AddRef(); nsCOMPtr foo1p( dont_AddRef(raw_foo1p) ); diff --git a/xpcom/tests/gtest/TestHashtables.cpp b/xpcom/tests/gtest/TestHashtables.cpp index 13bd15128cd2..9687b1b6e05c 100644 --- a/xpcom/tests/gtest/TestHashtables.cpp +++ b/xpcom/tests/gtest/TestHashtables.cpp @@ -246,7 +246,7 @@ nsresult CreateIFoo( IFoo** result ) // a typical factory function (that calls AddRef) { - IFoo* foop = new IFoo(); + auto* foop = new IFoo(); foop->AddRef(); *result = foop; @@ -318,7 +318,7 @@ TEST(Hashtables, ClassHashtable) nsClassHashtable EntToUniClass(ENTITY_COUNT); for (auto& entity : gEntities) { - TestUniChar* temp = new TestUniChar(entity.mUnicode); + auto* temp = new TestUniChar(entity.mUnicode); EntToUniClass.Put(nsDependentCString(entity.mStr), temp); } diff --git a/xpcom/tests/gtest/TestNsRefPtr.cpp b/xpcom/tests/gtest/TestNsRefPtr.cpp index a085c29660f7..c340a7ed2702 100644 --- a/xpcom/tests/gtest/TestNsRefPtr.cpp +++ b/xpcom/tests/gtest/TestNsRefPtr.cpp @@ -128,7 +128,7 @@ nsresult CreateFoo( void** result ) // a typical factory function (that calls AddRef) { - Foo* foop = new Foo; + auto* foop = new Foo; foop->AddRef(); *result = foop; @@ -331,10 +331,10 @@ TEST(nsRefPtr, AddRefHelpers) Foo::total_addrefs_ = 0; { - Foo* raw_foo1p = new Foo; + auto* raw_foo1p = new Foo; raw_foo1p->AddRef(); - Foo* raw_foo2p = new Foo; + auto* raw_foo2p = new Foo; raw_foo2p->AddRef(); ASSERT_EQ(Foo::total_addrefs_, 2);