From 2187798a40a791c85f09a24ba44d8c532d227ccb Mon Sep 17 00:00:00 2001 From: Benjamin Smedberg Date: Fri, 18 May 2012 13:30:49 -0400 Subject: [PATCH] Bug 734847 part 2 - treewide changes resulting from the default-infallibility of hashtables; either remove useless result checks, or use the fallible version of APIs, depending on context, r=jlebar --HG-- extra : rebase_source : 844b008c5167e6ca39a7ba9eeec8b30672938704 --- accessible/src/base/nsAccDocManager.cpp | 3 +- accessible/src/base/nsDocAccessible.cpp | 17 +--- accessible/src/xul/nsXULTreeAccessible.cpp | 9 +-- .../src/xul/nsXULTreeGridAccessible.cpp | 9 +-- chrome/src/nsChromeRegistry.cpp | 3 +- chrome/src/nsChromeRegistryChrome.cpp | 5 +- chrome/src/nsChromeRegistryChrome.h | 2 +- chrome/src/nsChromeRegistryContent.cpp | 4 +- content/base/src/nsContentUtils.cpp | 38 ++------- content/base/src/nsCrossSiteListenerProxy.cpp | 12 +-- content/base/src/nsDOMAttributeMap.cpp | 11 ++- content/base/src/nsDocument.cpp | 44 ++++------- content/base/src/nsNameSpaceManager.cpp | 10 +-- .../events/src/nsDOMDataContainerEvent.cpp | 3 +- .../html/content/src/nsHTMLFormElement.cpp | 26 ++----- content/media/ogg/nsOggCodecState.cpp | 7 +- content/media/ogg/nsOggReader.cpp | 9 +-- .../svg/content/src/nsSVGAttrTearoffTable.h | 6 +- content/xbl/src/nsBindingManager.cpp | 30 ++++---- content/xbl/src/nsXBLBinding.cpp | 12 +-- content/xslt/src/xslt/txEXSLTFunctions.cpp | 8 +- content/xslt/src/xslt/txExecutionState.cpp | 3 +- content/xslt/src/xslt/txKeyFunctionCall.cpp | 11 +-- content/xul/document/src/nsXULDocument.cpp | 16 ++-- .../xul/document/src/nsXULPrototypeCache.cpp | 10 +-- .../xul/templates/src/nsXULContentBuilder.cpp | 5 +- .../templates/src/nsXULTemplateBuilder.cpp | 20 ++--- .../src/nsXULTemplateQueryProcessorRDF.cpp | 28 +++---- .../src/nsXULTemplateQueryProcessorXML.cpp | 8 +- .../xul/templates/src/nsXULTreeBuilder.cpp | 5 +- docshell/base/nsDocShell.cpp | 9 +-- dom/base/nsGlobalWindow.cpp | 13 +--- dom/indexedDB/DatabaseInfo.cpp | 29 ++----- dom/indexedDB/FileManager.cpp | 12 +-- dom/indexedDB/IDBTransaction.cpp | 16 +--- dom/indexedDB/IndexedDatabaseManager.cpp | 35 +++------ dom/indexedDB/TransactionThreadPool.cpp | 10 +-- dom/ipc/CrashReporterParent.cpp | 3 +- dom/ipc/TabChild.cpp | 4 +- dom/plugins/base/nsPluginInstanceOwner.cpp | 4 +- dom/plugins/ipc/PluginInstanceParent.cpp | 6 +- dom/plugins/ipc/PluginModuleChild.cpp | 17 +--- dom/plugins/ipc/PluginModuleParent.cpp | 4 +- dom/src/storage/nsDOMStorage.cpp | 7 +- dom/src/storage/nsDOMStorageMemoryDB.cpp | 8 +- dom/workers/RuntimeService.cpp | 21 +---- .../commandhandler/src/nsCommandManager.cpp | 5 +- extensions/cookie/nsPermissionManager.cpp | 4 +- .../spellcheck/hunspell/src/mozHunspell.cpp | 4 +- .../spellcheck/src/mozPersonalDictionary.cpp | 4 +- image/src/imgLoader.cpp | 9 +-- js/xpconnect/loader/mozJSComponentLoader.cpp | 18 ++--- js/xpconnect/src/dombindings.cpp | 6 +- js/xpconnect/src/xpcprivate.h | 25 +++--- layout/base/RestyleTracker.h | 4 +- layout/base/nsCSSFrameConstructor.cpp | 5 +- layout/base/nsCounterManager.cpp | 5 +- layout/base/nsLayoutHistoryState.cpp | 6 +- layout/base/nsLayoutUtils.cpp | 4 - layout/base/nsPresArena.cpp | 5 -- layout/base/nsPresContext.cpp | 6 +- layout/base/nsPresShell.cpp | 4 +- layout/generic/TextOverflow.cpp | 4 +- layout/inspector/src/nsFontFaceList.cpp | 4 +- layout/style/Loader.cpp | 26 +++---- layout/tables/nsTableFrame.cpp | 5 +- layout/xul/base/src/nsBoxObject.cpp | 8 +- .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 4 +- modules/libjar/zipwriter/src/nsZipWriter.cpp | 19 ++--- modules/libpref/src/Preferences.cpp | 4 +- modules/libpref/src/nsPrefBranch.cpp | 7 +- netwerk/base/src/nsProtocolProxyService.cpp | 3 +- netwerk/cache/nsDiskCacheDeviceSQL.cpp | 9 +-- netwerk/dns/nsEffectiveTLDService.cpp | 3 +- netwerk/protocol/res/nsResProtocolHandler.cpp | 9 ++- parser/html/nsHtml5AtomTable.h | 7 +- parser/html/nsHtml5StringParser.cpp | 2 +- rdf/base/src/nsRDFXMLSerializer.cpp | 9 ++- .../src/nsStrictTransportSecurityService.cpp | 9 +-- .../manager/ssl/src/nsCertOverrideService.cpp | 3 +- security/manager/ssl/src/nsCertTree.cpp | 3 +- .../manager/ssl/src/nsClientAuthRemember.cpp | 3 +- storage/public/StatementCache.h | 8 +- storage/src/mozStorageBindingParams.cpp | 3 +- storage/src/mozStorageConnection.cpp | 6 +- storage/src/mozStorageRow.cpp | 2 +- toolkit/components/places/History.cpp | 3 +- .../components/places/nsFaviconService.cpp | 11 +-- toolkit/components/places/nsNavBookmarks.cpp | 3 +- toolkit/components/places/nsNavHistory.cpp | 12 +-- .../components/places/nsNavHistoryResult.cpp | 3 +- .../nsUrlClassifierDBService.cpp | 4 +- toolkit/crashreporter/nsExceptionHandler.cpp | 6 +- widget/android/nsAppShell.cpp | 3 +- xpcom/components/nsCategoryManager.cpp | 6 +- xpcom/components/nsNativeComponentLoader.cpp | 4 +- xpcom/ds/nsAtomTable.cpp | 3 +- xpcom/ds/nsCheapSets.h | 12 +-- xpcom/ds/nsHashPropertyBag.cpp | 8 +- xpcom/ds/nsProperties.cpp | 4 +- xpcom/ds/nsProperties.h | 1 + xpcom/glue/nsBaseHashtable.h | 10 +-- xpcom/glue/nsCategoryCache.cpp | 6 +- xpcom/glue/nsINIParser.cpp | 3 +- xpcom/tests/TestHashtables.cpp | 77 ++++--------------- xpcom/threads/nsEnvironment.cpp | 8 +- xpcom/threads/nsThreadManager.cpp | 3 +- 107 files changed, 322 insertions(+), 714 deletions(-) diff --git a/accessible/src/base/nsAccDocManager.cpp b/accessible/src/base/nsAccDocManager.cpp index 4e1388ff6b5..0af2cf396c9 100644 --- a/accessible/src/base/nsAccDocManager.cpp +++ b/accessible/src/base/nsAccDocManager.cpp @@ -395,8 +395,7 @@ nsAccDocManager::CreateDocOrRootAccessible(nsIDocument* aDocument) new nsDocAccessibleWrap(aDocument, rootElm, presShell); // Cache the document accessible into document cache. - if (!docAcc || !mDocAccessibleCache.Put(aDocument, docAcc)) - return nsnull; + mDocAccessibleCache.Put(aDocument, docAcc); // Initialize the document accessible. if (!docAcc->Init()) { diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index a0319d88957..71540299410 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -1369,17 +1369,11 @@ nsDocAccessible::BindToDocument(nsAccessible* aAccessible, return false; // Put into DOM node cache. - if (aAccessible->IsPrimaryForNode() && - !mNodeToAccessibleMap.Put(aAccessible->GetNode(), aAccessible)) - return false; + if (aAccessible->IsPrimaryForNode()) + mNodeToAccessibleMap.Put(aAccessible->GetNode(), aAccessible); // Put into unique ID cache. - if (!mAccessibleCache.Put(aAccessible->UniqueID(), aAccessible)) { - if (aAccessible->IsPrimaryForNode()) - mNodeToAccessibleMap.Remove(aAccessible->GetNode()); - - return false; - } + mAccessibleCache.Put(aAccessible->UniqueID(), aAccessible); // Initialize the accessible. if (!aAccessible->Init()) { @@ -1621,10 +1615,7 @@ nsDocAccessible::AddDependentIDsFor(nsAccessible* aRelProvider, if (!providers) { providers = new AttrRelProviderArray(); if (providers) { - if (!mDependentIDsHash.Put(id, providers)) { - delete providers; - providers = nsnull; - } + mDependentIDsHash.Put(id, providers); } } diff --git a/accessible/src/xul/nsXULTreeAccessible.cpp b/accessible/src/xul/nsXULTreeAccessible.cpp index e5ab37135bd..4288abd105c 100644 --- a/accessible/src/xul/nsXULTreeAccessible.cpp +++ b/accessible/src/xul/nsXULTreeAccessible.cpp @@ -574,12 +574,11 @@ nsXULTreeAccessible::GetTreeItemAccessible(PRInt32 aRow) nsRefPtr treeItem = CreateTreeItemAccessible(aRow); if (treeItem) { - if (mAccessibleCache.Put(key, treeItem)) { - if (Document()->BindToDocument(treeItem, nsnull)) - return treeItem; + mAccessibleCache.Put(key, treeItem); + if (Document()->BindToDocument(treeItem, nsnull)) + return treeItem; - mAccessibleCache.Remove(key); - } + mAccessibleCache.Remove(key); } return nsnull; diff --git a/accessible/src/xul/nsXULTreeGridAccessible.cpp b/accessible/src/xul/nsXULTreeGridAccessible.cpp index 4e9bbdbd1e2..98dc32aeba3 100644 --- a/accessible/src/xul/nsXULTreeGridAccessible.cpp +++ b/accessible/src/xul/nsXULTreeGridAccessible.cpp @@ -732,12 +732,11 @@ nsXULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn) new nsXULTreeGridCellAccessibleWrap(mContent, mDoc, this, mTree, mTreeView, mRow, aColumn); if (cell) { - if (mAccessibleCache.Put(key, cell)) { - if (Document()->BindToDocument(cell, nsnull)) - return cell; + mAccessibleCache.Put(key, cell); + if (Document()->BindToDocument(cell, nsnull)) + return cell; - mAccessibleCache.Remove(key); - } + mAccessibleCache.Remove(key); } return nsnull; diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp index c3f916c3071..9614ddbf958 100644 --- a/chrome/src/nsChromeRegistry.cpp +++ b/chrome/src/nsChromeRegistry.cpp @@ -175,8 +175,7 @@ nsChromeRegistry::GetService() nsresult nsChromeRegistry::Init() { - if (!mOverrideTable.Init()) - return NS_ERROR_FAILURE; + mOverrideTable.Init(); // This initialization process is fairly complicated and may cause reentrant // getservice calls to resolve chrome URIs (especially locale files). We diff --git a/chrome/src/nsChromeRegistryChrome.cpp b/chrome/src/nsChromeRegistryChrome.cpp index ed399512f92..328e89155ec 100644 --- a/chrome/src/nsChromeRegistryChrome.cpp +++ b/chrome/src/nsChromeRegistryChrome.cpp @@ -155,9 +155,8 @@ nsChromeRegistryChrome::Init() if (NS_FAILED(rv)) return rv; - if (!mOverlayHash.Init() || - !mStyleHash.Init()) - return NS_ERROR_FAILURE; + mOverlayHash.Init(); + mStyleHash.Init(); mSelectedLocale = NS_LITERAL_CSTRING("en-US"); mSelectedSkin = NS_LITERAL_CSTRING("classic/1.0"); diff --git a/chrome/src/nsChromeRegistryChrome.h b/chrome/src/nsChromeRegistryChrome.h index 19fdf7e33ef..d925ed36062 100644 --- a/chrome/src/nsChromeRegistryChrome.h +++ b/chrome/src/nsChromeRegistryChrome.h @@ -171,7 +171,7 @@ class nsChromeRegistryChrome : public nsChromeRegistry OverlayListHash() { } ~OverlayListHash() { } - bool Init() { return mTable.Init(); } + void Init() { mTable.Init(); } void Add(nsIURI* aBase, nsIURI* aOverlay); void Clear() { mTable.Clear(); } const nsCOMArray* GetArray(nsIURI* aBase); diff --git a/chrome/src/nsChromeRegistryContent.cpp b/chrome/src/nsChromeRegistryContent.cpp index 39b106131a0..b14bd21e7a3 100644 --- a/chrome/src/nsChromeRegistryContent.cpp +++ b/chrome/src/nsChromeRegistryContent.cpp @@ -117,9 +117,7 @@ nsChromeRegistryContent::RegisterPackage(const ChromePackage& aPackage) entry->localeBaseURI = locale; entry->skinBaseURI = skin; - nsresult rv = mPackagesHash.Put(aPackage.package, entry); - if (NS_FAILED(rv)) - return; + mPackagesHash.Put(aPackage.package, entry); } void diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index a63cae424ee..ec7d57033a9 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -548,30 +548,14 @@ nsContentUtils::InitializeEventTable() { sAtomEventTable = new nsDataHashtable; sStringEventTable = new nsDataHashtable; sUserDefinedEvents = new nsCOMArray(64); - - if (!sAtomEventTable || !sStringEventTable || !sUserDefinedEvents || - !sAtomEventTable->Init(int(ArrayLength(eventArray) / 0.75) + 1) || - !sStringEventTable->Init(int(ArrayLength(eventArray) / 0.75) + 1)) { - delete sAtomEventTable; - sAtomEventTable = nsnull; - delete sStringEventTable; - sStringEventTable = nsnull; - delete sUserDefinedEvents; - sUserDefinedEvents = nsnull; - return false; - } + sAtomEventTable->Init(int(ArrayLength(eventArray) / 0.75) + 1); + sStringEventTable->Init(int(ArrayLength(eventArray) / 0.75) + 1); // Subtract one from the length because of the trailing null for (PRUint32 i = 0; i < ArrayLength(eventArray) - 1; ++i) { - if (!sAtomEventTable->Put(eventArray[i].mAtom, eventArray[i]) || - !sStringEventTable->Put(Substring(nsDependentAtomString(eventArray[i].mAtom), 2), - eventArray[i])) { - delete sAtomEventTable; - sAtomEventTable = nsnull; - delete sStringEventTable; - sStringEventTable = nsnull; - return false; - } + sAtomEventTable->Put(eventArray[i].mAtom, eventArray[i]); + sStringEventTable->Put(Substring(nsDependentAtomString(eventArray[i].mAtom), 2), + eventArray[i]); } return true; @@ -594,15 +578,9 @@ nsContentUtils::InitializeTouchEventTable() }; // Subtract one from the length because of the trailing null for (PRUint32 i = 0; i < ArrayLength(touchEventArray) - 1; ++i) { - if (!sAtomEventTable->Put(touchEventArray[i].mAtom, touchEventArray[i]) || - !sStringEventTable->Put(Substring(nsDependentAtomString(touchEventArray[i].mAtom), 2), - touchEventArray[i])) { - delete sAtomEventTable; - sAtomEventTable = nsnull; - delete sStringEventTable; - sStringEventTable = nsnull; - return; - } + sAtomEventTable->Put(touchEventArray[i].mAtom, touchEventArray[i]); + sStringEventTable->Put(Substring(nsDependentAtomString(touchEventArray[i].mAtom), 2), + touchEventArray[i]); } } } diff --git a/content/base/src/nsCrossSiteListenerProxy.cpp b/content/base/src/nsCrossSiteListenerProxy.cpp index 8dcc52375cc..495f4878400 100644 --- a/content/base/src/nsCrossSiteListenerProxy.cpp +++ b/content/base/src/nsCrossSiteListenerProxy.cpp @@ -113,7 +113,8 @@ public: bool Initialize() { - return mTable.Init(); + mTable.Init(); + return true; } CacheEntry* GetEntry(nsIURI* aURI, nsIPrincipal* aPrincipal, @@ -260,14 +261,7 @@ nsPreflightCache::GetEntry(nsIURI* aURI, } } - if (!mTable.Put(key, entry)) { - // Failed, clean up the new entry. - delete entry; - - NS_WARNING("Failed to add entry to the CORS preflight cache!"); - return nsnull; - } - + mTable.Put(key, entry); PR_INSERT_LINK(entry, &mList); return entry; diff --git a/content/base/src/nsDOMAttributeMap.cpp b/content/base/src/nsDOMAttributeMap.cpp index f0617a0e5fa..a6d307e2b4a 100644 --- a/content/base/src/nsDOMAttributeMap.cpp +++ b/content/base/src/nsDOMAttributeMap.cpp @@ -65,7 +65,8 @@ nsDOMAttributeMap::nsDOMAttributeMap(Element* aContent) bool nsDOMAttributeMap::Init() { - return mAttributeCache.Init(); + mAttributeCache.Init(); + return true; } /** @@ -212,9 +213,8 @@ nsDOMAttributeMap::GetAttribute(nsINodeInfo* aNodeInfo, bool aNsAware) nsCOMPtr ni = aNodeInfo; nsRefPtr newAttr = new nsDOMAttribute(this, ni.forget(), EmptyString(), aNsAware); - if (newAttr && mAttributeCache.Put(attr, newAttr)) { - node = newAttr; - } + mAttributeCache.Put(attr, newAttr); + node = newAttr; } return node; @@ -352,8 +352,7 @@ nsDOMAttributeMap::SetNamedItemInternal(nsIDOMNode *aNode, // Add the new attribute to the attribute map before updating // its value in the element. @see bug 364413. nsAttrKey attrkey(ni->NamespaceID(), ni->NameAtom()); - rv = mAttributeCache.Put(attrkey, attribute); - NS_ENSURE_SUCCESS(rv, rv); + mAttributeCache.Put(attrkey, attribute); iAttribute->SetMap(this); rv = mContent->SetAttr(ni->NamespaceID(), ni->NameAtom(), diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 25e14a8428d..eb5ee97f165 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -726,9 +726,7 @@ nsExternalResourceMap::RequestResource(nsIURI* aURI, load = new PendingLoad(aDisplayDocument); - if (!mPendingLoads.Put(clone, load)) { - return nsnull; - } + mPendingLoads.Put(clone, load); if (NS_FAILED(load->StartLoad(clone, aRequestingNode))) { // Make sure we don't thrash things by trying this load again, since @@ -920,22 +918,14 @@ nsExternalResourceMap::AddExternalResource(nsIURI* aURI, } ExternalResource* newResource = new ExternalResource(); - if (newResource && !mMap.Put(aURI, newResource)) { - delete newResource; - newResource = nsnull; - if (NS_SUCCEEDED(rv)) { - rv = NS_ERROR_OUT_OF_MEMORY; - } - } + mMap.Put(aURI, newResource); - if (newResource) { - newResource->mDocument = doc; - newResource->mViewer = aViewer; - newResource->mLoadGroup = aLoadGroup; - if (doc) { - TransferZoomLevels(aDisplayDocument, doc); - TransferShowingState(aDisplayDocument, doc); - } + newResource->mDocument = doc; + newResource->mViewer = aViewer; + newResource->mLoadGroup = aLoadGroup; + if (doc) { + TransferZoomLevels(aDisplayDocument, doc); + TransferShowingState(aDisplayDocument, doc); } const nsTArray< nsCOMPtr > & obs = load->Observers(); @@ -2000,7 +1990,7 @@ nsDocument::Init() } mIdentifierMap.Init(); - (void)mStyledLinks.Init(); + mStyledLinks.Init(); mRadioGroups.Init(); // Force initialization. @@ -2041,10 +2031,8 @@ nsDocument::Init() mScriptLoader = new nsScriptLoader(this); NS_ENSURE_TRUE(mScriptLoader, NS_ERROR_OUT_OF_MEMORY); - if (!mImageTracker.Init() || - !mPlugins.Init()) { - return NS_ERROR_OUT_OF_MEMORY; - } + mImageTracker.Init(); + mPlugins.Init(); return NS_OK; } @@ -5355,9 +5343,7 @@ nsDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult) if (!mBoxObjectTable) { mBoxObjectTable = new nsInterfaceHashtable, nsPIBoxObject>; - if (mBoxObjectTable && !mBoxObjectTable->Init(12)) { - mBoxObjectTable = nsnull; - } + mBoxObjectTable->Init(12); } else { // Want to use Get(content, aResult); but it's the wrong type *aResult = mBoxObjectTable->GetWeak(content); @@ -6502,7 +6488,7 @@ nsDocument::GetRadioGroup(const nsAString& aName) } nsAutoPtr newRadioGroup(new nsRadioGroupStruct()); - NS_ENSURE_TRUE(mRadioGroups.Put(tmKey, newRadioGroup), nsnull); + mRadioGroups.Put(tmKey, newRadioGroup); return newRadioGroup.forget(); } @@ -8285,9 +8271,7 @@ nsDocument::AddImage(imgIRequest* aImage) mImageTracker.Get(aImage, &oldCount); // Put the image in the hashtable, with the proper count. - bool success = mImageTracker.Put(aImage, oldCount + 1); - if (!success) - return NS_ERROR_OUT_OF_MEMORY; + mImageTracker.Put(aImage, oldCount + 1); nsresult rv = NS_OK; diff --git a/content/base/src/nsNameSpaceManager.cpp b/content/base/src/nsNameSpaceManager.cpp index de71353a4ce..054376f898c 100644 --- a/content/base/src/nsNameSpaceManager.cpp +++ b/content/base/src/nsNameSpaceManager.cpp @@ -140,9 +140,9 @@ NS_IMPL_ISUPPORTS1(NameSpaceManagerImpl, nsINameSpaceManager) nsresult NameSpaceManagerImpl::Init() { - nsresult rv = mURIToIDTable.Init(32); - NS_ENSURE_SUCCESS(rv, rv); + mURIToIDTable.Init(32); + nsresult rv; #define REGISTER_NAMESPACE(uri, id) \ rv = AddNameSpace(NS_LITERAL_STRING(uri), id); \ NS_ENSURE_SUCCESS(rv, rv) @@ -288,11 +288,7 @@ nsresult NameSpaceManagerImpl::AddNameSpace(const nsAString& aURI, return NS_ERROR_OUT_OF_MEMORY; } - if (!mURIToIDTable.Put(uri, aNameSpaceID)) { - mURIArray.RemoveElementAt(aNameSpaceID - 1); - - return NS_ERROR_OUT_OF_MEMORY; - } + mURIToIDTable.Put(uri, aNameSpaceID); return NS_OK; } diff --git a/content/events/src/nsDOMDataContainerEvent.cpp b/content/events/src/nsDOMDataContainerEvent.cpp index 03ef81c5f80..7fb80cf3874 100644 --- a/content/events/src/nsDOMDataContainerEvent.cpp +++ b/content/events/src/nsDOMDataContainerEvent.cpp @@ -89,7 +89,8 @@ nsDOMDataContainerEvent::SetData(const nsAString& aKey, nsIVariant *aData) // Make sure this event isn't already being dispatched. NS_ENSURE_STATE(!(NS_IS_EVENT_IN_DISPATCH(mEvent))); NS_ENSURE_STATE(mData.IsInitialized()); - return mData.Put(aKey, aData) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; + mData.Put(aKey, aData); + return NS_OK; } nsresult diff --git a/content/html/content/src/nsHTMLFormElement.cpp b/content/html/content/src/nsHTMLFormElement.cpp index c2e5c0beee3..755bff8bbf1 100644 --- a/content/html/content/src/nsHTMLFormElement.cpp +++ b/content/html/content/src/nsHTMLFormElement.cpp @@ -289,12 +289,9 @@ nsHTMLFormElement::Init() return rv; } - NS_ENSURE_TRUE(mSelectedRadioButtons.Init(4), - NS_ERROR_OUT_OF_MEMORY); - NS_ENSURE_TRUE(mRequiredRadioButtonCounts.Init(4), - NS_ERROR_OUT_OF_MEMORY); - NS_ENSURE_TRUE(mValueMissingRadioGroups.Init(4), - NS_ERROR_OUT_OF_MEMORY); + mSelectedRadioButtons.Init(4); + mRequiredRadioButtonCounts.Init(4); + mValueMissingRadioGroups.Init(4); return NS_OK; } @@ -1894,8 +1891,7 @@ NS_IMETHODIMP nsHTMLFormElement::SetCurrentRadioButton(const nsAString& aName, nsIDOMHTMLInputElement* aRadio) { - NS_ENSURE_TRUE(mSelectedRadioButtons.Put(aName, aRadio), - NS_ERROR_OUT_OF_MEMORY); + mSelectedRadioButtons.Put(aName, aRadio); return NS_OK; } @@ -2144,10 +2140,7 @@ nsFormControlList::~nsFormControlList() nsresult nsFormControlList::Init() { - NS_ENSURE_TRUE( - mNameLookupTable.Init(NS_FORM_CONTROL_LIST_HASHTABLE_SIZE), - NS_ERROR_OUT_OF_MEMORY); - + mNameLookupTable.Init(NS_FORM_CONTROL_LIST_HASHTABLE_SIZE); return NS_OK; } @@ -2310,9 +2303,7 @@ nsFormControlList::AddElementToTable(nsGenericHTMLFormElement* aChild, if (!supports) { // No entry found, add the form control - NS_ENSURE_TRUE(mNameLookupTable.Put(aName, - NS_ISUPPORTS_CAST(nsIContent*, aChild)), - NS_ERROR_FAILURE); + mNameLookupTable.Put(aName, NS_ISUPPORTS_CAST(nsIContent*, aChild)); } else { // Found something in the hash, check its type nsCOMPtr content = do_QueryInterface(supports); @@ -2345,8 +2336,7 @@ nsFormControlList::AddElementToTable(nsGenericHTMLFormElement* aChild, nsCOMPtr listSupports = do_QueryObject(list); // Replace the element with the list. - NS_ENSURE_TRUE(mNameLookupTable.Put(aName, listSupports), - NS_ERROR_FAILURE); + mNameLookupTable.Put(aName, listSupports); } else { // There's already a list in the hash, add the child to the list nsCOMPtr nodeList = do_QueryInterface(supports); @@ -2455,7 +2445,7 @@ nsFormControlList::RemoveElementFromTable(nsGenericHTMLFormElement* aChild, // single element. nsIContent* node = list->GetNodeAt(0); if (node) { - NS_ENSURE_TRUE(mNameLookupTable.Put(aName, node),NS_ERROR_FAILURE); + mNameLookupTable.Put(aName, node); } } diff --git a/content/media/ogg/nsOggCodecState.cpp b/content/media/ogg/nsOggCodecState.cpp index b9eb3cd10c3..f4d664dcf1f 100644 --- a/content/media/ogg/nsOggCodecState.cpp +++ b/content/media/ogg/nsOggCodecState.cpp @@ -1263,12 +1263,7 @@ bool nsSkeletonState::DecodeHeader(ogg_packet* aPacket) LOG(PR_LOG_DEBUG, ("Skeleton segment length: %lld", mLength)); // Initialize the serianlno-to-index map. - bool init = mIndex.Init(); - if (!init) { - NS_WARNING("Failed to initialize Ogg skeleton serialno-to-index map"); - mActive = false; - return mDoneReadingHeaders = true; - } + mIndex.Init(); mActive = true; } else if (IsSkeletonIndex(aPacket) && mVersion >= SKELETON_VERSION(4,0)) { if (!DecodeIndex(aPacket)) { diff --git a/content/media/ogg/nsOggReader.cpp b/content/media/ogg/nsOggReader.cpp index a85893c7efc..c4414bae6d2 100644 --- a/content/media/ogg/nsOggReader.cpp +++ b/content/media/ogg/nsOggReader.cpp @@ -126,11 +126,7 @@ nsOggReader::~nsOggReader() } nsresult nsOggReader::Init(nsBuiltinDecoderReader* aCloneDonor) { - bool init = mCodecStates.Init(); - NS_ASSERTION(init, "Failed to initialize mCodecStates"); - if (!init) { - return NS_ERROR_FAILURE; - } + mCodecStates.Init(); int ret = ogg_sync_init(&mOggState); NS_ENSURE_TRUE(ret == 0, NS_ERROR_FAILURE); return NS_OK; @@ -205,8 +201,7 @@ nsresult nsOggReader::ReadMetadata(nsVideoInfo* aInfo) // an nsOggCodecState to demux it, and map that to the nsOggCodecState // in mCodecStates. codecState = nsOggCodecState::Create(&page); - DebugOnly r = mCodecStates.Put(serial, codecState); - NS_ASSERTION(r, "Failed to insert into mCodecStates"); + mCodecStates.Put(serial, codecState); bitstreams.AppendElement(codecState); mKnownStreams.AppendElement(serial); if (codecState && diff --git a/content/svg/content/src/nsSVGAttrTearoffTable.h b/content/svg/content/src/nsSVGAttrTearoffTable.h index 1ae54266f12..bf81841c41c 100644 --- a/content/svg/content/src/nsSVGAttrTearoffTable.h +++ b/content/svg/content/src/nsSVGAttrTearoffTable.h @@ -104,11 +104,7 @@ nsSVGAttrTearoffTable::AddTearoff(SimpleType* aSimple, return; } -#ifdef DEBUG - bool result = -#endif - mTable.Put(aSimple, aTearoff); - NS_ABORT_IF_FALSE(result, "Out of memory."); + mTable.Put(aSimple, aTearoff); } template diff --git a/content/xbl/src/nsBindingManager.cpp b/content/xbl/src/nsBindingManager.cpp index 828228775da..94299633a6f 100644 --- a/content/xbl/src/nsBindingManager.cpp +++ b/content/xbl/src/nsBindingManager.cpp @@ -554,8 +554,7 @@ nsresult nsBindingManager::SetBinding(nsIContent* aContent, nsXBLBinding* aBinding) { if (!mBindingTable.IsInitialized()) { - if (!mBindingTable.Init()) - return NS_ERROR_OUT_OF_MEMORY; + mBindingTable.Init(); } // After this point, aBinding will be the most-derived binding for aContent. @@ -584,11 +583,9 @@ nsBindingManager::SetBinding(nsIContent* aContent, nsXBLBinding* aBinding) } } - bool result = true; - if (aBinding) { aContent->SetFlags(NODE_MAY_BE_IN_BINDING_MNGR); - result = mBindingTable.Put(aContent, aBinding); + mBindingTable.Put(aContent, aBinding); } else { mBindingTable.Remove(aContent); @@ -603,7 +600,7 @@ nsBindingManager::SetBinding(nsIContent* aContent, nsXBLBinding* aBinding) } } - return result ? NS_OK : NS_ERROR_FAILURE; + return NS_OK; } nsIContent* @@ -1101,12 +1098,11 @@ nsBindingManager::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo) { NS_PRECONDITION(aDocumentInfo, "Must have a non-null documentinfo!"); - NS_ENSURE_TRUE(mDocumentTable.IsInitialized() || mDocumentTable.Init(16), - NS_ERROR_OUT_OF_MEMORY); + if (!mDocumentTable.IsInitialized()) + mDocumentTable.Init(16); - NS_ENSURE_TRUE(mDocumentTable.Put(aDocumentInfo->DocumentURI(), - aDocumentInfo), - NS_ERROR_OUT_OF_MEMORY); + mDocumentTable.Put(aDocumentInfo->DocumentURI(), + aDocumentInfo); return NS_OK; } @@ -1133,11 +1129,10 @@ nsBindingManager::PutLoadingDocListener(nsIURI* aURL, nsIStreamListener* aListen { NS_PRECONDITION(aListener, "Must have a non-null listener!"); - NS_ENSURE_TRUE(mLoadingDocTable.IsInitialized() || mLoadingDocTable.Init(16), - NS_ERROR_OUT_OF_MEMORY); + if (!mLoadingDocTable.IsInitialized()) + mLoadingDocTable.Init(16); - NS_ENSURE_TRUE(mLoadingDocTable.Put(aURL, aListener), - NS_ERROR_OUT_OF_MEMORY); + mLoadingDocTable.Put(aURL, aListener); return NS_OK; } @@ -1355,8 +1350,9 @@ EnumRuleProcessors(nsISupports *aKey, nsXBLBinding *aBinding, void* aClosure) nsIStyleRuleProcessor *ruleProc = binding->PrototypeBinding()->GetRuleProcessor(); if (ruleProc) { - if (!set->IsInitialized() && !set->Init(16)) - return PL_DHASH_STOP; + if (!set->IsInitialized()) { + set->Init(16); + } set->PutEntry(ruleProc); } } diff --git a/content/xbl/src/nsXBLBinding.cpp b/content/xbl/src/nsXBLBinding.cpp index d3d69bfe185..c0e1e93cde0 100644 --- a/content/xbl/src/nsXBLBinding.cpp +++ b/content/xbl/src/nsXBLBinding.cpp @@ -1438,22 +1438,14 @@ nsXBLBinding::GetInsertionPointsFor(nsIContent* aParent, if (!mInsertionPointTable) { mInsertionPointTable = new nsClassHashtable; - if (!mInsertionPointTable || !mInsertionPointTable->Init(4)) { - delete mInsertionPointTable; - mInsertionPointTable = nsnull; - return NS_ERROR_OUT_OF_MEMORY; - } + mInsertionPointTable->Init(4); } mInsertionPointTable->Get(aParent, aResult); if (!*aResult) { *aResult = new nsInsertionPointList; - if (!*aResult || !mInsertionPointTable->Put(aParent, *aResult)) { - delete *aResult; - *aResult = nsnull; - return NS_ERROR_OUT_OF_MEMORY; - } + mInsertionPointTable->Put(aParent, *aResult); if (aParent) { aParent->SetFlags(NODE_IS_INSERTION_PARENT); } diff --git a/content/xslt/src/xslt/txEXSLTFunctions.cpp b/content/xslt/src/xslt/txEXSLTFunctions.cpp index fb6e5d2c382..214b2133ebf 100644 --- a/content/xslt/src/xslt/txEXSLTFunctions.cpp +++ b/content/xslt/src/xslt/txEXSLTFunctions.cpp @@ -407,9 +407,7 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext, NS_ENSURE_SUCCESS(rv, rv); nsTHashtable hash; - if (!hash.Init()) { - return NS_ERROR_OUT_OF_MEMORY; - } + hash.Init(); PRInt32 i, len = nodes->size(); for (i = 0; i < len; ++i) { @@ -417,9 +415,7 @@ txEXSLTFunctionCall::evaluate(txIEvalContext *aContext, const txXPathNode& node = nodes->get(i); txXPathNodeUtils::appendNodeValue(node, str); if (!hash.GetEntry(str)) { - if (!hash.PutEntry(str)) { - return NS_ERROR_OUT_OF_MEMORY; - } + hash.PutEntry(str); rv = resultSet->append(node); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/content/xslt/src/xslt/txExecutionState.cpp b/content/xslt/src/xslt/txExecutionState.cpp index ad0f20ea91e..834eed08c40 100644 --- a/content/xslt/src/xslt/txExecutionState.cpp +++ b/content/xslt/src/xslt/txExecutionState.cpp @@ -51,8 +51,7 @@ const PRInt32 txExecutionState::kMaxRecursionDepth = 20000; nsresult txLoadedDocumentsHash::init(txXPathNode* aSourceDocument) { - nsresult rv = Init(8); - NS_ENSURE_SUCCESS(rv, rv); + Init(8); mSourceDocument = aSourceDocument; diff --git a/content/xslt/src/xslt/txKeyFunctionCall.cpp b/content/xslt/src/xslt/txKeyFunctionCall.cpp index f4e6c6df123..818f5abfdcd 100644 --- a/content/xslt/src/xslt/txKeyFunctionCall.cpp +++ b/content/xslt/src/xslt/txKeyFunctionCall.cpp @@ -272,15 +272,10 @@ txKeyHash::getKeyNodes(const txExpandedName& aKeyName, nsresult txKeyHash::init() { - nsresult rv = mKeyValues.Init(8); - NS_ENSURE_SUCCESS(rv, rv); - - rv = mIndexedKeys.Init(1); - NS_ENSURE_SUCCESS(rv, rv); - + mKeyValues.Init(8); + mIndexedKeys.Init(1); mEmptyNodeSet = new txNodeSet(nsnull); - NS_ENSURE_TRUE(mEmptyNodeSet, NS_ERROR_OUT_OF_MEMORY); - + return NS_OK; } diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 80bd48e64a8..060200f6dd9 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -1873,10 +1873,7 @@ nsXULDocument::SetTemplateBuilderFor(nsIContent* aContent, return NS_OK; } mTemplateBuilderTable = new BuilderTable; - if (! mTemplateBuilderTable || !mTemplateBuilderTable->Init()) { - mTemplateBuilderTable = nsnull; - return NS_ERROR_OUT_OF_MEMORY; - } + mTemplateBuilderTable->Init(); } if (aBuilder) { @@ -2649,9 +2646,9 @@ nsXULDocument::LoadOverlay(const nsAString& aURL, nsIObserver* aObserver) if (aObserver) { nsIObserver* obs = nsnull; - NS_ENSURE_TRUE(mOverlayLoadObservers.IsInitialized() || mOverlayLoadObservers.Init(), - NS_ERROR_OUT_OF_MEMORY); - + if (!mOverlayLoadObservers.IsInitialized()) { + mOverlayLoadObservers.Init(); + } obs = mOverlayLoadObservers.GetWeak(uri); if (obs) { @@ -3248,8 +3245,9 @@ nsXULDocument::DoneWalking() // XXXbz really, we shouldn't be firing binding constructors // until after StartLayout returns! - NS_ENSURE_TRUE(mPendingOverlayLoadNotifications.IsInitialized() || mPendingOverlayLoadNotifications.Init(), - NS_ERROR_OUT_OF_MEMORY); + if (!mPendingOverlayLoadNotifications.IsInitialized()) { + mPendingOverlayLoadNotifications.Init(); + } mPendingOverlayLoadNotifications.Get(overlayURI, getter_AddRefs(obs)); if (!obs) { diff --git a/content/xul/document/src/nsXULPrototypeCache.cpp b/content/xul/document/src/nsXULPrototypeCache.cpp index d4ce68b428d..ef327c58856 100644 --- a/content/xul/document/src/nsXULPrototypeCache.cpp +++ b/content/xul/document/src/nsXULPrototypeCache.cpp @@ -209,7 +209,7 @@ nsXULPrototypeCache::PutPrototype(nsXULPrototypeDocument* aDocument) { nsCOMPtr uri = aDocument->GetURI(); // Put() releases any old value and addrefs the new one - NS_ENSURE_TRUE(mPrototypeTable.Put(uri, aDocument), NS_ERROR_OUT_OF_MEMORY); + mPrototypeTable.Put(uri, aDocument); return NS_OK; } @@ -219,8 +219,7 @@ nsXULPrototypeCache::PutStyleSheet(nsCSSStyleSheet* aStyleSheet) { nsIURI* uri = aStyleSheet->GetSheetURI(); - NS_ENSURE_TRUE(mStyleSheetTable.Put(uri, aStyleSheet), - NS_ERROR_OUT_OF_MEMORY); + mStyleSheetTable.Put(uri, aStyleSheet); return NS_OK; } @@ -266,7 +265,7 @@ nsXULPrototypeCache::PutScript(nsIURI* aURI, JSScript* aScriptObject) CacheScriptEntry entry = {aScriptObject}; - NS_ENSURE_TRUE(mScriptTable.Put(aURI, entry), NS_ERROR_OUT_OF_MEMORY); + mScriptTable.Put(aURI, entry); // Lock the object from being gc'd until it is removed from the cache nsCOMPtr rt; @@ -296,8 +295,7 @@ nsXULPrototypeCache::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo) nsRefPtr info; mXBLDocTable.Get(uri, getter_AddRefs(info)); if (!info) { - NS_ENSURE_TRUE(mXBLDocTable.Put(uri, aDocumentInfo), - NS_ERROR_OUT_OF_MEMORY); + mXBLDocTable.Put(uri, aDocumentInfo); } return NS_OK; } diff --git a/content/xul/templates/src/nsXULContentBuilder.cpp b/content/xul/templates/src/nsXULContentBuilder.cpp index 74c132df243..470fe619080 100644 --- a/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/content/xul/templates/src/nsXULContentBuilder.cpp @@ -1241,9 +1241,8 @@ nsXULContentBuilder::CreateContainerContentsForQuerySet(nsIContent* aElement, if (prevmatch) { prevmatch->mNext = newmatch; } - else if (!mMatchMap.Put(resultid, newmatch)) { - nsTemplateMatch::Destroy(mPool, newmatch, true); - return NS_ERROR_OUT_OF_MEMORY; + else { + mMatchMap.Put(resultid, newmatch); } if (removematch) { diff --git a/content/xul/templates/src/nsXULTemplateBuilder.cpp b/content/xul/templates/src/nsXULTemplateBuilder.cpp index e0ca73f35bb..29630981c54 100644 --- a/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -211,8 +211,8 @@ nsXULTemplateBuilder::InitGlobals() gXULTemplateLog = PR_NewLogModule("nsXULTemplateBuilder"); #endif - if (!mMatchMap.IsInitialized() && !mMatchMap.Init()) - return NS_ERROR_OUT_OF_MEMORY; + if (!mMatchMap.IsInitialized()) + mMatchMap.Init(); const size_t bucketsizes[] = { sizeof(nsTemplateMatch) }; return mPool.Init("nsXULTemplateBuilder", bucketsizes, 1, 256); @@ -791,8 +791,7 @@ nsXULTemplateBuilder::UpdateResultInContainer(nsIXULTemplateResult* aOldResult, if (oldmatch == firstmatch) { // the match to remove is at the beginning if (oldmatch->mNext) { - if (!mMatchMap.Put(aOldId, oldmatch->mNext)) - return NS_ERROR_OUT_OF_MEMORY; + mMatchMap.Put(aOldId, oldmatch->mNext); } else { mMatchMap.Remove(aOldId); @@ -965,13 +964,7 @@ nsXULTemplateBuilder::UpdateResultInContainer(nsIXULTemplateResult* aOldResult, // put the match in the map if there isn't a previous match if (! prevmatch) { - if (!mMatchMap.Put(aNewId, newmatch)) { - // The match may have already matched a rule above, so - // HasBeenRemoved should be called to indicate that it - // is being removed again. - nsTemplateMatch::Destroy(mPool, newmatch, true); - return rv; - } + mMatchMap.Put(aNewId, newmatch); } } @@ -1000,10 +993,7 @@ nsXULTemplateBuilder::UpdateResultInContainer(nsIXULTemplateResult* aOldResult, acceptedmatch = newmatch; } - if (!mMatchMap.Put(aNewId, newmatch)) { - nsTemplateMatch::Destroy(mPool, newmatch, true); - return NS_ERROR_OUT_OF_MEMORY; - } + mMatchMap.Put(aNewId, newmatch); } } diff --git a/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp b/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp index 51468507109..88be134d931 100644 --- a/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp +++ b/content/xul/templates/src/nsXULTemplateQueryProcessorRDF.cpp @@ -342,15 +342,12 @@ nsXULTemplateQueryProcessorRDF::InitializeForBuilding(nsISupports* aDatasource, if (NS_FAILED(rv)) return rv; - if (!mMemoryElementToResultMap.IsInitialized() && - !mMemoryElementToResultMap.Init()) - return NS_ERROR_OUT_OF_MEMORY; - if (!mBindingDependencies.IsInitialized() && - !mBindingDependencies.Init()) - return NS_ERROR_OUT_OF_MEMORY; - if (!mRuleToBindingsMap.IsInitialized() && - !mRuleToBindingsMap.Init()) - return NS_ERROR_OUT_OF_MEMORY; + if (!mMemoryElementToResultMap.IsInitialized()) + mMemoryElementToResultMap.Init(); + if (!mBindingDependencies.IsInitialized()) + mBindingDependencies.Init(); + if (!mRuleToBindingsMap.IsInitialized()) + mRuleToBindingsMap.Init(); mQueryProcessorRDFInited = true; } @@ -620,8 +617,7 @@ nsXULTemplateQueryProcessorRDF::AddBinding(nsIDOMNode* aRuleNode, nsRefPtr bindings = mRuleToBindingsMap.GetWeak(aRuleNode); if (!bindings) { bindings = new RDFBindingSet(); - if (!bindings || !mRuleToBindingsMap.Put(aRuleNode, bindings)) - return NS_ERROR_OUT_OF_MEMORY; + mRuleToBindingsMap.Put(aRuleNode, bindings); } return bindings->AddBinding(aVar, aRef, property); @@ -1766,10 +1762,7 @@ nsXULTemplateQueryProcessorRDF::AddBindingDependency(nsXULTemplateResultRDF* aRe if (!arr) return NS_ERROR_OUT_OF_MEMORY; - if (!mBindingDependencies.Put(aResource, arr)) { - delete arr; - return NS_ERROR_OUT_OF_MEMORY; - } + mBindingDependencies.Put(aResource, arr); } PRInt32 index = arr->IndexOf(aResult); @@ -1811,10 +1804,7 @@ nsXULTemplateQueryProcessorRDF::AddMemoryElements(const Instantiation& aInst, if (!arr) return NS_ERROR_OUT_OF_MEMORY; - if (!mMemoryElementToResultMap.Put(hash, arr)) { - delete arr; - return NS_ERROR_OUT_OF_MEMORY; - } + mMemoryElementToResultMap.Put(hash, arr); } // results may be added more than once so they will all get deleted properly diff --git a/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp b/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp index 2cc60f74a73..0a9677ed65e 100644 --- a/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp +++ b/content/xul/templates/src/nsXULTemplateQueryProcessorXML.cpp @@ -255,9 +255,8 @@ nsXULTemplateQueryProcessorXML::InitializeForBuilding(nsISupports* aDatasource, mEvaluator = do_CreateInstance("@mozilla.org/dom/xpath-evaluator;1"); NS_ENSURE_TRUE(mEvaluator, NS_ERROR_OUT_OF_MEMORY); - if (!mRuleToBindingsMap.IsInitialized() && - !mRuleToBindingsMap.Init()) - return NS_ERROR_OUT_OF_MEMORY; + if (!mRuleToBindingsMap.IsInitialized()) + mRuleToBindingsMap.Init(); return NS_OK; } @@ -400,8 +399,7 @@ nsXULTemplateQueryProcessorXML::AddBinding(nsIDOMNode* aRuleNode, nsRefPtr bindings = mRuleToBindingsMap.GetWeak(aRuleNode); if (!bindings) { bindings = new nsXMLBindingSet(); - if (!bindings || !mRuleToBindingsMap.Put(aRuleNode, bindings)) - return NS_ERROR_OUT_OF_MEMORY; + mRuleToBindingsMap.Put(aRuleNode, bindings); } nsCOMPtr compiledexpr; diff --git a/content/xul/templates/src/nsXULTreeBuilder.cpp b/content/xul/templates/src/nsXULTreeBuilder.cpp index 8dcc3afb34b..8ba1fbe77b1 100644 --- a/content/xul/templates/src/nsXULTreeBuilder.cpp +++ b/content/xul/templates/src/nsXULTreeBuilder.cpp @@ -1743,9 +1743,8 @@ nsXULTreeBuilder::OpenSubtreeForQuerySet(nsTreeRows::Subtree* aSubtree, if (prevmatch) { prevmatch->mNext = newmatch; } - else if (!mMatchMap.Put(resultid, newmatch)) { - nsTemplateMatch::Destroy(mPool, newmatch, true); - return NS_ERROR_OUT_OF_MEMORY; + else { + mMatchMap.Put(resultid, newmatch); } } diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 3cf5a86e5af..1920359c00f 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -877,8 +877,7 @@ nsDocShell::Init() rv = mContentListener->Init(); NS_ENSURE_SUCCESS(rv, rv); - if (!mStorages.Init()) - return NS_ERROR_OUT_OF_MEMORY; + mStorages.Init(); // We want to hold a strong ref to the loadgroup, so it better hold a weak // ref to us... use an InterfaceRequestorProxy to do this. @@ -2442,8 +2441,7 @@ nsDocShell::GetSessionStorageForPrincipal(nsIPrincipal* aPrincipal, if (NS_FAILED(rv)) return rv; - if (!mStorages.Put(origin, newstorage)) - return NS_ERROR_OUT_OF_MEMORY; + mStorages.Put(origin, newstorage); newstorage.swap(*aStorage); #if defined(PR_LOGGING) && defined(DEBUG) @@ -2580,8 +2578,7 @@ nsDocShell::AddSessionStorage(nsIPrincipal* aPrincipal, ("nsDocShell[%p]: was added a sessionStorage %p", this, aStorage)); #endif - if (!mStorages.Put(origin, aStorage)) - return NS_ERROR_OUT_OF_MEMORY; + mStorages.Put(origin, aStorage); } else { return topDocShell->AddSessionStorage(aPrincipal, aStorage); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 1f816f75d9a..038af046534 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -816,14 +816,7 @@ nsGlobalWindow::Init() #endif sWindowsById = new WindowByIdTable(); - // There are two reasons to have Init() failing: if we were not able to - // alloc the memory or if the size we want to init is too high. None of them - // should happen. -#ifdef DEBUG - NS_ASSERTION(sWindowsById->Init(), "Init() should not fail!"); -#else sWindowsById->Init(); -#endif } static PLDHashOperator @@ -6745,10 +6738,8 @@ void nsGlobalWindow::CacheXBLPrototypeHandler(nsXBLPrototypeHandler* aKey, nsScriptObjectHolder& aHandler) { - if (!mCachedXBLPrototypeHandlers.IsInitialized() && - !mCachedXBLPrototypeHandlers.Init()) { - NS_ERROR("Failed to initiailize hashtable!"); - return; + if (!mCachedXBLPrototypeHandlers.IsInitialized()) { + mCachedXBLPrototypeHandlers.Init(); } if (!mCachedXBLPrototypeHandlers.Count()) { diff --git a/dom/indexedDB/DatabaseInfo.cpp b/dom/indexedDB/DatabaseInfo.cpp index 5aa4465181a..004837a2141 100644 --- a/dom/indexedDB/DatabaseInfo.cpp +++ b/dom/indexedDB/DatabaseInfo.cpp @@ -73,10 +73,7 @@ CloneObjectStoreInfo(const nsAString& aKey, nsRefPtr newInfo(new ObjectStoreInfo(*aData)); - if (!hash->Put(aKey, newInfo)) { - NS_WARNING("Out of memory?"); - return PL_DHASH_STOP; - } + hash->Put(aKey, newInfo); return PL_DHASH_NEXT; } @@ -178,11 +175,7 @@ DatabaseInfo::Put(DatabaseInfo* aInfo) if (!gDatabaseHash) { nsAutoPtr databaseHash(new DatabaseHash()); - if (!databaseHash->Init()) { - NS_ERROR("Failed to initialize hashtable!"); - return false; - } - + databaseHash->Init(); gDatabaseHash = databaseHash.forget(); } @@ -191,10 +184,7 @@ DatabaseInfo::Put(DatabaseInfo* aInfo) return false; } - if (!gDatabaseHash->Put(aInfo->id, aInfo)) { - NS_ERROR("Put failed!"); - return false; - } + gDatabaseHash->Put(aInfo->id, aInfo); return true; } @@ -280,10 +270,7 @@ DatabaseInfo::PutObjectStore(ObjectStoreInfo* aInfo) if (!objectStoreHash) { nsAutoPtr hash(new ObjectStoreInfoHash()); - if (!hash->Init()) { - NS_ERROR("Failed to initialize hashtable!"); - return false; - } + hash->Init(); objectStoreHash = hash.forget(); } @@ -292,7 +279,8 @@ DatabaseInfo::PutObjectStore(ObjectStoreInfo* aInfo) return false; } - return objectStoreHash->Put(aInfo->name, aInfo); + objectStoreHash->Put(aInfo->name, aInfo); + return true; } void @@ -323,10 +311,7 @@ DatabaseInfo::Clone() if (objectStoreHash) { dbInfo->objectStoreHash = new ObjectStoreInfoHash(); - if (!dbInfo->objectStoreHash->Init()) { - return nsnull; - } - + dbInfo->objectStoreHash->Init(); objectStoreHash->EnumerateRead(CloneObjectStoreInfo, dbInfo->objectStoreHash); } diff --git a/dom/indexedDB/FileManager.cpp b/dom/indexedDB/FileManager.cpp index 5dd7d412b14..7b9d668e039 100644 --- a/dom/indexedDB/FileManager.cpp +++ b/dom/indexedDB/FileManager.cpp @@ -78,7 +78,7 @@ FileManager::Init(nsIFile* aDirectory, { NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!"); - NS_ENSURE_TRUE(mFileInfos.Init(), NS_ERROR_OUT_OF_MEMORY); + mFileInfos.Init(); bool exists; nsresult rv = aDirectory->Exists(&exists); @@ -186,10 +186,7 @@ FileManager::Load(mozIStorageConnection* aConnection) nsRefPtr fileInfo = FileInfo::Create(this, id); fileInfo->mDBRefCnt = refcount; - if (!mFileInfos.Put(id, fileInfo)) { - NS_WARNING("Out of memory?"); - return NS_ERROR_OUT_OF_MEMORY; - } + mFileInfos.Put(id, fileInfo); mLastFileId = NS_MAX(id, mLastFileId); } @@ -273,10 +270,7 @@ FileManager::GetNewFileInfo() fileInfo = FileInfo::Create(this, id); - if (!mFileInfos.Put(id, fileInfo)) { - NS_WARNING("Out of memory?"); - return nsnull; - } + mFileInfos.Put(id, fileInfo); mLastFileId = id; } diff --git a/dom/indexedDB/IDBTransaction.cpp b/dom/indexedDB/IDBTransaction.cpp index b82163ca9eb..e502c358b94 100644 --- a/dom/indexedDB/IDBTransaction.cpp +++ b/dom/indexedDB/IDBTransaction.cpp @@ -136,10 +136,7 @@ IDBTransaction::Create(IDBDatabase* aDatabase, return nsnull; } - if (!transaction->mCachedStatements.Init()) { - NS_ERROR("Failed to initialize hash!"); - return nsnull; - } + transaction->mCachedStatements.Init(); if (!aDispatchDelayed) { nsCOMPtr appShell = do_GetService(kAppShellCID); @@ -396,9 +393,7 @@ IDBTransaction::GetCachedStatement(const nsACString& aQuery) #endif NS_ENSURE_SUCCESS(rv, nsnull); - if (!mCachedStatements.Put(aQuery, stmt)) { - NS_ERROR("Out of memory?!"); - } + mCachedStatements.Put(aQuery, stmt); } return stmt.forget(); @@ -845,7 +840,7 @@ CommitHelper::RevertAutoIncrementCounts() nsresult UpdateRefcountFunction::Init() { - NS_ENSURE_TRUE(mFileInfoEntries.Init(), NS_ERROR_OUT_OF_MEMORY); + mFileInfoEntries.Init(); return NS_OK; } @@ -911,10 +906,7 @@ UpdateRefcountFunction::ProcessValue(mozIStorageValueArray* aValues, NS_ASSERTION(fileInfo, "Shouldn't be null!"); nsAutoPtr newEntry(new FileInfoEntry(fileInfo)); - if (!mFileInfoEntries.Put(id, newEntry)) { - NS_WARNING("Out of memory?"); - return NS_ERROR_OUT_OF_MEMORY; - } + mFileInfoEntries.Put(id, newEntry); entry = newEntry.forget(); } diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp index 5f580eaf74b..fed931f6e3b 100644 --- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -228,12 +228,9 @@ IndexedDatabaseManager::GetOrCreate() instance = new IndexedDatabaseManager(); - if (!instance->mLiveDatabases.Init() || - !instance->mQuotaHelperHash.Init() || - !instance->mFileManagers.Init()) { - NS_WARNING("Out of memory!"); - return nsnull; - } + instance->mLiveDatabases.Init(); + instance->mQuotaHelperHash.Init(); + instance->mFileManagers.Init(); // We need a thread-local to hold the current window. NS_ASSERTION(instance->mCurrentWindowIndex == BAD_TLS_INDEX, "Huh?"); @@ -342,10 +339,7 @@ IndexedDatabaseManager::RegisterDatabase(IDBDatabase* aDatabase) nsTArray* array; if (!mLiveDatabases.Get(aDatabase->Origin(), &array)) { nsAutoPtr > newArray(new nsTArray()); - if (!mLiveDatabases.Put(aDatabase->Origin(), newArray)) { - NS_WARNING("Out of memory?"); - return false; - } + mLiveDatabases.Put(aDatabase->Origin(), newArray); array = newArray.forget(); } if (!array->AppendElement(aDatabase)) { @@ -730,7 +724,7 @@ IndexedDatabaseManager::EnsureOriginIsInitialized(const nsACString& aOrigin, new nsTArray >()); nsTHashtable validSubdirs; - NS_ENSURE_TRUE(validSubdirs.Init(20), NS_ERROR_OUT_OF_MEMORY); + validSubdirs.Init(20); nsCOMPtr entries; rv = directory->GetDirectoryEntries(getter_AddRefs(entries)); @@ -808,10 +802,7 @@ IndexedDatabaseManager::EnsureOriginIsInitialized(const nsACString& aOrigin, rv = ss->UpdateQuotaInformationForFile(file); NS_ENSURE_SUCCESS(rv, rv); - if (!validSubdirs.PutEntry(dbBaseFilename)) { - NS_WARNING("Out of memory?"); - return NS_ERROR_OUT_OF_MEMORY; - } + validSubdirs.PutEntry(dbBaseFilename); } NS_ENSURE_SUCCESS(rv, rv); @@ -844,11 +835,7 @@ IndexedDatabaseManager::EnsureOriginIsInitialized(const nsACString& aOrigin, } } - if (!mFileManagers.Put(aOrigin, fileManagers)) { - NS_WARNING("Out of memory?"); - return NS_ERROR_OUT_OF_MEMORY; - } - + mFileManagers.Put(aOrigin, fileManagers); fileManagers.forget(); NS_ADDREF(*aDirectory = directory); @@ -878,8 +865,7 @@ IndexedDatabaseManager::QuotaIsLiftedInternal() helper = new CheckQuotaHelper(window, mQuotaHelperMutex); createdHelper = true; - bool result = mQuotaHelperHash.Put(window, helper); - NS_ENSURE_TRUE(result, result); + mQuotaHelperHash.Put(window, helper); // Unlock while calling out to XPCOM { @@ -966,10 +952,7 @@ IndexedDatabaseManager::GetOrCreateFileManager(const nsACString& aOrigin, if (!mFileManagers.Get(aOrigin, &array)) { nsAutoPtr > > newArray( new nsTArray >()); - if (!mFileManagers.Put(aOrigin, newArray)) { - NS_WARNING("Out of memory?"); - return nsnull; - } + mFileManagers.Put(aOrigin, newArray); array = newArray.forget(); } diff --git a/dom/indexedDB/TransactionThreadPool.cpp b/dom/indexedDB/TransactionThreadPool.cpp index 784f1ebd144..3934272f1a8 100644 --- a/dom/indexedDB/TransactionThreadPool.cpp +++ b/dom/indexedDB/TransactionThreadPool.cpp @@ -164,10 +164,7 @@ TransactionThreadPool::Init() { NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); - if (!mTransactionsInProgress.Init()) { - NS_WARNING("Failed to init hash!"); - return NS_ERROR_FAILURE; - } + mTransactionsInProgress.Init(); nsresult rv; mThreadPool = do_CreateInstance(NS_THREADPOOL_CONTRACTID, &rv); @@ -468,10 +465,7 @@ TransactionThreadPool::Dispatch(IDBTransaction* aTransaction, } if (autoDBTransactionInfo) { - if (!mTransactionsInProgress.Put(databaseId, autoDBTransactionInfo)) { - NS_WARNING("Failed to put!"); - return NS_ERROR_OUT_OF_MEMORY; - } + mTransactionsInProgress.Put(databaseId, autoDBTransactionInfo); autoDBTransactionInfo.forget(); } diff --git a/dom/ipc/CrashReporterParent.cpp b/dom/ipc/CrashReporterParent.cpp index 0530591bc97..1df8c9b09af 100644 --- a/dom/ipc/CrashReporterParent.cpp +++ b/dom/ipc/CrashReporterParent.cpp @@ -124,8 +124,7 @@ CrashReporterParent::GenerateHangCrashReport(const AnnotationTable* processNotes GenerateChildData(processNotes); CrashReporter::AnnotationTable notes; - if (!notes.Init(4)) - return false; + notes.Init(4); notes.Put(nsDependentCString("HangID"), NS_ConvertUTF16toUTF8(mHangID)); if (!CrashReporter::AppendExtraData(mParentDumpID, notes)) NS_WARNING("problem appending parent data to .extra"); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 3cb14a06e12..a93843099b8 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -384,7 +384,7 @@ TabChild::OpenDialog(PRUint32 aType, const nsACString& aName, nsIDOMElement* aFrameElement) { if (!gActiveDialogs.IsInitialized()) { - NS_ENSURE_STATE(gActiveDialogs.Init()); + gActiveDialogs.Init(); } InfallibleTArray intParams; InfallibleTArray stringParams; @@ -392,7 +392,7 @@ TabChild::OpenDialog(PRUint32 aType, const nsACString& aName, PContentDialogChild* dialog = SendPContentDialogConstructor(aType, nsCString(aName), nsCString(aFeatures), intParams, stringParams); - NS_ENSURE_STATE(gActiveDialogs.Put(dialog, aArguments)); + gActiveDialogs.Put(dialog, aArguments); nsIThread *thread = NS_GetCurrentThread(); while (gActiveDialogs.GetWeak(dialog)) { if (!NS_ProcessNextEvent(thread)) { diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 0cd401cc714..2d77389b4d2 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -1044,9 +1044,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result) if (!gCharsetMap) { const int NUM_CHARSETS = sizeof(charsets) / sizeof(moz2javaCharset); gCharsetMap = new nsDataHashtable(); - if (!gCharsetMap || !gCharsetMap->Init(NUM_CHARSETS)) + if (!gCharsetMap) return NS_ERROR_OUT_OF_MEMORY; - + gCharsetMap->Init(NUM_CHARSETS); for (PRUint16 i = 0; i < NUM_CHARSETS; i++) { gCharsetMap->Put(charsets[i].mozName, charsets[i].javaName); } diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index c42a842358c..71f2fdebe83 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -137,7 +137,8 @@ PluginInstanceParent::~PluginInstanceParent() bool PluginInstanceParent::Init() { - return !!mScriptableObjects.Init(); + mScriptableObjects.Init(); + return true; } void @@ -1542,7 +1543,8 @@ PluginInstanceParent::RegisterNPObjectForActor( NS_ASSERTION(aObject && aActor, "Null pointers!"); NS_ASSERTION(mScriptableObjects.IsInitialized(), "Hash not initialized!"); NS_ASSERTION(!mScriptableObjects.Get(aObject, nsnull), "Duplicate entry!"); - return !!mScriptableObjects.Put(aObject, aActor); + mScriptableObjects.Put(aObject, aActor); + return true; } void diff --git a/dom/plugins/ipc/PluginModuleChild.cpp b/dom/plugins/ipc/PluginModuleChild.cpp index 696279b1f12..a537e533c7d 100644 --- a/dom/plugins/ipc/PluginModuleChild.cpp +++ b/dom/plugins/ipc/PluginModuleChild.cpp @@ -177,20 +177,9 @@ PluginModuleChild::Init(const std::string& aPluginFilename, NS_ASSERTION(aChannel, "need a channel"); - if (!mObjectMap.Init()) { - NS_WARNING("Failed to initialize object hashtable!"); - return false; - } - - if (!mStringIdentifiers.Init()) { - NS_ERROR("Failed to initialize string identifier hashtable!"); - return false; - } - - if (!mIntIdentifiers.Init()) { - NS_ERROR("Failed to initialize int identifier hashtable!"); - return false; - } + mObjectMap.Init(); + mStringIdentifiers.Init(); + mIntIdentifiers.Init(); if (!InitGraphics()) return false; diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index 9c8e23f1bf7..02fbb18e87f 100644 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -137,9 +137,7 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath) { NS_ASSERTION(mSubprocess, "Out of memory!"); - if (!mIdentifiers.Init()) { - NS_ERROR("Out of memory"); - } + mIdentifiers.Init(); Preferences::RegisterCallback(TimeoutChanged, kChildTimeoutPref, this); Preferences::RegisterCallback(TimeoutChanged, kParentTimeoutPref, this); diff --git a/dom/src/storage/nsDOMStorage.cpp b/dom/src/storage/nsDOMStorage.cpp index 76a2ccdd5da..e061a4050a5 100644 --- a/dom/src/storage/nsDOMStorage.cpp +++ b/dom/src/storage/nsDOMStorage.cpp @@ -273,12 +273,7 @@ nsDOMStorageManager::Initialize() if (!gStorageManager) return NS_ERROR_OUT_OF_MEMORY; - if (!gStorageManager->mStorages.Init()) { - delete gStorageManager; - gStorageManager = nsnull; - return NS_ERROR_OUT_OF_MEMORY; - } - + gStorageManager->mStorages.Init(); NS_ADDREF(gStorageManager); // No observers needed in non-chrome diff --git a/dom/src/storage/nsDOMStorageMemoryDB.cpp b/dom/src/storage/nsDOMStorageMemoryDB.cpp index c76946d0f50..f26b3410fb7 100644 --- a/dom/src/storage/nsDOMStorageMemoryDB.cpp +++ b/dom/src/storage/nsDOMStorageMemoryDB.cpp @@ -46,8 +46,7 @@ nsresult nsDOMStorageMemoryDB::Init(nsDOMStoragePersistentDB* aPreloadDB) { - if (!mData.Init(20)) - return NS_ERROR_OUT_OF_MEMORY; + mData.Init(20); mPreloadDB = aPreloadDB; return NS_OK; @@ -86,10 +85,7 @@ nsDOMStorageMemoryDB::GetItemsTable(DOMStorageImpl* aStorage, if (!storageData) return NS_ERROR_OUT_OF_MEMORY; - if (!storageData->mTable.Init()) { - delete storageData; - return NS_ERROR_OUT_OF_MEMORY; - } + storageData->mTable.Init(); if (mPreloadDB) { nsresult rv; diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index e49bc23df11..479fd13f9cb 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -639,11 +639,7 @@ RuntimeService::RegisterWorker(JSContext* aCx, WorkerPrivate* aWorkerPrivate) domainInfo = new WorkerDomainInfo(); domainInfo->mDomain = domain; - - if (!mDomainMap.Put(domain, domainInfo)) { - delete domainInfo; - domainInfo = nsnull; - } + mDomainMap.Put(domain, domainInfo); } if (domainInfo) { @@ -696,13 +692,7 @@ RuntimeService::RegisterWorker(JSContext* aCx, WorkerPrivate* aWorkerPrivate) NS_ASSERTION(!parent, "Shouldn't have a parent here!"); windowArray = new nsTArray(1); - - if (!mWindowMap.Put(window, windowArray)) { - delete windowArray; - UnregisterWorker(aCx, aWorkerPrivate); - JS_ReportOutOfMemory(aCx); - return false; - } + mWindowMap.Put(window, windowArray); } NS_ASSERTION(!windowArray->Contains(aWorkerPrivate), @@ -915,11 +905,8 @@ RuntimeService::Init() mIdleThreadTimer = do_CreateInstance(NS_TIMER_CONTRACTID); NS_ENSURE_STATE(mIdleThreadTimer); - bool ok = mDomainMap.Init(); - NS_ENSURE_STATE(ok); - - ok = mWindowMap.Init(); - NS_ENSURE_STATE(ok); + mDomainMap.Init(); + mWindowMap.Init(); nsCOMPtr obs = services::GetObserverService(); NS_ENSURE_TRUE(obs, NS_ERROR_FAILURE); diff --git a/embedding/components/commandhandler/src/nsCommandManager.cpp b/embedding/components/commandhandler/src/nsCommandManager.cpp index ec101d3bfff..3cb34627727 100644 --- a/embedding/components/commandhandler/src/nsCommandManager.cpp +++ b/embedding/components/commandhandler/src/nsCommandManager.cpp @@ -116,7 +116,7 @@ nsCommandManager::Init(nsIDOMWindow *aWindow) NS_ASSERTION(aWindow, "Need non-null window here"); mWindow = aWindow; // weak ptr - NS_ENSURE_TRUE(mObserversTable.Init(), NS_ERROR_OUT_OF_MEMORY); + mObserversTable.Init(); return NS_OK; } @@ -163,8 +163,7 @@ nsCommandManager::AddCommandObserver(nsIObserver *aCommandObserver, const char * if (!mObserversTable.Get(aCommandToObserve, &commandObservers)) { nsAutoPtr > array(new nsCOMArray); - if (!array || !mObserversTable.Put(aCommandToObserve, array)) - return NS_ERROR_OUT_OF_MEMORY; + mObserversTable.Put(aCommandToObserve, array); commandObservers = array.forget(); } diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index cdfe21bbc3a..9962dc8b52a 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -193,9 +193,7 @@ nsPermissionManager::Init() { nsresult rv; - if (!mHostTable.Init()) { - return NS_ERROR_OUT_OF_MEMORY; - } + mHostTable.Init(); mObserverService = do_GetService("@mozilla.org/observer-service;1", &rv); if (NS_SUCCEEDED(rv)) { diff --git a/extensions/spellcheck/hunspell/src/mozHunspell.cpp b/extensions/spellcheck/hunspell/src/mozHunspell.cpp index b978caa8349..a1bb00980d4 100644 --- a/extensions/spellcheck/hunspell/src/mozHunspell.cpp +++ b/extensions/spellcheck/hunspell/src/mozHunspell.cpp @@ -123,9 +123,7 @@ NS_MEMORY_REPORTER_IMPLEMENT(Hunspell, nsresult mozHunspell::Init() { - if (!mDictionaries.Init()) - return NS_ERROR_OUT_OF_MEMORY; - + mDictionaries.Init(); LoadDictionaryList(); nsCOMPtr obs = mozilla::services::GetObserverService(); diff --git a/extensions/spellcheck/src/mozPersonalDictionary.cpp b/extensions/spellcheck/src/mozPersonalDictionary.cpp index 13c3ab8d82a..569389a49ee 100644 --- a/extensions/spellcheck/src/mozPersonalDictionary.cpp +++ b/extensions/spellcheck/src/mozPersonalDictionary.cpp @@ -90,8 +90,8 @@ mozPersonalDictionary::~mozPersonalDictionary() nsresult mozPersonalDictionary::Init() { - if (!mDictionaryTable.Init() || !mIgnoreTable.Init()) - return NS_ERROR_OUT_OF_MEMORY; + mDictionaryTable.Init(); + mIgnoreTable.Init(); nsresult rv; nsCOMPtr svc = diff --git a/image/src/imgLoader.cpp b/image/src/imgLoader.cpp index 36c8e6a1919..5cc28f417b2 100644 --- a/image/src/imgLoader.cpp +++ b/image/src/imgLoader.cpp @@ -915,10 +915,8 @@ nsresult imgLoader::InitCache() gCacheTracker = new imgCacheExpirationTracker(); - if (!sCache.Init()) - return NS_ERROR_OUT_OF_MEMORY; - if (!sChromeCache.Init()) - return NS_ERROR_OUT_OF_MEMORY; + sCache.Init(); + sChromeCache.Init(); PRInt32 timeweight; rv = Preferences::GetInt("image.cache.timeweight", &timeweight); @@ -1083,8 +1081,7 @@ bool imgLoader::PutIntoCache(nsIURI *key, imgCacheEntry *entry) ("[this=%p] imgLoader::PutIntoCache -- Element NOT already in the cache", nsnull)); } - if (!cache.Put(spec, entry)) - return false; + cache.Put(spec, entry); // We can be called to resurrect an evicted entry. if (entry->Evicted()) diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp index 743a11cabe9..f6aff26353b 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -454,12 +454,9 @@ mozJSComponentLoader::ReallyInit() if (NS_FAILED(rv) || !mSystemPrincipal) return NS_ERROR_FAILURE; - if (!mModules.Init(32)) - return NS_ERROR_OUT_OF_MEMORY; - if (!mImports.Init(32)) - return NS_ERROR_OUT_OF_MEMORY; - if (!mInProgressImports.Init(32)) - return NS_ERROR_OUT_OF_MEMORY; + mModules.Init(32); + mImports.Init(32); + mInProgressImports.Init(32); nsCOMPtr obsSvc = do_GetService(kObserverServiceContractID, &rv); @@ -607,8 +604,7 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile) } // Cache this module for later - if (!mModules.Put(spec, entry)) - return NULL; + mModules.Put(spec, entry); // The hash owns the ModuleEntry now, forget about it return entry.forget(); @@ -1141,8 +1137,9 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation, nsAutoPtr newEntry; if (!mImports.Get(key, &mod) && !mInProgressImports.Get(key, &mod)) { newEntry = new ModuleEntry; - if (!newEntry || !mInProgressImports.Put(key, newEntry)) + if (!newEntry) return NS_ERROR_OUT_OF_MEMORY; + mInProgressImports.Put(key, newEntry); JS::Anchor exception(JSVAL_VOID); rv = GlobalForLocation(sourceLocalFile, resURI, &newEntry->global, @@ -1256,8 +1253,7 @@ mozJSComponentLoader::ImportInto(const nsACString & aLocation, // Cache this module for later if (newEntry) { - if (!mImports.Put(key, newEntry)) - return NS_ERROR_OUT_OF_MEMORY; + mImports.Put(key, newEntry); newEntry.forget(); } diff --git a/js/xpconnect/src/dombindings.cpp b/js/xpconnect/src/dombindings.cpp index 7373cb3d5d1..136389e267f 100644 --- a/js/xpconnect/src/dombindings.cpp +++ b/js/xpconnect/src/dombindings.cpp @@ -440,8 +440,8 @@ ListBase::getPrototype(JSContext *cx, XPCWrappedNativeScope *scope, xpc_UnmarkGrayObject(interfacePrototype); return interfacePrototype; } - } else if (!cache.Init()) { - return NULL; + } else { + cache.Init(); } JSObject* proto = Base::getPrototype(cx, scope, receiver); @@ -491,7 +491,7 @@ ListBase::getPrototype(JSContext *cx, XPCWrappedNativeScope *scope, // overwrite the value set by InvalidateProtoShape_add when we set our own properties. js::SetReservedSlot(interfacePrototype, 0, PrivateUint32Value(USE_CACHE)); - if (!cache.Put(sInterfaceClass.name, interfacePrototype)) + if (!cache.Put(sInterfaceClass.name, interfacePrototype, fallible_t())) return NULL; return interfacePrototype; diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index 05775c204bb..60d5bb76b3e 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -4380,6 +4380,9 @@ namespace xpc { struct CompartmentPrivate { + typedef nsDataHashtable, JSObject *> ExpandoMap; + typedef nsTHashtable > DOMExpandoMap; + CompartmentPrivate(bool wantXrays) : wantXrays(wantXrays) { @@ -4391,20 +4394,17 @@ struct CompartmentPrivate bool wantXrays; nsAutoPtr waiverWrapperMap; // NB: we don't want this map to hold a strong reference to the wrapper. - nsAutoPtr, JSObject *> > expandoMap; - nsAutoPtr > > domExpandoMap; + nsAutoPtr expandoMap; + nsAutoPtr domExpandoMap; nsCString location; bool RegisterExpandoObject(XPCWrappedNative *wn, JSObject *expando) { if (!expandoMap) { - expandoMap = new nsDataHashtable, JSObject *>(); - if (!expandoMap->Init(8)) { - expandoMap = nsnull; - return false; - } + expandoMap = new ExpandoMap(); + expandoMap->Init(8); } wn->SetHasExpandoObject(); - return expandoMap->Put(wn, expando); + return expandoMap->Put(wn, expando, mozilla::fallible_t()); } /** @@ -4430,13 +4430,10 @@ struct CompartmentPrivate bool RegisterDOMExpandoObject(JSObject *expando) { if (!domExpandoMap) { - domExpandoMap = new nsTHashtable >(); - if (!domExpandoMap->Init(8)) { - domExpandoMap = nsnull; - return false; - } + domExpandoMap = new DOMExpandoMap(); + domExpandoMap->Init(8); } - return domExpandoMap->PutEntry(expando); + return domExpandoMap->PutEntry(expando, mozilla::fallible_t()); } void RemoveDOMExpandoObject(JSObject *expando) { if (domExpandoMap) diff --git a/layout/base/RestyleTracker.h b/layout/base/RestyleTracker.h index b83ba0d08bf..3c6d80346a5 100644 --- a/layout/base/RestyleTracker.h +++ b/layout/base/RestyleTracker.h @@ -76,8 +76,8 @@ public: "Shouldn't have both root flags"); } - bool Init() { - return mPendingRestyles.Init(); + void Init() { + mPendingRestyles.Init(); } PRUint32 Count() const { diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index bf3fe330590..86dbf204732 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -1395,9 +1395,8 @@ nsCSSFrameConstructor::nsCSSFrameConstructor(nsIDocument *aDocument, ELEMENT_IS_POTENTIAL_ANIMATION_RESTYLE_ROOT, this) { // XXXbz this should be in Init() or something! - if (!mPendingRestyles.Init() || !mPendingAnimationRestyles.Init()) { - // now what? - } + mPendingRestyles.Init(); + mPendingAnimationRestyles.Init(); #ifdef DEBUG static bool gFirstTime = true; diff --git a/layout/base/nsCounterManager.cpp b/layout/base/nsCounterManager.cpp index 63586188bee..91ee40833fb 100644 --- a/layout/base/nsCounterManager.cpp +++ b/layout/base/nsCounterManager.cpp @@ -275,10 +275,7 @@ nsCounterManager::CounterListFor(const nsSubstring& aCounterName) nsCounterList *counterList; if (!mNames.Get(aCounterName, &counterList)) { counterList = new nsCounterList(); - if (!mNames.Put(aCounterName, counterList)) { - delete counterList; - return nsnull; - } + mNames.Put(aCounterName, counterList); } return counterList; } diff --git a/layout/base/nsLayoutHistoryState.cpp b/layout/base/nsLayoutHistoryState.cpp index 742bc8f191e..2b01bf19095 100644 --- a/layout/base/nsLayoutHistoryState.cpp +++ b/layout/base/nsLayoutHistoryState.cpp @@ -96,13 +96,15 @@ nsresult nsLayoutHistoryState::Init() { mScrollPositionOnly = false; - return mStates.Init() ? NS_OK : NS_ERROR_FAILURE; + mStates.Init(); + return NS_OK; } NS_IMETHODIMP nsLayoutHistoryState::AddState(const nsCString& aStateKey, nsPresState* aState) { - return mStates.Put(aStateKey, aState) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; + mStates.Put(aStateKey, aState); + return NS_OK; } NS_IMETHODIMP diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 2e2e25fc21f..3252de93269 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -143,11 +143,7 @@ static ContentMap* sContentMap = NULL; static ContentMap& GetContentMap() { if (!sContentMap) { sContentMap = new ContentMap(); -#ifdef DEBUG - nsresult rv = -#endif sContentMap->Init(); - NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv), "Could not initialize map."); } return *sContentMap; } diff --git a/layout/base/nsPresArena.cpp b/layout/base/nsPresArena.cpp index 53ad1f90531..99064285ac4 100644 --- a/layout/base/nsPresArena.cpp +++ b/layout/base/nsPresArena.cpp @@ -289,7 +289,6 @@ public: nsTArray mEntries; size_t mEntrySize; -protected: typedef const void* KeyTypePointer; KeyTypePointer mKey; @@ -306,7 +305,6 @@ protected: { return NS_PTR_TO_INT32(aKey); } enum { ALLOW_MEMMOVE = false }; - friend class nsTHashtable; }; } @@ -337,9 +335,6 @@ struct nsPresArena::State { // If there is no free-list entry for this type already, we have // to create one now, to record its size. FreeList* list = mFreeLists.PutEntry(aCode); - if (!list) { - return nsnull; - } nsTArray::index_type len = list->mEntries.Length(); if (list->mEntrySize == 0) { diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 86be2cbe1ac..b786e2e1380 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -954,9 +954,9 @@ nsPresContext::Init(nsDeviceContext* aDeviceContext) mDeviceContext->FlushFontCache(); mCurAppUnitsPerDevPixel = AppUnitsPerDevPixel(); - for (PRUint32 i = 0; i < IMAGE_LOAD_TYPE_COUNT; ++i) - if (!mImageLoaders[i].Init()) - return NS_ERROR_OUT_OF_MEMORY; + for (PRUint32 i = 0; i < IMAGE_LOAD_TYPE_COUNT; ++i) { + mImageLoaders[i].Init(); + } mEventManager = new nsEventStateManager(); NS_ADDREF(mEventManager); diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 2473737356e..67fff1d1224 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -767,9 +767,7 @@ PresShell::Init(nsIDocument* aDocument, return NS_ERROR_ALREADY_INITIALIZED; } - if (!mFramesToDirty.Init()) { - return NS_ERROR_OUT_OF_MEMORY; - } + mFramesToDirty.Init(); mDocument = aDocument; NS_ADDREF(mDocument); diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index d9d9f0d2142..1d8d5ed876e 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -587,9 +587,7 @@ TextOverflow::ProcessLine(const nsDisplayListSet& aLists, mRight.mActive = mRight.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP; FrameHashtable framesToHide; - if (!framesToHide.Init(100)) { - return; - } + framesToHide.Init(100); AlignmentEdges alignmentEdges; ExamineLineFrames(aLine, &framesToHide, &alignmentEdges); bool needLeft = mLeft.IsNeeded(); diff --git a/layout/inspector/src/nsFontFaceList.cpp b/layout/inspector/src/nsFontFaceList.cpp index ff6a40736d4..1a8df6d99c0 100644 --- a/layout/inspector/src/nsFontFaceList.cpp +++ b/layout/inspector/src/nsFontFaceList.cpp @@ -128,9 +128,7 @@ nsFontFaceList::AddFontsFromTextRun(gfxTextRun* aTextRun, } nsCOMPtr ff = new nsFontFace(fe, iter.GetGlyphRun()->mMatchType, rule); - if (!mFontFaces.Put(fe, ff)) { - return NS_ERROR_OUT_OF_MEMORY; - } + mFontFaces.Put(fe, ff); } } diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index 521a45762dc..930e261c191 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -1102,10 +1102,15 @@ Loader::CreateSheet(nsIURI* aURI, LOG(("css::Loader::CreateSheet")); NS_PRECONDITION(aSheet, "Null out param!"); - NS_ENSURE_TRUE((mCompleteSheets.IsInitialized() || mCompleteSheets.Init()) && - (mLoadingDatas.IsInitialized() || mLoadingDatas.Init()) && - (mPendingDatas.IsInitialized() || mPendingDatas.Init()), - NS_ERROR_OUT_OF_MEMORY); + if (!mCompleteSheets.IsInitialized()) { + mCompleteSheets.Init(); + } + if (!mLoadingDatas.IsInitialized()) { + mLoadingDatas.Init(); + } + if (!mPendingDatas.IsInitialized()) { + mPendingDatas.Init(); + } nsresult rv = NS_OK; *aSheet = nsnull; @@ -1597,14 +1602,7 @@ Loader::LoadSheet(SheetLoadData* aLoadData, StyleSheetState aSheetState) return rv; } - if (!mLoadingDatas.Put(&key, aLoadData)) { - LOG_ERROR((" Failed to put data in loading table")); - aLoadData->mIsCancelled = true; - channel->Cancel(NS_ERROR_OUT_OF_MEMORY); - SheetComplete(aLoadData, NS_ERROR_OUT_OF_MEMORY); - return NS_ERROR_OUT_OF_MEMORY; - } - + mLoadingDatas.Put(&key, aLoadData); aLoadData->mIsLoading = true; return NS_OK; @@ -1951,9 +1949,7 @@ Loader::LoadStyleLink(nsIContent* aElement, *aIsAlternate) { LOG((" Deferring alternate sheet load")); URIAndPrincipalHashKey key(data->mURI, data->mLoaderPrincipal); - if (!mPendingDatas.Put(&key, data)) { - return NS_ERROR_OUT_OF_MEMORY; - } + mPendingDatas.Put(&key, data); data->mMustNotify = true; return NS_OK; diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index ae7e3ceec0e..868afafca19 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -500,10 +500,7 @@ void nsTableFrame::ResetRowIndices(const nsFrameList::Slice& aRowGroupsToExclude PRInt32 rowIndex = 0; nsTHashtable > excludeRowGroups; - if (!excludeRowGroups.Init()) { - NS_ERROR("Failed to initialize excludeRowGroups hash."); - return; - } + excludeRowGroups.Init(); nsFrameList::Enumerator excludeRowGroupsEnumerator(aRowGroupsToExclude); while (!excludeRowGroupsEnumerator.AtEnd()) { excludeRowGroups.PutEntry(static_cast(excludeRowGroupsEnumerator.get())); diff --git a/layout/xul/base/src/nsBoxObject.cpp b/layout/xul/base/src/nsBoxObject.cpp index 4556f52918c..5f2a143a780 100644 --- a/layout/xul/base/src/nsBoxObject.cpp +++ b/layout/xul/base/src/nsBoxObject.cpp @@ -343,15 +343,11 @@ nsBoxObject::SetPropertyAsSupports(const PRUnichar* aPropertyName, nsISupports* if (!mPropertyTable) { mPropertyTable = new nsInterfaceHashtable; if (!mPropertyTable) return NS_ERROR_OUT_OF_MEMORY; - if (!mPropertyTable->Init(8)) { - mPropertyTable = nsnull; - return NS_ERROR_FAILURE; - } + mPropertyTable->Init(8); } nsDependentString propertyName(aPropertyName); - if (!mPropertyTable->Put(propertyName, aValue)) - return NS_ERROR_OUT_OF_MEMORY; + mPropertyTable->Put(propertyName, aValue); return NS_OK; } diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 3a02709baad..e09596626f0 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -209,9 +209,9 @@ nsTreeBodyFrame::Init(nsIContent* aContent, mIndentation = GetIndentation(); mRowHeight = GetRowHeight(); - NS_ENSURE_TRUE(mCreatedListeners.Init(), NS_ERROR_OUT_OF_MEMORY); + mCreatedListeners.Init(); - NS_ENSURE_TRUE(mImageCache.Init(16), NS_ERROR_OUT_OF_MEMORY); + mImageCache.Init(16); EnsureBoxObject(); return rv; diff --git a/modules/libjar/zipwriter/src/nsZipWriter.cpp b/modules/libjar/zipwriter/src/nsZipWriter.cpp index 08d328e0718..5a6ae8bf7cd 100644 --- a/modules/libjar/zipwriter/src/nsZipWriter.cpp +++ b/modules/libjar/zipwriter/src/nsZipWriter.cpp @@ -234,8 +234,7 @@ nsresult nsZipWriter::ReadFile(nsIFile *aFile) mHeaders.Clear(); return rv; } - if (!mEntryHash.Put(header->mName, mHeaders.Count())) - return NS_ERROR_OUT_OF_MEMORY; + mEntryHash.Put(header->mName, mHeaders.Count()); if (!mHeaders.AppendObject(header)) return NS_ERROR_OUT_OF_MEMORY; } @@ -616,10 +615,7 @@ NS_IMETHODIMP nsZipWriter::RemoveEntry(const nsACString & aZipEntry, mCDSOffset -= shift; PRInt32 pos2 = pos + 1; while (pos2 < mHeaders.Count()) { - if (!mEntryHash.Put(mHeaders[pos2]->mName, pos2-1)) { - Cleanup(); - return NS_ERROR_OUT_OF_MEMORY; - } + mEntryHash.Put(mHeaders[pos2]->mName, pos2-1); mHeaders[pos2]->mOffset -= shift; pos2++; } @@ -804,10 +800,8 @@ nsresult nsZipWriter::InternalAddEntryDirectory(const nsACString & aZipEntry, mCDSDirty = true; mCDSOffset += header->GetFileHeaderLength(); - if (!mEntryHash.Put(header->mName, mHeaders.Count())) { - Cleanup(); - return NS_ERROR_OUT_OF_MEMORY; - } + mEntryHash.Put(header->mName, mHeaders.Count()); + if (!mHeaders.AppendObject(header)) { Cleanup(); return NS_ERROR_OUT_OF_MEMORY; @@ -856,10 +850,7 @@ nsresult nsZipWriter::EntryCompleteCallback(nsZipHeader* aHeader, nsresult aStatus) { if (NS_SUCCEEDED(aStatus)) { - if (!mEntryHash.Put(aHeader->mName, mHeaders.Count())) { - SeekCDS(); - return NS_ERROR_OUT_OF_MEMORY; - } + mEntryHash.Put(aHeader->mName, mHeaders.Count()); if (!mHeaders.AppendObject(aHeader)) { mEntryHash.Remove(aHeader->mName); SeekCDS(); diff --git a/modules/libpref/src/Preferences.cpp b/modules/libpref/src/Preferences.cpp index 00742a88383..cd391267674 100644 --- a/modules/libpref/src/Preferences.cpp +++ b/modules/libpref/src/Preferences.cpp @@ -1438,8 +1438,8 @@ Preferences::RegisterCallback(PrefChangedFunc aCallback, observer->AppendClosure(aClosure); nsresult rv = AddStrongObserver(observer, aPref); NS_ENSURE_SUCCESS(rv, rv); - return gObserverTable->Put(observer, observer) ? NS_OK : - NS_ERROR_OUT_OF_MEMORY; + gObserverTable->Put(observer, observer); + return NS_OK; } // static diff --git a/modules/libpref/src/nsPrefBranch.cpp b/modules/libpref/src/nsPrefBranch.cpp index c623bde3d71..3ec48cdc430 100644 --- a/modules/libpref/src/nsPrefBranch.cpp +++ b/modules/libpref/src/nsPrefBranch.cpp @@ -591,12 +591,7 @@ NS_IMETHODIMP nsPrefBranch::AddObserver(const char *aDomain, nsIObserver *aObser return NS_OK; } - bool putSucceeded = mObservers.Put(pCallback, pCallback); - - if (!putSucceeded) { - delete pCallback; - return NS_ERROR_FAILURE; - } + mObservers.Put(pCallback, pCallback); // We must pass a fully qualified preference name to the callback // aDomain == nsnull is the only possible failure, and we trapped it with diff --git a/netwerk/base/src/nsProtocolProxyService.cpp b/netwerk/base/src/nsProtocolProxyService.cpp index d609ef73184..0dcfa8bc959 100644 --- a/netwerk/base/src/nsProtocolProxyService.cpp +++ b/netwerk/base/src/nsProtocolProxyService.cpp @@ -336,8 +336,7 @@ nsProtocolProxyService::~nsProtocolProxyService() nsresult nsProtocolProxyService::Init() { - if (!mFailedProxies.Init()) - return NS_ERROR_OUT_OF_MEMORY; + mFailedProxies.Init(); // failure to access prefs is non-fatal nsCOMPtr prefBranch = diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.cpp b/netwerk/cache/nsDiskCacheDeviceSQL.cpp index 26ffee305bd..8ca6fd1359b 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp +++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp @@ -1182,16 +1182,15 @@ nsOfflineCacheDevice::Init() nsresult nsOfflineCacheDevice::InitActiveCaches() { - NS_ENSURE_TRUE(mCaches.Init(), NS_ERROR_OUT_OF_MEMORY); - NS_ENSURE_TRUE(mActiveCachesByGroup.Init(), NS_ERROR_OUT_OF_MEMORY); + mCaches.Init(); + mActiveCachesByGroup.Init(); - nsresult rv = mActiveCaches.Init(5); - NS_ENSURE_SUCCESS(rv, rv); + mActiveCaches.Init(5); AutoResetStatement statement(mStatement_EnumerateGroups); bool hasRows; - rv = statement->ExecuteStep(&hasRows); + nsresult rv = statement->ExecuteStep(&hasRows); NS_ENSURE_SUCCESS(rv, rv); while (hasRows) diff --git a/netwerk/dns/nsEffectiveTLDService.cpp b/netwerk/dns/nsEffectiveTLDService.cpp index 8a183e3b32c..d68f9980413 100644 --- a/netwerk/dns/nsEffectiveTLDService.cpp +++ b/netwerk/dns/nsEffectiveTLDService.cpp @@ -72,8 +72,7 @@ nsEffectiveTLDService::Init() // use a perfect hash, but at least we'll save a few rehashes along the way. // Next optimization here is to precompute the hash using something like // gperf, but one step at a time. :-) - if (!mHash.Init(ArrayLength(gEntries) - 1)) - return NS_ERROR_OUT_OF_MEMORY; + mHash.Init(ArrayLength(gEntries) - 1); nsresult rv; mIDNService = do_GetService(NS_IDNSERVICE_CONTRACTID, &rv); diff --git a/netwerk/protocol/res/nsResProtocolHandler.cpp b/netwerk/protocol/res/nsResProtocolHandler.cpp index 239da9e0ce9..2e0c2c8c054 100644 --- a/netwerk/protocol/res/nsResProtocolHandler.cpp +++ b/netwerk/protocol/res/nsResProtocolHandler.cpp @@ -157,8 +157,7 @@ nsResProtocolHandler::~nsResProtocolHandler() nsresult nsResProtocolHandler::Init() { - if (!mSubstitutions.Init(32)) - return NS_ERROR_UNEXPECTED; + mSubstitutions.Init(32); nsresult rv; @@ -362,7 +361,8 @@ nsResProtocolHandler::SetSubstitution(const nsACString& root, nsIURI *baseURI) nsresult rv = baseURI->GetScheme(scheme); NS_ENSURE_SUCCESS(rv, rv); if (!scheme.Equals(NS_LITERAL_CSTRING("resource"))) { - return mSubstitutions.Put(root, baseURI) ? NS_OK : NS_ERROR_UNEXPECTED; + mSubstitutions.Put(root, baseURI); + return NS_OK; } // baseURI is a resource URI, let's resolve it first. @@ -375,7 +375,8 @@ nsResProtocolHandler::SetSubstitution(const nsACString& root, nsIURI *baseURI) getter_AddRefs(newBaseURI)); NS_ENSURE_SUCCESS(rv, rv); - return mSubstitutions.Put(root, newBaseURI) ? NS_OK : NS_ERROR_UNEXPECTED; + mSubstitutions.Put(root, newBaseURI); + return NS_OK; } NS_IMETHODIMP diff --git a/parser/html/nsHtml5AtomTable.h b/parser/html/nsHtml5AtomTable.h index 86453eb3678..ce9ee1a4cd7 100644 --- a/parser/html/nsHtml5AtomTable.h +++ b/parser/html/nsHtml5AtomTable.h @@ -110,11 +110,10 @@ class nsHtml5AtomTable ~nsHtml5AtomTable(); /** - * Must be called after the constructor before use. Returns true - * when successful and false on OOM failure. + * Must be called after the constructor before use. */ - inline bool Init() { - return mTable.Init(); + inline void Init() { + mTable.Init(); } /** diff --git a/parser/html/nsHtml5StringParser.cpp b/parser/html/nsHtml5StringParser.cpp index dcf134f577f..2517072088f 100644 --- a/parser/html/nsHtml5StringParser.cpp +++ b/parser/html/nsHtml5StringParser.cpp @@ -53,7 +53,7 @@ nsHtml5StringParser::nsHtml5StringParser() , mTokenizer(new nsHtml5Tokenizer(mTreeBuilder, false)) { MOZ_COUNT_CTOR(nsHtml5StringParser); - mAtomTable.Init(); // we aren't checking for OOM anyway... + mAtomTable.Init(); mTokenizer->setInterner(&mAtomTable); } diff --git a/rdf/base/src/nsRDFXMLSerializer.cpp b/rdf/base/src/nsRDFXMLSerializer.cpp index 16a95337da4..54957006c6d 100644 --- a/rdf/base/src/nsRDFXMLSerializer.cpp +++ b/rdf/base/src/nsRDFXMLSerializer.cpp @@ -254,7 +254,8 @@ nsRDFXMLSerializer::RegisterQName(nsIRDFResource* aResource) iter->mPrefix->ToUTF8String(qname); qname.Append(':'); qname += StringTail(uri, uri.Length() - iter->mURI.Length()); - return mQNames.Put(aResource, qname) ? NS_OK : NS_ERROR_FAILURE; + mQNames.Put(aResource, qname); + return NS_OK; } // Okay, so we don't have it in our map. Try to make one up. This @@ -265,7 +266,8 @@ nsRDFXMLSerializer::RegisterQName(nsIRDFResource* aResource) if (i == -1) { // Okay, just punt and assume there is _no_ namespace on // this thing... - return mQNames.Put(aResource, uri) ? NS_OK : NS_ERROR_FAILURE; + mQNames.Put(aResource, uri); + return NS_OK; } } @@ -277,7 +279,8 @@ nsRDFXMLSerializer::RegisterQName(nsIRDFResource* aResource) qname.Append(':'); qname += StringTail(uri, uri.Length() - (i + 1)); - return mQNames.Put(aResource, qname) ? NS_OK : NS_ERROR_FAILURE; + mQNames.Put(aResource, qname); + return NS_OK; } nsresult diff --git a/security/manager/boot/src/nsStrictTransportSecurityService.cpp b/security/manager/boot/src/nsStrictTransportSecurityService.cpp index b3abe4ce680..a25fc7d1255 100644 --- a/security/manager/boot/src/nsStrictTransportSecurityService.cpp +++ b/security/manager/boot/src/nsStrictTransportSecurityService.cpp @@ -114,8 +114,8 @@ nsStrictTransportSecurityService::Init() if (mObserverService) mObserverService->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, false); - if (mInPrivateMode && !mPrivateModeHostTable.Init()) - return NS_ERROR_OUT_OF_MEMORY; + if (mInPrivateMode) + mPrivateModeHostTable.Init(); return NS_OK; } @@ -400,9 +400,8 @@ nsStrictTransportSecurityService::Observe(nsISupports *subject, // Indication to start recording stuff locally and not writing changes // out to the permission manager. - if (!mPrivateModeHostTable.IsInitialized() - && !mPrivateModeHostTable.Init()) { - return NS_ERROR_OUT_OF_MEMORY; + if (!mPrivateModeHostTable.IsInitialized()) { + mPrivateModeHostTable.Init(); } mInPrivateMode = true; } diff --git a/security/manager/ssl/src/nsCertOverrideService.cpp b/security/manager/ssl/src/nsCertOverrideService.cpp index b075cda7e0b..041664c17bd 100644 --- a/security/manager/ssl/src/nsCertOverrideService.cpp +++ b/security/manager/ssl/src/nsCertOverrideService.cpp @@ -136,8 +136,7 @@ nsCertOverrideService::Init() return NS_ERROR_NOT_SAME_THREAD; } - if (!mSettingsTable.Init()) - return NS_ERROR_OUT_OF_MEMORY; + mSettingsTable.Init(); mOidTagForStoringNewHashes = SEC_OID_SHA256; diff --git a/security/manager/ssl/src/nsCertTree.cpp b/security/manager/ssl/src/nsCertTree.cpp index d662c3b378f..2d1c36abbe9 100644 --- a/security/manager/ssl/src/nsCertTree.cpp +++ b/security/manager/ssl/src/nsCertTree.cpp @@ -497,8 +497,7 @@ nsCertTree::GetCertsByTypeFromCertList(CERTCertList *aCertList, return NS_ERROR_FAILURE; nsTHashtable allHostPortOverrideKeys; - if (!allHostPortOverrideKeys.Init()) - return NS_ERROR_OUT_OF_MEMORY; + allHostPortOverrideKeys.Init(); if (aWantedType == nsIX509Cert::SERVER_CERT) { mOriginalOverrideService-> diff --git a/security/manager/ssl/src/nsClientAuthRemember.cpp b/security/manager/ssl/src/nsClientAuthRemember.cpp index 63401bfee10..0289d441a63 100644 --- a/security/manager/ssl/src/nsClientAuthRemember.cpp +++ b/security/manager/ssl/src/nsClientAuthRemember.cpp @@ -81,8 +81,7 @@ nsClientAuthRememberService::Init() return NS_ERROR_NOT_SAME_THREAD; } - if (!mSettingsTable.Init()) - return NS_ERROR_OUT_OF_MEMORY; + mSettingsTable.Init(); nsCOMPtr observerService = mozilla::services::GetObserverService(); diff --git a/storage/public/StatementCache.h b/storage/public/StatementCache.h index 1adac7013e1..b59fdd2fd46 100644 --- a/storage/public/StatementCache.h +++ b/storage/public/StatementCache.h @@ -71,9 +71,7 @@ public: StatementCache(nsCOMPtr& aConnection) : mConnection(aConnection) { - if (!mCachedStatements.Init()) { - NS_ERROR("Out of memory!?"); - } + mCachedStatements.Init(); } /** @@ -94,9 +92,7 @@ public: stmt = CreateStatement(aQuery); NS_ENSURE_TRUE(stmt, nsnull); - if (!mCachedStatements.Put(aQuery, stmt)) { - NS_ERROR("Out of memory!?"); - } + mCachedStatements.Put(aQuery, stmt); } return stmt.forget(); } diff --git a/storage/src/mozStorageBindingParams.cpp b/storage/src/mozStorageBindingParams.cpp index d99075b0266..b51b268a127 100644 --- a/storage/src/mozStorageBindingParams.cpp +++ b/storage/src/mozStorageBindingParams.cpp @@ -309,8 +309,7 @@ AsyncBindingParams::BindByName(const nsACString &aName, { NS_ENSURE_FALSE(mLocked, NS_ERROR_UNEXPECTED); - if (!mNamedParameters.Put(aName, aValue)) - return NS_ERROR_OUT_OF_MEMORY; + mNamedParameters.Put(aName, aValue); return NS_OK; } diff --git a/storage/src/mozStorageConnection.cpp b/storage/src/mozStorageConnection.cpp index 2cb583f2532..dd41ef232ad 100644 --- a/storage/src/mozStorageConnection.cpp +++ b/storage/src/mozStorageConnection.cpp @@ -1423,8 +1423,7 @@ Connection::CreateFunction(const nsACString &aFunctionName, FunctionInfo info = { aFunction, Connection::FunctionInfo::SIMPLE, aNumArguments }; - NS_ENSURE_TRUE(mFunctions.Put(aFunctionName, info), - NS_ERROR_OUT_OF_MEMORY); + mFunctions.Put(aFunctionName, info); return NS_OK; } @@ -1459,8 +1458,7 @@ Connection::CreateAggregateFunction(const nsACString &aFunctionName, FunctionInfo info = { aFunction, Connection::FunctionInfo::AGGREGATE, aNumArguments }; - NS_ENSURE_TRUE(mFunctions.Put(aFunctionName, info), - NS_ERROR_OUT_OF_MEMORY); + mFunctions.Put(aFunctionName, info); return NS_OK; } diff --git a/storage/src/mozStorageRow.cpp b/storage/src/mozStorageRow.cpp index 82a5fd58456..3b305ee26c2 100644 --- a/storage/src/mozStorageRow.cpp +++ b/storage/src/mozStorageRow.cpp @@ -54,7 +54,7 @@ nsresult Row::initialize(sqlite3_stmt *aStatement) { // Initialize the hash table - NS_ENSURE_TRUE(mNameHashtable.Init(), NS_ERROR_OUT_OF_MEMORY); + mNameHashtable.Init(); // Get the number of results mNumCols = ::sqlite3_column_count(aStatement); diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index ca78439c1af..dd972fb14f8 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -1938,8 +1938,7 @@ History::RegisterVisitedCallback(nsIURI* aURI, // First, ensure that our hash table is setup. if (!mObservers.IsInitialized()) { - NS_ENSURE_TRUE(mObservers.Init(VISIT_OBSERVERS_INITIAL_CACHE_SIZE), - NS_ERROR_OUT_OF_MEMORY); + mObservers.Init(VISIT_OBSERVERS_INITIAL_CACHE_SIZE); } // Obtain our array of observers for this URI. diff --git a/toolkit/components/places/nsFaviconService.cpp b/toolkit/components/places/nsFaviconService.cpp index faab6ab3d8d..4df8ef962e3 100644 --- a/toolkit/components/places/nsFaviconService.cpp +++ b/toolkit/components/places/nsFaviconService.cpp @@ -140,12 +140,8 @@ nsFaviconService::Init() mDB = Database::GetDatabase(); NS_ENSURE_STATE(mDB); - // Init failed favicon cache. - if (!mFailedFavicons.Init(MAX_FAVICON_CACHE_SIZE)) - return NS_ERROR_OUT_OF_MEMORY; - - if (!mUnassociatedIcons.Init(MAX_UNASSOCIATED_FAVICONS)) - return NS_ERROR_OUT_OF_MEMORY; + mFailedFavicons.Init(MAX_FAVICON_CACHE_SIZE); + mUnassociatedIcons.Init(MAX_UNASSOCIATED_FAVICONS); mOptimizedIconDimension = Preferences::GetInt( "places.favicons.optimizeToDimension", OPTIMIZED_FAVICON_DIMENSION @@ -980,8 +976,7 @@ nsFaviconService::AddFailedFavicon(nsIURI* aFaviconURI) nsresult rv = aFaviconURI->GetSpec(spec); NS_ENSURE_SUCCESS(rv, rv); - if (! mFailedFavicons.Put(spec, mFailedFaviconSerial)) - return NS_ERROR_OUT_OF_MEMORY; + mFailedFavicons.Put(spec, mFailedFaviconSerial); mFailedFaviconSerial ++; if (mFailedFavicons.Count() > MAX_FAVICON_CACHE_SIZE) { diff --git a/toolkit/components/places/nsNavBookmarks.cpp b/toolkit/components/places/nsNavBookmarks.cpp index 011b1063d51..e1a8d8afe8f 100644 --- a/toolkit/components/places/nsNavBookmarks.cpp +++ b/toolkit/components/places/nsNavBookmarks.cpp @@ -2677,8 +2677,7 @@ nsNavBookmarks::EnsureKeywordsHash() { rv = stmt->GetString(1, keyword); NS_ENSURE_SUCCESS(rv, rv); - rv = mBookmarkToKeywordHash.Put(itemId, keyword); - NS_ENSURE_SUCCESS(rv, rv); + mBookmarkToKeywordHash.Put(itemId, keyword); } return NS_OK; diff --git a/toolkit/components/places/nsNavHistory.cpp b/toolkit/components/places/nsNavHistory.cpp index 29a55b54d96..2a27bde9e93 100644 --- a/toolkit/components/places/nsNavHistory.cpp +++ b/toolkit/components/places/nsNavHistory.cpp @@ -341,16 +341,12 @@ nsNavHistory::Init() NS_ENSURE_STATE(mDB); // recent events hash tables - NS_ENSURE_TRUE(mRecentTyped.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE), - NS_ERROR_OUT_OF_MEMORY); - NS_ENSURE_TRUE(mRecentLink.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE), - NS_ERROR_OUT_OF_MEMORY); - NS_ENSURE_TRUE(mRecentBookmark.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE), - NS_ERROR_OUT_OF_MEMORY); + mRecentTyped.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE); + mRecentLink.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE); + mRecentBookmark.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE); // Embed visits hash table. - NS_ENSURE_TRUE(mEmbedVisits.Init(EMBED_VISITS_INITIAL_CACHE_SIZE), - NS_ERROR_OUT_OF_MEMORY); + mEmbedVisits.Init(EMBED_VISITS_INITIAL_CACHE_SIZE); /***************************************************************************** *** IMPORTANT NOTICE! diff --git a/toolkit/components/places/nsNavHistoryResult.cpp b/toolkit/components/places/nsNavHistoryResult.cpp index 9cf1eb11d05..d072a250354 100644 --- a/toolkit/components/places/nsNavHistoryResult.cpp +++ b/toolkit/components/places/nsNavHistoryResult.cpp @@ -4347,8 +4347,7 @@ nsNavHistoryResult::Init(nsINavHistoryQuery** aQueries, rv = aOptions->GetSortingAnnotation(mSortingAnnotation); NS_ENSURE_SUCCESS(rv, rv); - if (!mBookmarkFolderObservers.Init(128)) - return NS_ERROR_OUT_OF_MEMORY; + mBookmarkFolderObservers.Init(128); NS_ASSERTION(mRootNode->mIndentLevel == -1, "Root node's indent level initialized wrong"); diff --git a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp index 064ec6d535b..51cfb0d4596 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp @@ -4397,9 +4397,7 @@ nsUrlClassifierDBService::SetHashCompleter(const nsACString &tableName, nsIUrlClassifierHashCompleter *completer) { if (completer) { - if (!mCompleters.Put(tableName, completer)) { - return NS_ERROR_OUT_OF_MEMORY; - } + mCompleters.Put(tableName, completer); } else { mCompleters.Remove(tableName); } diff --git a/toolkit/crashreporter/nsExceptionHandler.cpp b/toolkit/crashreporter/nsExceptionHandler.cpp index 09a8a2c1dd3..0b01e9ed241 100644 --- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -697,8 +697,7 @@ nsresult SetExceptionHandler(nsILocalFile* aXREDirectory, new nsDataHashtable(); NS_ENSURE_TRUE(crashReporterAPIData_Hash, NS_ERROR_OUT_OF_MEMORY); - rv = crashReporterAPIData_Hash->Init(); - NS_ENSURE_SUCCESS(rv, rv); + crashReporterAPIData_Hash->Init(); notesField = new nsCString(); NS_ENSURE_TRUE(notesField, NS_ERROR_OUT_OF_MEMORY); @@ -1287,8 +1286,7 @@ nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data) MutexAutoLock lock(*crashReporterAPILock); - rv = crashReporterAPIData_Hash->Put(key, escapedData); - NS_ENSURE_SUCCESS(rv, rv); + crashReporterAPIData_Hash->Put(key, escapedData); // now rebuild the file contents crashReporterAPIData->Truncate(0); diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp index 678f7d99648..8b774090df1 100644 --- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -776,7 +776,8 @@ nsresult nsAppShell::AddObserver(const nsAString &aObserverKey, nsIObserver *aObserver) { NS_ASSERTION(aObserver != nsnull, "nsAppShell::AddObserver: aObserver is null!"); - return mObserversHash.Put(aObserverKey, aObserver) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; + mObserversHash.Put(aObserverKey, aObserver); + return NS_OK; } /** diff --git a/xpcom/components/nsCategoryManager.cpp b/xpcom/components/nsCategoryManager.cpp index 98959150c71..a6ce4a99832 100644 --- a/xpcom/components/nsCategoryManager.cpp +++ b/xpcom/components/nsCategoryManager.cpp @@ -242,11 +242,7 @@ CategoryNode::Create(PLArenaPool* aArena) if (!node) return nsnull; - if (!node->mTable.Init()) { - delete node; - return nsnull; - } - + node->mTable.Init(); return node; } diff --git a/xpcom/components/nsNativeComponentLoader.cpp b/xpcom/components/nsNativeComponentLoader.cpp index b8c0b7abdd7..682fd799f93 100644 --- a/xpcom/components/nsNativeComponentLoader.cpp +++ b/xpcom/components/nsNativeComponentLoader.cpp @@ -105,8 +105,8 @@ nsNativeModuleLoader::Init() NS_ASSERTION(NS_IsMainThread(), "Startup not on main thread?"); LOG(PR_LOG_DEBUG, ("nsNativeModuleLoader::Init()")); - - return mLibraries.Init() ? NS_OK : NS_ERROR_OUT_OF_MEMORY; + mLibraries.Init(); + return NS_OK; } class LoadModuleMainThreadRunnable : public nsRunnable diff --git a/xpcom/ds/nsAtomTable.cpp b/xpcom/ds/nsAtomTable.cpp index 93b1d2c702f..09a77c46002 100644 --- a/xpcom/ds/nsAtomTable.cpp +++ b/xpcom/ds/nsAtomTable.cpp @@ -560,11 +560,12 @@ RegisterStaticAtoms(const nsStaticAtom* aAtoms, PRUint32 aAtomCount) if (!gStaticAtomTable && !gStaticAtomTableSealed) { gStaticAtomTable = new nsDataHashtable(); - if (!gStaticAtomTable || !gStaticAtomTable->Init()) { + if (!gStaticAtomTable) { delete gStaticAtomTable; gStaticAtomTable = nsnull; return NS_ERROR_OUT_OF_MEMORY; } + gStaticAtomTable->Init(); } for (PRUint32 i=0; i::Put(const KeyType aVal) if (!table) { return NS_ERROR_OUT_OF_MEMORY; } - if (!table->Init()) { - return NS_ERROR_FAILURE; - } + table->Init(); EntryType *entry = GetSingleEntry(); - if (!table->PutEntry(entry->GetKey())) { - return NS_ERROR_OUT_OF_MEMORY; - } + table->PutEntry(entry->GetKey()); entry->~EntryType(); mUnion.table = table; mState = MANY; } // Fall through. case MANY: - if (!mUnion.table->PutEntry(aVal)) { - return NS_ERROR_OUT_OF_MEMORY; - } + mUnion.table->PutEntry(aVal); return NS_OK; default: NS_NOTREACHED("bogus state"); diff --git a/xpcom/ds/nsHashPropertyBag.cpp b/xpcom/ds/nsHashPropertyBag.cpp index 9f863548911..2c9044a8e12 100644 --- a/xpcom/ds/nsHashPropertyBag.cpp +++ b/xpcom/ds/nsHashPropertyBag.cpp @@ -81,9 +81,7 @@ NS_INTERFACE_MAP_END nsresult nsHashPropertyBag::Init() { - // we can only assume that Init will fail only due to OOM. - if (!mPropertyHash.Init()) - return NS_ERROR_OUT_OF_MEMORY; + mPropertyHash.Init(); return NS_OK; } @@ -119,9 +117,7 @@ nsHashPropertyBag::SetProperty(const nsAString& name, nsIVariant *value) { NS_ENSURE_ARG_POINTER(value); - bool success = mPropertyHash.Put(name, value); - if (!success) - return NS_ERROR_FAILURE; + mPropertyHash.Put(name, value); return NS_OK; } diff --git a/xpcom/ds/nsProperties.cpp b/xpcom/ds/nsProperties.cpp index 75c25066e67..72cdddfa3d0 100644 --- a/xpcom/ds/nsProperties.cpp +++ b/xpcom/ds/nsProperties.cpp @@ -62,8 +62,8 @@ NS_IMETHODIMP nsProperties::Set(const char* prop, nsISupports* value) { NS_ENSURE_ARG(prop); - - return Put(prop, value) ? NS_OK : NS_ERROR_FAILURE; + Put(prop, value); + return NS_OK; } NS_IMETHODIMP diff --git a/xpcom/ds/nsProperties.h b/xpcom/ds/nsProperties.h index 3bc560eb703..a17585a8fd2 100644 --- a/xpcom/ds/nsProperties.h +++ b/xpcom/ds/nsProperties.h @@ -65,6 +65,7 @@ public: NS_DECL_NSIPROPERTIES nsProperties(nsISupports *aOuter) { NS_INIT_AGGREGATED(aOuter); } + nsresult Init() { nsProperties_HashBase::Init(); return NS_OK; } private: ~nsProperties() { } diff --git a/xpcom/glue/nsBaseHashtable.h b/xpcom/glue/nsBaseHashtable.h index e26500cb266..79119d792ab 100644 --- a/xpcom/glue/nsBaseHashtable.h +++ b/xpcom/glue/nsBaseHashtable.h @@ -458,8 +458,8 @@ template void nsBaseHashtableMT::Init(PRUint32 initSize) { - if (!nsTHashtable::IsInitialized() && !nsTHashtable::Init(initSize)) - NS_RUNTIMEABORT("OOM"); + if (!nsTHashtable::IsInitialized()) + nsTHashtable::Init(initSize); this->mLock = PR_NewLock(); if (!this->mLock) @@ -496,12 +496,8 @@ nsBaseHashtableMT::Put(KeyType aKey, UserDataType aData) { PR_Lock(this->mLock); - bool res = - nsBaseHashtable::Put(aKey, aData); + nsBaseHashtable::Put(aKey, aData); PR_Unlock(this->mLock); - - if (!res) - NS_RUNTIMEABORT("OOM"); } template diff --git a/xpcom/glue/nsCategoryCache.cpp b/xpcom/glue/nsCategoryCache.cpp index 4c7dadd2669..5632faf3f27 100644 --- a/xpcom/glue/nsCategoryCache.cpp +++ b/xpcom/glue/nsCategoryCache.cpp @@ -47,11 +47,7 @@ nsCategoryObserver::nsCategoryObserver(const char* aCategory, nsCategoryListener* aListener) : mListener(nsnull), mCategory(aCategory), mObserversRemoved(false) { - if (!mHash.Init()) { - // OOM - return; - } - + mHash.Init(); mListener = aListener; // First, enumerate the currently existing entries diff --git a/xpcom/glue/nsINIParser.cpp b/xpcom/glue/nsINIParser.cpp index 6db34112afa..3bb0113f760 100644 --- a/xpcom/glue/nsINIParser.cpp +++ b/xpcom/glue/nsINIParser.cpp @@ -133,8 +133,7 @@ static const char kRBracket[] = "]"; nsresult nsINIParser::InitFromFILE(FILE *fd) { - if (!mSections.Init()) - return NS_ERROR_OUT_OF_MEMORY; + mSections.Init(); /* get file size */ if (fseek(fd, 0, SEEK_END) != 0) diff --git a/xpcom/tests/TestHashtables.cpp b/xpcom/tests/TestHashtables.cpp index 1d0c30ad150..6b466e4b233 100644 --- a/xpcom/tests/TestHashtables.cpp +++ b/xpcom/tests/TestHashtables.cpp @@ -407,10 +407,7 @@ main(void) { nsTHashtable EntityToUnicode; printf("Initializing nsTHashtable..."); - if (!EntityToUnicode.Init(ENTITY_COUNT)) { - printf("FAILED\n"); - exit (1); - } + EntityToUnicode.Init(ENTITY_COUNT); printf("OK\n"); printf("Partially filling nsTHashtable:\n"); @@ -454,10 +451,7 @@ main(void) { nsDataHashtable UniToEntity; printf("Initializing nsDataHashtable..."); - if (!UniToEntity.Init(ENTITY_COUNT)) { - printf("FAILED\n"); - exit (10); - } + UniToEntity.Init(ENTITY_COUNT); printf("OK\n"); printf("Filling hash with %u entries.\n", ENTITY_COUNT); @@ -465,10 +459,7 @@ main(void) { PRUint32 i; for (i = 0; i < ENTITY_COUNT; ++i) { printf(" Putting entry %u...", gEntities[i].mUnicode); - if (!UniToEntity.Put(gEntities[i].mUnicode, gEntities[i].mStr)) { - printf("FAILED\n"); - exit (11); - } + UniToEntity.Put(gEntities[i].mUnicode, gEntities[i].mStr); printf("OK...\n"); } @@ -521,20 +512,14 @@ main(void) { nsDataHashtableMT UniToEntityL; printf("Initializing nsDataHashtableMT..."); - if (!UniToEntityL.Init(ENTITY_COUNT)) { - printf("FAILED\n"); - exit (10); - } + UniToEntityL.Init(ENTITY_COUNT); printf("OK\n"); printf("Filling hash with %u entries.\n", ENTITY_COUNT); for (i = 0; i < ENTITY_COUNT; ++i) { printf(" Putting entry %u...", gEntities[i].mUnicode); - if (!UniToEntityL.Put(gEntities[i].mUnicode, gEntities[i].mStr)) { - printf("FAILED\n"); - exit (11); - } + UniToEntityL.Put(gEntities[i].mUnicode, gEntities[i].mStr); printf("OK...\n"); } @@ -586,10 +571,7 @@ main(void) { nsClassHashtable EntToUniClass; printf("Initializing nsClassHashtable..."); - if (!EntToUniClass.Init(ENTITY_COUNT)) { - printf("FAILED\n"); - exit (16); - } + EntToUniClass.Init(ENTITY_COUNT); printf("OK\n"); printf("Filling hash with %u entries.\n", ENTITY_COUNT); @@ -598,11 +580,7 @@ main(void) { printf(" Putting entry %u...", gEntities[i].mUnicode); TestUniChar* temp = new TestUniChar(gEntities[i].mUnicode); - if (!EntToUniClass.Put(nsDependentCString(gEntities[i].mStr), temp)) { - printf("FAILED\n"); - delete temp; - exit (17); - } + EntToUniClass.Put(nsDependentCString(gEntities[i].mStr), temp); printf("OK...\n"); } @@ -655,10 +633,7 @@ main(void) { nsClassHashtableMT EntToUniClassL; printf("Initializing nsClassHashtableMT..."); - if (!EntToUniClassL.Init(ENTITY_COUNT)) { - printf("FAILED\n"); - exit (16); - } + EntToUniClassL.Init(ENTITY_COUNT); printf("OK\n"); printf("Filling hash with %u entries.\n", ENTITY_COUNT); @@ -667,11 +642,7 @@ main(void) { printf(" Putting entry %u...", gEntities[i].mUnicode); TestUniChar* temp = new TestUniChar(gEntities[i].mUnicode); - if (!EntToUniClassL.Put(nsDependentCString(gEntities[i].mStr), temp)) { - printf("FAILED\n"); - delete temp; - exit (17); - } + EntToUniClassL.Put(nsDependentCString(gEntities[i].mStr), temp); printf("OK...\n"); } @@ -723,10 +694,7 @@ main(void) { nsDataHashtable EntToUniClass2; printf("Initializing nsDataHashtable with interface key..."); - if (!EntToUniClass2.Init(ENTITY_COUNT)) { - printf("FAILED\n"); - exit (22); - } + EntToUniClass2.Init(ENTITY_COUNT); printf("OK\n"); printf("Filling hash with %u entries.\n", ENTITY_COUNT); @@ -742,10 +710,7 @@ main(void) { fooArray.InsertObjectAt(foo, i); - if (!EntToUniClass2.Put(foo, gEntities[i].mUnicode)) { - printf("FAILED\n"); - exit (23); - } + EntToUniClass2.Put(foo, gEntities[i].mUnicode); printf("OK...\n"); } @@ -799,10 +764,7 @@ main(void) { nsInterfaceHashtable UniToEntClass2; printf("Initializing nsInterfaceHashtable..."); - if (!UniToEntClass2.Init(ENTITY_COUNT)) { - printf("FAILED\n"); - exit (28); - } + UniToEntClass2.Init(ENTITY_COUNT); printf("OK\n"); printf("Filling hash with %u entries.\n", ENTITY_COUNT); @@ -813,10 +775,7 @@ main(void) { CreateIFoo(getter_AddRefs(foo)); foo->SetString(nsDependentCString(gEntities[i].mStr)); - if (!UniToEntClass2.Put(gEntities[i].mUnicode, foo)) { - printf("FAILED\n"); - exit (29); - } + UniToEntClass2.Put(gEntities[i].mUnicode, foo); printf("OK...\n"); } @@ -873,10 +832,7 @@ main(void) { nsInterfaceHashtableMT UniToEntClass2L; printf("Initializing nsInterfaceHashtableMT..."); - if (!UniToEntClass2L.Init(ENTITY_COUNT)) { - printf("FAILED\n"); - exit (28); - } + UniToEntClass2L.Init(ENTITY_COUNT); printf("OK\n"); printf("Filling hash with %u entries.\n", ENTITY_COUNT); @@ -887,10 +843,7 @@ main(void) { CreateIFoo(getter_AddRefs(foo)); foo->SetString(nsDependentCString(gEntities[i].mStr)); - if (!UniToEntClass2L.Put(gEntities[i].mUnicode, foo)) { - printf("FAILED\n"); - exit (29); - } + UniToEntClass2L.Put(gEntities[i].mUnicode, foo); printf("OK...\n"); } diff --git a/xpcom/threads/nsEnvironment.cpp b/xpcom/threads/nsEnvironment.cpp index 1a4fbea9db9..89a4dd91c9b 100644 --- a/xpcom/threads/nsEnvironment.cpp +++ b/xpcom/threads/nsEnvironment.cpp @@ -145,12 +145,8 @@ EnsureEnvHash() if (!gEnvHash) return false; - if(gEnvHash->Init()) - return true; - - delete gEnvHash; - gEnvHash = nsnull; - return false; + gEnvHash->Init(); + return true; } NS_IMETHODIMP diff --git a/xpcom/threads/nsThreadManager.cpp b/xpcom/threads/nsThreadManager.cpp index c2fed777d62..19b7ee0a99f 100644 --- a/xpcom/threads/nsThreadManager.cpp +++ b/xpcom/threads/nsThreadManager.cpp @@ -89,8 +89,7 @@ NS_IMPL_CI_INTERFACE_GETTER1(nsThreadManager, nsIThreadManager) nsresult nsThreadManager::Init() { - if (!mThreadsByPRThread.Init()) - return NS_ERROR_OUT_OF_MEMORY; + mThreadsByPRThread.Init(); if (PR_NewThreadPrivateIndex(&mCurThreadIndex, ReleaseObject) == PR_FAILURE) return NS_ERROR_FAILURE;