Bug 1050035 (part 2) - Remove the fallible version of PL_DHashTableInit(). r=froydnj,mrbkap.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 01 Feb 2015 20:19:08 -0800
changeset 256382 df3fcd2be8fda0166301cab6d83087b24e1e9124
parent 256381 0a436bce77a6695f0b5a600b726cd3693c000213
child 256383 66dfe37b8532cd188b528527e06086f3126d1259
push idunknown
push userunknown
push dateunknown
reviewersfroydnj, mrbkap
bugs1050035
milestone38.0a1
Bug 1050035 (part 2) - Remove the fallible version of PL_DHashTableInit(). r=froydnj,mrbkap. Because it's no longer needed now that entry storage isn't allocated there. (The other possible causes of failures are much less interesting and simply crashing is a reasonable thing to do for them.) This also makes PL_DNewHashTable() infallible.
dom/base/nsDocument.cpp
dom/base/nsScriptNameSpaceManager.cpp
dom/base/nsScriptNameSpaceManager.h
dom/xul/XULDocument.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/XPCMaps.cpp
js/xpconnect/src/XPCMaps.h
layout/style/nsRuleNode.cpp
modules/libpref/Preferences.cpp
modules/libpref/prefapi.cpp
modules/libpref/prefapi.h
netwerk/cache/nsCacheEntry.cpp
netwerk/cache/nsCacheEntry.h
netwerk/cache/nsCacheService.cpp
netwerk/cache/nsMemoryCacheDevice.cpp
netwerk/protocol/http/nsHttp.cpp
parser/htmlparser/nsHTMLEntities.cpp
security/manager/ssl/src/nsCertTree.cpp
security/manager/ssl/src/nsCertTree.h
xpcom/ds/nsStaticNameTable.cpp
xpcom/glue/pldhash.cpp
xpcom/glue/pldhash.h
xpcom/tests/TestPLDHash.cpp
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -3980,19 +3980,16 @@ nsDocument::SetSubDocumentFor(Element* a
         PL_DHashVoidPtrKeyStub,
         PL_DHashMatchEntryStub,
         PL_DHashMoveEntryStub,
         SubDocClearEntry,
         SubDocInitEntry
       };
 
       mSubDocuments = PL_NewDHashTable(&hash_table_ops, sizeof(SubDocMapEntry));
-      if (!mSubDocuments) {
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
     }
 
     // Add a mapping to the hash table
     SubDocMapEntry *entry =
       static_cast<SubDocMapEntry*>
                  (PL_DHashTableAdd(mSubDocuments, aElement));
 
     if (!entry) {
--- a/dom/base/nsScriptNameSpaceManager.cpp
+++ b/dom/base/nsScriptNameSpaceManager.cpp
@@ -117,29 +117,26 @@ GlobalNameHashInitEntry(PLDHashTable *ta
 
 NS_IMPL_ISUPPORTS(
   nsScriptNameSpaceManager,
   nsIObserver,
   nsISupportsWeakReference,
   nsIMemoryReporter)
 
 nsScriptNameSpaceManager::nsScriptNameSpaceManager()
-  : mIsInitialized(false)
 {
   MOZ_COUNT_CTOR(nsScriptNameSpaceManager);
 }
 
 nsScriptNameSpaceManager::~nsScriptNameSpaceManager()
 {
-  if (mIsInitialized) {
-    UnregisterWeakMemoryReporter(this);
-    // Destroy the hash
-    PL_DHashTableFinish(&mGlobalNames);
-    PL_DHashTableFinish(&mNavigatorNames);
-  }
+  UnregisterWeakMemoryReporter(this);
+  // Destroy the hash
+  PL_DHashTableFinish(&mGlobalNames);
+  PL_DHashTableFinish(&mNavigatorNames);
   MOZ_COUNT_DTOR(nsScriptNameSpaceManager);
 }
 
 nsGlobalNameStruct *
 nsScriptNameSpaceManager::AddToHash(PLDHashTable *aTable, const nsAString *aKey,
                                     const char16_t **aClassName)
 {
   GlobalNameMapEntry *entry =
@@ -321,31 +318,23 @@ nsScriptNameSpaceManager::Init()
   {
     GlobalNameHashHashKey,
     GlobalNameHashMatchEntry,
     PL_DHashMoveEntryStub,
     GlobalNameHashClearEntry,
     GlobalNameHashInitEntry
   };
 
-  mIsInitialized = PL_DHashTableInit(&mGlobalNames, &hash_table_ops,
-                                     sizeof(GlobalNameMapEntry),
-                                     fallible,
-                                     GLOBALNAME_HASHTABLE_INITIAL_LENGTH);
-  NS_ENSURE_TRUE(mIsInitialized, NS_ERROR_OUT_OF_MEMORY);
+  PL_DHashTableInit(&mGlobalNames, &hash_table_ops,
+                    sizeof(GlobalNameMapEntry),
+                    GLOBALNAME_HASHTABLE_INITIAL_LENGTH);
 
-  mIsInitialized = PL_DHashTableInit(&mNavigatorNames, &hash_table_ops,
-                                     sizeof(GlobalNameMapEntry),
-                                     fallible,
-                                     GLOBALNAME_HASHTABLE_INITIAL_LENGTH);
-  if (!mIsInitialized) {
-    PL_DHashTableFinish(&mGlobalNames);
-
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
+  PL_DHashTableInit(&mNavigatorNames, &hash_table_ops,
+                    sizeof(GlobalNameMapEntry),
+                    GLOBALNAME_HASHTABLE_INITIAL_LENGTH);
 
   RegisterWeakMemoryReporter(this);
 
   nsresult rv = NS_OK;
 
   rv = RegisterExternalInterfaces(false);
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/dom/base/nsScriptNameSpaceManager.h
+++ b/dom/base/nsScriptNameSpaceManager.h
@@ -235,13 +235,11 @@ private:
                                     nsISupports* aEntry,
                                     bool aRemove);
 
   nsGlobalNameStruct* LookupNameInternal(const nsAString& aName,
                                          const char16_t **aClassName = nullptr);
 
   PLDHashTable mGlobalNames;
   PLDHashTable mNavigatorNames;
-
-  bool mIsInitialized;
 };
 
 #endif /* nsScriptNameSpaceManager_h__ */
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -764,21 +764,16 @@ XULDocument::AddBroadcastListenerFor(Ele
         PL_DHashMatchEntryStub,
         PL_DHashMoveEntryStub,
         ClearBroadcasterMapEntry,
         nullptr
     };
 
     if (! mBroadcasterMap) {
         mBroadcasterMap = PL_NewDHashTable(&gOps, sizeof(BroadcasterMapEntry));
-
-        if (! mBroadcasterMap) {
-            aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
-            return;
-        }
     }
 
     BroadcasterMapEntry* entry =
         static_cast<BroadcasterMapEntry*>
                    (PL_DHashTableSearch(mBroadcasterMap, &aBroadcaster));
 
     if (!entry) {
         entry =
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -1531,19 +1531,18 @@ DetachedWrappedNativeProtoShutdownMarker
 void XPCJSRuntime::DestroyJSContextStack()
 {
     delete mJSContextStack;
     mJSContextStack = nullptr;
 }
 
 void XPCJSRuntime::SystemIsBeingShutDown()
 {
-    if (mDetachedWrappedNativeProtoMap)
-        mDetachedWrappedNativeProtoMap->
-            Enumerate(DetachedWrappedNativeProtoShutdownMarker, nullptr);
+    mDetachedWrappedNativeProtoMap->
+        Enumerate(DetachedWrappedNativeProtoShutdownMarker, nullptr);
 }
 
 #define JS_OPTIONS_DOT_STR "javascript.options."
 
 static void
 ReloadPrefsCallback(const char *pref, void *data)
 {
     XPCJSRuntime *runtime = reinterpret_cast<XPCJSRuntime *>(data);
@@ -1615,61 +1614,43 @@ XPCJSRuntime::~XPCJSRuntime()
     if (mCallContext)
         mCallContext->SystemIsBeingShutDown();
 
     auto rtPrivate = static_cast<PerThreadAtomCache*>(JS_GetRuntimePrivate(Runtime()));
     delete rtPrivate;
     JS_SetRuntimePrivate(Runtime(), nullptr);
 
     // clean up and destroy maps...
-    if (mWrappedJSMap) {
-        mWrappedJSMap->ShutdownMarker();
-        delete mWrappedJSMap;
-        mWrappedJSMap = nullptr;
-    }
-
-    if (mWrappedJSClassMap) {
-        delete mWrappedJSClassMap;
-        mWrappedJSClassMap = nullptr;
-    }
-
-    if (mIID2NativeInterfaceMap) {
-        delete mIID2NativeInterfaceMap;
-        mIID2NativeInterfaceMap = nullptr;
-    }
-
-    if (mClassInfo2NativeSetMap) {
-        delete mClassInfo2NativeSetMap;
-        mClassInfo2NativeSetMap = nullptr;
-    }
-
-    if (mNativeSetMap) {
-        delete mNativeSetMap;
-        mNativeSetMap = nullptr;
-    }
-
-    if (mThisTranslatorMap) {
-        delete mThisTranslatorMap;
-        mThisTranslatorMap = nullptr;
-    }
-
-    if (mNativeScriptableSharedMap) {
-        delete mNativeScriptableSharedMap;
-        mNativeScriptableSharedMap = nullptr;
-    }
-
-    if (mDyingWrappedNativeProtoMap) {
-        delete mDyingWrappedNativeProtoMap;
-        mDyingWrappedNativeProtoMap = nullptr;
-    }
-
-    if (mDetachedWrappedNativeProtoMap) {
-        delete mDetachedWrappedNativeProtoMap;
-        mDetachedWrappedNativeProtoMap = nullptr;
-    }
+    mWrappedJSMap->ShutdownMarker();
+    delete mWrappedJSMap;
+    mWrappedJSMap = nullptr;
+
+    delete mWrappedJSClassMap;
+    mWrappedJSClassMap = nullptr;
+
+    delete mIID2NativeInterfaceMap;
+    mIID2NativeInterfaceMap = nullptr;
+
+    delete mClassInfo2NativeSetMap;
+    mClassInfo2NativeSetMap = nullptr;
+
+    delete mNativeSetMap;
+    mNativeSetMap = nullptr;
+
+    delete mThisTranslatorMap;
+    mThisTranslatorMap = nullptr;
+
+    delete mNativeScriptableSharedMap;
+    mNativeScriptableSharedMap = nullptr;
+
+    delete mDyingWrappedNativeProtoMap;
+    mDyingWrappedNativeProtoMap = nullptr;
+
+    delete mDetachedWrappedNativeProtoMap;
+    mDetachedWrappedNativeProtoMap = nullptr;
 
 #ifdef MOZ_ENABLE_PROFILER_SPS
     // Tell the profiler that the runtime is gone
     if (PseudoStack *stack = mozilla_get_pseudo_stack())
         stack->sampleRuntime(nullptr);
 #endif
 
     Preferences::UnregisterCallback(ReloadPrefsCallback, JS_OPTIONS_DOT_STR, this);
@@ -3509,52 +3490,48 @@ XPCJSRuntime::DebugDump(int16_t depth)
         while (JS_ContextIterator(Runtime(), &iter)) {
             XPCContext *xpc = XPCContext::GetXPCContext(iter);
             XPC_LOG_INDENT();
             xpc->DebugDump(depth);
             XPC_LOG_OUTDENT();
         }
 
         XPC_LOG_ALWAYS(("mWrappedJSClassMap @ %x with %d wrapperclasses(s)",  \
-                        mWrappedJSClassMap, mWrappedJSClassMap ?              \
-                        mWrappedJSClassMap->Count() : 0));
+                        mWrappedJSClassMap, mWrappedJSClassMap->Count()));
         // iterate wrappersclasses...
-        if (depth && mWrappedJSClassMap && mWrappedJSClassMap->Count()) {
+        if (depth && mWrappedJSClassMap->Count()) {
             XPC_LOG_INDENT();
             mWrappedJSClassMap->Enumerate(WrappedJSClassMapDumpEnumerator, &depth);
             XPC_LOG_OUTDENT();
         }
         XPC_LOG_ALWAYS(("mWrappedJSMap @ %x with %d wrappers(s)",             \
-                        mWrappedJSMap, mWrappedJSMap ?                        \
-                        mWrappedJSMap->Count() : 0));
+                        mWrappedJSMap, mWrappedJSMap->Count()));
         // iterate wrappers...
-        if (depth && mWrappedJSMap && mWrappedJSMap->Count()) {
+        if (depth && mWrappedJSMap->Count()) {
             XPC_LOG_INDENT();
             mWrappedJSMap->Dump(depth);
             XPC_LOG_OUTDENT();
         }
 
         XPC_LOG_ALWAYS(("mIID2NativeInterfaceMap @ %x with %d interface(s)",  \
-                        mIID2NativeInterfaceMap, mIID2NativeInterfaceMap ?    \
-                        mIID2NativeInterfaceMap->Count() : 0));
+                        mIID2NativeInterfaceMap,
+                        mIID2NativeInterfaceMap->Count()));
 
         XPC_LOG_ALWAYS(("mClassInfo2NativeSetMap @ %x with %d sets(s)",       \
-                        mClassInfo2NativeSetMap, mClassInfo2NativeSetMap ?    \
-                        mClassInfo2NativeSetMap->Count() : 0));
+                        mClassInfo2NativeSetMap,                              \
+                        mClassInfo2NativeSetMap->Count()));
 
         XPC_LOG_ALWAYS(("mThisTranslatorMap @ %x with %d translator(s)",      \
-                        mThisTranslatorMap, mThisTranslatorMap ?              \
-                        mThisTranslatorMap->Count() : 0));
+                        mThisTranslatorMap, mThisTranslatorMap->Count()));
 
         XPC_LOG_ALWAYS(("mNativeSetMap @ %x with %d sets(s)",                 \
-                        mNativeSetMap, mNativeSetMap ?                        \
-                        mNativeSetMap->Count() : 0));
+                        mNativeSetMap, mNativeSetMap->Count()));
 
         // iterate sets...
-        if (depth && mNativeSetMap && mNativeSetMap->Count()) {
+        if (depth && mNativeSetMap->Count()) {
             XPC_LOG_INDENT();
             mNativeSetMap->Enumerate(NativeSetDumpEnumerator, &depth);
             XPC_LOG_OUTDENT();
         }
 
         XPC_LOG_OUTDENT();
 #endif
 }
--- a/js/xpconnect/src/XPCMaps.cpp
+++ b/js/xpconnect/src/XPCMaps.cpp
@@ -164,44 +164,35 @@ JSObject2WrappedJSMap::SizeOfWrappedJS(m
 
 /***************************************************************************/
 // implement Native2WrappedNativeMap...
 
 // static
 Native2WrappedNativeMap*
 Native2WrappedNativeMap::newMap(int length)
 {
-    Native2WrappedNativeMap* map = new Native2WrappedNativeMap(length);
-    if (map && map->mTable)
-        return map;
-    // Allocation of the map or the creation of its hash table has
-    // failed. This will cause a nullptr deref later when we attempt
-    // to use the map, so we abort immediately to provide a more
-    // useful crash stack.
-    NS_RUNTIMEABORT("Ran out of memory.");
-    return nullptr;
+    return new Native2WrappedNativeMap(length);
 }
 
 Native2WrappedNativeMap::Native2WrappedNativeMap(int length)
 {
     mTable = PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
 }
 
 Native2WrappedNativeMap::~Native2WrappedNativeMap()
 {
-    if (mTable)
-        PL_DHashTableDestroy(mTable);
+    PL_DHashTableDestroy(mTable);
 }
 
 size_t
 Native2WrappedNativeMap::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf)
 {
     size_t n = 0;
     n += mallocSizeOf(this);
-    n += mTable ? PL_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
+    n += PL_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf);
     return n;
 }
 
 /* static */ size_t
 Native2WrappedNativeMap::SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr,
                                                   mozilla::MallocSizeOf mallocSizeOf, void *)
 {
     return mallocSizeOf(((Native2WrappedNativeMap::Entry*)hdr)->value);
@@ -217,32 +208,27 @@ const struct PLDHashTableOps IID2Wrapped
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub
 };
 
 // static
 IID2WrappedJSClassMap*
 IID2WrappedJSClassMap::newMap(int length)
 {
-    IID2WrappedJSClassMap* map = new IID2WrappedJSClassMap(length);
-    if (map && map->mTable)
-        return map;
-    delete map;
-    return nullptr;
+    return new IID2WrappedJSClassMap(length);
 }
 
 IID2WrappedJSClassMap::IID2WrappedJSClassMap(int length)
 {
     mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
 }
 
 IID2WrappedJSClassMap::~IID2WrappedJSClassMap()
 {
-    if (mTable)
-        PL_DHashTableDestroy(mTable);
+    PL_DHashTableDestroy(mTable);
 }
 
 
 /***************************************************************************/
 // implement IID2NativeInterfaceMap...
 
 const struct PLDHashTableOps IID2NativeInterfaceMap::Entry::sOps =
 {
@@ -251,40 +237,35 @@ const struct PLDHashTableOps IID2NativeI
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub
 };
 
 // static
 IID2NativeInterfaceMap*
 IID2NativeInterfaceMap::newMap(int length)
 {
-    IID2NativeInterfaceMap* map = new IID2NativeInterfaceMap(length);
-    if (map && map->mTable)
-        return map;
-    delete map;
-    return nullptr;
+    return new IID2NativeInterfaceMap(length);
 }
 
 IID2NativeInterfaceMap::IID2NativeInterfaceMap(int length)
 {
     mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
 }
 
 IID2NativeInterfaceMap::~IID2NativeInterfaceMap()
 {
-    if (mTable)
-        PL_DHashTableDestroy(mTable);
+    PL_DHashTableDestroy(mTable);
 }
 
 size_t
 IID2NativeInterfaceMap::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf)
 {
     size_t n = 0;
     n += mallocSizeOf(this);
-    n += mTable ? PL_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
+    n += PL_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf);
     return n;
 }
 
 /* static */ size_t
 IID2NativeInterfaceMap::SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr,
                                                  mozilla::MallocSizeOf mallocSizeOf, void *)
 {
     XPCNativeInterface *iface = ((IID2NativeInterfaceMap::Entry*)hdr)->value;
@@ -293,79 +274,65 @@ IID2NativeInterfaceMap::SizeOfEntryExclu
 
 /***************************************************************************/
 // implement ClassInfo2NativeSetMap...
 
 // static
 ClassInfo2NativeSetMap*
 ClassInfo2NativeSetMap::newMap(int length)
 {
-    ClassInfo2NativeSetMap* map = new ClassInfo2NativeSetMap(length);
-    if (map && map->mTable)
-        return map;
-    delete map;
-    return nullptr;
+    return new ClassInfo2NativeSetMap(length);
 }
 
 ClassInfo2NativeSetMap::ClassInfo2NativeSetMap(int length)
 {
     mTable = PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
 }
 
 ClassInfo2NativeSetMap::~ClassInfo2NativeSetMap()
 {
-    if (mTable)
-        PL_DHashTableDestroy(mTable);
+    PL_DHashTableDestroy(mTable);
 }
 
 size_t
 ClassInfo2NativeSetMap::ShallowSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf)
 {
     size_t n = 0;
     n += mallocSizeOf(this);
     // The second arg is nullptr because this is a "shallow" measurement of the map.
-    n += mTable ? PL_DHashTableSizeOfIncludingThis(mTable, nullptr, mallocSizeOf) : 0;
+    n += PL_DHashTableSizeOfIncludingThis(mTable, nullptr, mallocSizeOf);
     return n;
 }
 
 /***************************************************************************/
 // implement ClassInfo2WrappedNativeProtoMap...
 
 // static
 ClassInfo2WrappedNativeProtoMap*
 ClassInfo2WrappedNativeProtoMap::newMap(int length)
 {
-    ClassInfo2WrappedNativeProtoMap* map = new ClassInfo2WrappedNativeProtoMap(length);
-    if (map && map->mTable)
-        return map;
-    // Allocation of the map or the creation of its hash table has
-    // failed. This will cause a nullptr deref later when we attempt
-    // to use the map, so we abort immediately to provide a more
-    // useful crash stack.
-    NS_RUNTIMEABORT("Ran out of memory.");
-    return nullptr;
+    return new ClassInfo2WrappedNativeProtoMap(length);
 }
 
 ClassInfo2WrappedNativeProtoMap::ClassInfo2WrappedNativeProtoMap(int length)
 {
     mTable = PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
 }
 
 ClassInfo2WrappedNativeProtoMap::~ClassInfo2WrappedNativeProtoMap()
 {
-    if (mTable)
-        PL_DHashTableDestroy(mTable);
+    PL_DHashTableDestroy(mTable);
 }
 
 size_t
 ClassInfo2WrappedNativeProtoMap::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf)
 {
     size_t n = 0;
     n += mallocSizeOf(this);
-    n += mTable ? PL_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
+    n += PL_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf);
     return n;
 }
 
 /* static */ size_t
 ClassInfo2WrappedNativeProtoMap::SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr,
                                                           mozilla::MallocSizeOf mallocSizeOf, void *)
 {
     return mallocSizeOf(((ClassInfo2WrappedNativeProtoMap::Entry*)hdr)->value);
@@ -453,40 +420,35 @@ const struct PLDHashTableOps NativeSetMa
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub
 };
 
 // static
 NativeSetMap*
 NativeSetMap::newMap(int length)
 {
-    NativeSetMap* map = new NativeSetMap(length);
-    if (map && map->mTable)
-        return map;
-    delete map;
-    return nullptr;
+    return new NativeSetMap(length);
 }
 
 NativeSetMap::NativeSetMap(int length)
 {
     mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
 }
 
 NativeSetMap::~NativeSetMap()
 {
-    if (mTable)
-        PL_DHashTableDestroy(mTable);
+    PL_DHashTableDestroy(mTable);
 }
 
 size_t
 NativeSetMap::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf)
 {
     size_t n = 0;
     n += mallocSizeOf(this);
-    n += mTable ? PL_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf) : 0;
+    n += PL_DHashTableSizeOfIncludingThis(mTable, SizeOfEntryExcludingThis, mallocSizeOf);
     return n;
 }
 
 /* static */ size_t
 NativeSetMap::SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr, mozilla::MallocSizeOf mallocSizeOf, void *)
 {
     XPCNativeSet *set = ((NativeSetMap::Entry*)hdr)->key_value;
     return set->SizeOfIncludingThis(mallocSizeOf);
@@ -517,32 +479,27 @@ const struct PLDHashTableOps IID2ThisTra
     PL_DHashMoveEntryStub,
     Clear
 };
 
 // static
 IID2ThisTranslatorMap*
 IID2ThisTranslatorMap::newMap(int length)
 {
-    IID2ThisTranslatorMap* map = new IID2ThisTranslatorMap(length);
-    if (map && map->mTable)
-        return map;
-    delete map;
-    return nullptr;
+    return new IID2ThisTranslatorMap(length);
 }
 
 IID2ThisTranslatorMap::IID2ThisTranslatorMap(int length)
 {
     mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
 }
 
 IID2ThisTranslatorMap::~IID2ThisTranslatorMap()
 {
-    if (mTable)
-        PL_DHashTableDestroy(mTable);
+    PL_DHashTableDestroy(mTable);
 }
 
 /***************************************************************************/
 
 PLDHashNumber
 XPCNativeScriptableSharedMap::Entry::Hash(PLDHashTable *table, const void *key)
 {
     PLDHashNumber h;
@@ -593,33 +550,27 @@ const struct PLDHashTableOps XPCNativeSc
     PL_DHashMoveEntryStub,
     PL_DHashClearEntryStub
 };
 
 // static
 XPCNativeScriptableSharedMap*
 XPCNativeScriptableSharedMap::newMap(int length)
 {
-    XPCNativeScriptableSharedMap* map =
-        new XPCNativeScriptableSharedMap(length);
-    if (map && map->mTable)
-        return map;
-    delete map;
-    return nullptr;
+    return new XPCNativeScriptableSharedMap(length);
 }
 
 XPCNativeScriptableSharedMap::XPCNativeScriptableSharedMap(int length)
 {
     mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
 }
 
 XPCNativeScriptableSharedMap::~XPCNativeScriptableSharedMap()
 {
-    if (mTable)
-        PL_DHashTableDestroy(mTable);
+    PL_DHashTableDestroy(mTable);
 }
 
 bool
 XPCNativeScriptableSharedMap::GetNewOrUsed(uint32_t flags,
                                            char* name,
                                            XPCNativeScriptableInfo* si)
 {
     NS_PRECONDITION(name,"bad param");
@@ -645,28 +596,23 @@ XPCNativeScriptableSharedMap::GetNewOrUs
 
 /***************************************************************************/
 // implement XPCWrappedNativeProtoMap...
 
 // static
 XPCWrappedNativeProtoMap*
 XPCWrappedNativeProtoMap::newMap(int length)
 {
-    XPCWrappedNativeProtoMap* map = new XPCWrappedNativeProtoMap(length);
-    if (map && map->mTable)
-        return map;
-    delete map;
-    return nullptr;
+    return new XPCWrappedNativeProtoMap(length);
 }
 
 XPCWrappedNativeProtoMap::XPCWrappedNativeProtoMap(int length)
 {
     mTable = PL_NewDHashTable(PL_DHashGetStubOps(),
                               sizeof(PLDHashEntryStub), length);
 }
 
 XPCWrappedNativeProtoMap::~XPCWrappedNativeProtoMap()
 {
-    if (mTable)
-        PL_DHashTableDestroy(mTable);
+    PL_DHashTableDestroy(mTable);
 }
 
 /***************************************************************************/
--- a/js/xpconnect/src/XPCMaps.h
+++ b/js/xpconnect/src/XPCMaps.h
@@ -27,17 +27,17 @@
 class JSObject2WrappedJSMap
 {
     typedef js::HashMap<JSObject*, nsXPCWrappedJS*, js::PointerHasher<JSObject*, 3>,
                         js::SystemAllocPolicy> Map;
 
 public:
     static JSObject2WrappedJSMap* newMap(int length) {
         JSObject2WrappedJSMap* map = new JSObject2WrappedJSMap();
-        if (map && map->mTable.init(length))
+        if (map->mTable.init(length))
             return map;
         delete map;
         return nullptr;
     }
 
     inline nsXPCWrappedJS* Find(JSObject* Obj) {
         NS_PRECONDITION(Obj,"bad param");
         Map::Ptr p = mTable.lookup(Obj);
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1602,18 +1602,16 @@ void nsRuleNode::SetUsedDirectly()
 void
 nsRuleNode::ConvertChildrenToHash(int32_t aNumKids)
 {
   NS_ASSERTION(!ChildrenAreHashed() && HaveChildren(),
                "must have a non-empty list of children");
   PLDHashTable *hash = PL_NewDHashTable(&ChildrenHashOps,
                                         sizeof(ChildrenHashEntry),
                                         aNumKids);
-  if (!hash)
-    return;
   for (nsRuleNode* curr = ChildrenList(); curr; curr = curr->mNextSibling) {
     // This will never fail because of the initial size we gave the table.
     ChildrenHashEntry *entry = static_cast<ChildrenHashEntry*>(
       PL_DHashTableAdd(hash, curr->mRule));
     NS_ASSERTION(!entry->mRuleNode, "duplicate entries in list");
     entry->mRuleNode = curr;
   }
   SetChildrenHash(hash);
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -518,18 +518,17 @@ NS_INTERFACE_MAP_END
  * nsIPrefService Implementation
  */
 
 nsresult
 Preferences::Init()
 {
   nsresult rv;
 
-  rv = PREF_Init();
-  NS_ENSURE_SUCCESS(rv, rv);
+  PREF_Init();
 
   rv = pref_InitInitialObjects();
   NS_ENSURE_SUCCESS(rv, rv);
 
   using mozilla::dom::ContentChild;
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     InfallibleTArray<PrefSetting> prefs;
     ContentChild::GetSingleton()->SendReadPrefsArray(&prefs);
@@ -639,18 +638,17 @@ Preferences::ResetPrefs()
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
     NS_ERROR("cannot reset prefs from content process");
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   NotifyServiceObservers(NS_PREFSERVICE_RESET_TOPIC_ID);
   PREF_CleanupPrefs();
 
-  nsresult rv = PREF_Init();
-  NS_ENSURE_SUCCESS(rv, rv);
+  PREF_Init();
 
   return pref_InitInitialObjects();
 }
 
 NS_IMETHODIMP
 Preferences::ResetUserPrefs()
 {
   if (XRE_GetProcessType() == GeckoProcessType_Content) {
--- a/modules/libpref/prefapi.cpp
+++ b/modules/libpref/prefapi.cpp
@@ -138,29 +138,24 @@ static nsresult pref_DoCallback(const ch
 enum {
     kPrefSetDefault = 1,
     kPrefForceSet = 2
 };
 static nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t flags);
 
 #define PREF_HASHTABLE_INITIAL_LENGTH   1024
 
-nsresult PREF_Init()
+void PREF_Init()
 {
     if (!gHashTable.IsInitialized()) {
-        if (!PL_DHashTableInit(&gHashTable, &pref_HashTableOps,
-                               sizeof(PrefHashEntry), fallible,
-                               PREF_HASHTABLE_INITIAL_LENGTH)) {
-            return NS_ERROR_OUT_OF_MEMORY;
-        }
-
+        PL_DHashTableInit(&gHashTable, &pref_HashTableOps,
+                          sizeof(PrefHashEntry), PREF_HASHTABLE_INITIAL_LENGTH);
         PL_INIT_ARENA_POOL(&gPrefNameArena, "PrefNameArena",
                            PREFNAME_ARENA_SIZE);
     }
-    return NS_OK;
 }
 
 /* Frees the callback list. */
 void PREF_Cleanup()
 {
     NS_ASSERTION(!gCallbacksInProgress,
         "PREF_Cleanup was called while gCallbacksInProgress is true!");
     struct CallbackNode* node = gCallbacks;
--- a/modules/libpref/prefapi.h
+++ b/modules/libpref/prefapi.h
@@ -37,17 +37,17 @@ struct PrefHashEntry : PLDHashEntryHdr
 };
 
 /*
 // <font color=blue>
 // The Init function initializes the preference context and creates
 // the preference hashtable.
 // </font>
 */
-nsresult    PREF_Init();
+void        PREF_Init();
 
 /*
 // Cleanup should be called at program exit to free the 
 // list of registered callbacks.
 */
 void        PREF_Cleanup();
 void        PREF_CleanupPrefs();
 
--- a/netwerk/cache/nsCacheEntry.cpp
+++ b/netwerk/cache/nsCacheEntry.cpp
@@ -380,107 +380,101 @@ nsCacheEntryHashTable::ops =
     HashKey,
     MatchEntry,
     MoveEntry,
     ClearEntry
 };
 
 
 nsCacheEntryHashTable::nsCacheEntryHashTable()
-    : initialized(false)
 {
     MOZ_COUNT_CTOR(nsCacheEntryHashTable);
 }
 
 
 nsCacheEntryHashTable::~nsCacheEntryHashTable()
 {
     MOZ_COUNT_DTOR(nsCacheEntryHashTable);
-    if (initialized)
-        Shutdown();
+    Shutdown();
 }
 
 
-nsresult
+void
 nsCacheEntryHashTable::Init()
 {
-    nsresult rv = NS_OK;
-    initialized = PL_DHashTableInit(&table, &ops,
-                                    sizeof(nsCacheEntryHashTableEntry),
-                                    fallible, 256);
-
-    if (!initialized) rv = NS_ERROR_OUT_OF_MEMORY;
-
-    return rv;
+    PL_DHashTableInit(&table, &ops, sizeof(nsCacheEntryHashTableEntry), 256);
 }
 
 void
 nsCacheEntryHashTable::Shutdown()
 {
-    if (initialized) {
+    if (table.IsInitialized()) {
         PL_DHashTableFinish(&table);
-        initialized = false;
     }
 }
 
 
 nsCacheEntry *
 nsCacheEntryHashTable::GetEntry( const nsCString * key)
 {
-    NS_ASSERTION(initialized, "nsCacheEntryHashTable not initialized");
-    if (!initialized)  return nullptr;
+    NS_ASSERTION(table.IsInitialized(),
+                 "nsCacheEntryHashTable not initialized");
+    if (!table.IsInitialized())  return nullptr;
 
     PLDHashEntryHdr *hashEntry = PL_DHashTableSearch(&table, key);
     return hashEntry ? ((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry
                      : nullptr;
 }
 
 
 nsresult
 nsCacheEntryHashTable::AddEntry( nsCacheEntry *cacheEntry)
 {
     PLDHashEntryHdr    *hashEntry;
 
-    NS_ASSERTION(initialized, "nsCacheEntryHashTable not initialized");
-    if (!initialized)  return NS_ERROR_NOT_INITIALIZED;
+    NS_ASSERTION(table.IsInitialized(),
+                 "nsCacheEntryHashTable not initialized");
+    if (!table.IsInitialized())  return NS_ERROR_NOT_INITIALIZED;
     if (!cacheEntry)   return NS_ERROR_NULL_POINTER;
 
     hashEntry = PL_DHashTableAdd(&table, &(cacheEntry->mKey));
 #ifndef DEBUG_dougt
     NS_ASSERTION(((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry == 0,
                  "### nsCacheEntryHashTable::AddEntry - entry already used");
 #endif
     ((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry = cacheEntry;
 
     return NS_OK;
 }
 
 
 void
 nsCacheEntryHashTable::RemoveEntry( nsCacheEntry *cacheEntry)
 {
-    NS_ASSERTION(initialized, "nsCacheEntryHashTable not initialized");
+    NS_ASSERTION(table.IsInitialized(),
+                 "nsCacheEntryHashTable not initialized");
     NS_ASSERTION(cacheEntry, "### cacheEntry == nullptr");
 
-    if (!initialized)  return; // NS_ERROR_NOT_INITIALIZED
+    if (!table.IsInitialized())  return; // NS_ERROR_NOT_INITIALIZED
 
 #if DEBUG
     // XXX debug code to make sure we have the entry we're trying to remove
     nsCacheEntry *check = GetEntry(&(cacheEntry->mKey));
     NS_ASSERTION(check == cacheEntry, "### Attempting to remove unknown cache entry!!!");
 #endif
     PL_DHashTableRemove(&table, &(cacheEntry->mKey));
 }
 
 
 void
 nsCacheEntryHashTable::VisitEntries( PLDHashEnumerator etor, void *arg)
 {
-    NS_ASSERTION(initialized, "nsCacheEntryHashTable not initialized");
-    if (!initialized)  return; // NS_ERROR_NOT_INITIALIZED
+    NS_ASSERTION(table.IsInitialized(),
+                 "nsCacheEntryHashTable not initialized");
+    if (!table.IsInitialized())  return; // NS_ERROR_NOT_INITIALIZED
     PL_DHashTableEnumerate(&table, etor, arg);
 }
 
 
 /**
  *  hash table operation callback functions
  */
 
--- a/netwerk/cache/nsCacheEntry.h
+++ b/netwerk/cache/nsCacheEntry.h
@@ -262,17 +262,17 @@ typedef struct {
 
 
 class nsCacheEntryHashTable
 {
 public:
     nsCacheEntryHashTable();
     ~nsCacheEntryHashTable();
 
-    nsresult      Init();
+    void          Init();
     void          Shutdown();
 
     nsCacheEntry *GetEntry( const nsCString * key);
     nsresult      AddEntry( nsCacheEntry *entry);
     void          RemoveEntry( nsCacheEntry *entry);
     
     void          VisitEntries( PLDHashEnumerator etor, void *arg);
 
@@ -301,12 +301,11 @@ private:
     PLDHashOperator       VisitEntry(PLDHashTable *         table,
                                      PLDHashEntryHdr *      hdr,
                                      uint32_t               number,
                                      void *                 arg);
                                      
     // member variables
     static const PLDHashTableOps ops;
     PLDHashTable                 table;
-    bool                         initialized;
 };
 
 #endif // _nsCacheEntry_h_
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -1150,18 +1150,17 @@ nsCacheService::Init()
     }
 
     rv = nsDeleteDir::Init();
     if (NS_FAILED(rv)) {
         NS_WARNING("Can't initialize nsDeleteDir");
     }
 
     // initialize hashtable for active cache entries
-    rv = mActiveEntries.Init();
-    if (NS_FAILED(rv)) return rv;
+    mActiveEntries.Init();
 
     // create profile/preference observer
     if (!mObserver) {
       mObserver = new nsCacheProfilePrefObserver();
       NS_ADDREF(mObserver);
       mObserver->Install();
     }
 
--- a/netwerk/cache/nsMemoryCacheDevice.cpp
+++ b/netwerk/cache/nsMemoryCacheDevice.cpp
@@ -50,19 +50,19 @@ nsMemoryCacheDevice::~nsMemoryCacheDevic
 }
 
 
 nsresult
 nsMemoryCacheDevice::Init()
 {
     if (mInitialized)  return NS_ERROR_ALREADY_INITIALIZED;
 
-    nsresult  rv = mMemCacheEntries.Init();
-    mInitialized = NS_SUCCEEDED(rv);
-    return rv;
+    mMemCacheEntries.Init();
+    mInitialized = true;
+    return NS_OK;
 }
 
 
 nsresult
 nsMemoryCacheDevice::Shutdown()
 {
     NS_ASSERTION(mInitialized, "### attempting shutdown while not initialized");
     NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
--- a/netwerk/protocol/http/nsHttp.cpp
+++ b/netwerk/protocol/http/nsHttp.cpp
@@ -100,20 +100,18 @@ nsHttp::CreateAtomTable()
 
     if (!sLock) {
         sLock = new Mutex("nsHttp.sLock");
     }
 
     // The initial length for this table is a value greater than the number of
     // known atoms (NUM_HTTP_ATOMS) because we expect to encounter a few random
     // headers right off the bat.
-    if (!PL_DHashTableInit(&sAtomTable, &ops, sizeof(PLDHashEntryStub),
-                           fallible, NUM_HTTP_ATOMS + 10)) {
-        return NS_ERROR_OUT_OF_MEMORY;
-    }
+    PL_DHashTableInit(&sAtomTable, &ops, sizeof(PLDHashEntryStub),
+                      NUM_HTTP_ATOMS + 10);
 
     // fill the table with our known atoms
     const char *const atoms[] = {
 #define HTTP_ATOM(_name, _value) nsHttp::_name._val,
 #include "nsHttpAtomList.h"
 #undef HTTP_ATOM
         nullptr
     };
--- a/parser/htmlparser/nsHTMLEntities.cpp
+++ b/parser/htmlparser/nsHTMLEntities.cpp
@@ -78,27 +78,20 @@ static const EntityNode gEntityArray[] =
 #undef HTML_ENTITY
 
 #define NS_HTML_ENTITY_COUNT ((int32_t)ArrayLength(gEntityArray))
 
 nsresult
 nsHTMLEntities::AddRefTable(void)
 {
   if (!gTableRefCnt) {
-    if (!PL_DHashTableInit(&gEntityToUnicode, &EntityToUnicodeOps,
-                           sizeof(EntityNodeEntry),
-                           fallible, NS_HTML_ENTITY_COUNT)) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-    if (!PL_DHashTableInit(&gUnicodeToEntity, &UnicodeToEntityOps,
-                           sizeof(EntityNodeEntry),
-                           fallible, NS_HTML_ENTITY_COUNT)) {
-      PL_DHashTableFinish(&gEntityToUnicode);
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
+    PL_DHashTableInit(&gEntityToUnicode, &EntityToUnicodeOps,
+                      sizeof(EntityNodeEntry), NS_HTML_ENTITY_COUNT);
+    PL_DHashTableInit(&gUnicodeToEntity, &UnicodeToEntityOps,
+                      sizeof(EntityNodeEntry), NS_HTML_ENTITY_COUNT);
     for (const EntityNode *node = gEntityArray,
                  *node_end = ArrayEnd(gEntityArray);
          node < node_end; ++node) {
 
       // add to Entity->Unicode table
       EntityNodeEntry* entry =
         static_cast<EntityNodeEntry*>
                    (PL_DHashTableAdd(&gEntityToUnicode, node->mStr));
--- a/security/manager/ssl/src/nsCertTree.cpp
+++ b/security/manager/ssl/src/nsCertTree.cpp
@@ -173,24 +173,21 @@ nsCertTree::nsCertTree() : mTreeArray(nu
 
 void nsCertTree::ClearCompareHash()
 {
   if (mCompareCache.IsInitialized()) {
     PL_DHashTableFinish(&mCompareCache);
   }
 }
 
-nsresult nsCertTree::InitCompareHash()
+void nsCertTree::InitCompareHash()
 {
   ClearCompareHash();
-  if (!PL_DHashTableInit(&mCompareCache, &gMapOps,
-                         sizeof(CompareCacheHashEntryPtr), fallible, 64)) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-  return NS_OK;
+  PL_DHashTableInit(&mCompareCache, &gMapOps,
+                    sizeof(CompareCacheHashEntryPtr), 64);
 }
 
 nsCertTree::~nsCertTree()
 {
   ClearCompareHash();
   delete [] mTreeArray;
 }
 
@@ -658,39 +655,38 @@ NS_IMETHODIMP
 nsCertTree::LoadCertsFromCache(nsINSSCertCache *aCache, uint32_t aType)
 {
   if (mTreeArray) {
     FreeCertArray();
     delete [] mTreeArray;
     mTreeArray = nullptr;
     mNumRows = 0;
   }
-  nsresult rv = InitCompareHash();
-  if (NS_FAILED(rv)) return rv;
+  InitCompareHash();
 
-  rv = GetCertsByTypeFromCache(aCache, aType, 
-                               GetCompareFuncFromCertType(aType), &mCompareCache);
+  nsresult rv =
+    GetCertsByTypeFromCache(aCache, aType, GetCompareFuncFromCertType(aType),
+                            &mCompareCache);
   if (NS_FAILED(rv)) return rv;
   return UpdateUIContents();
 }
 
 NS_IMETHODIMP 
 nsCertTree::LoadCerts(uint32_t aType)
 {
   if (mTreeArray) {
     FreeCertArray();
     delete [] mTreeArray;
     mTreeArray = nullptr;
     mNumRows = 0;
   }
-  nsresult rv = InitCompareHash();
-  if (NS_FAILED(rv)) return rv;
+  InitCompareHash();
 
-  rv = GetCertsByType(aType, 
-                      GetCompareFuncFromCertType(aType), &mCompareCache);
+  nsresult rv =
+    GetCertsByType(aType, GetCompareFuncFromCertType(aType), &mCompareCache);
   if (NS_FAILED(rv)) return rv;
   return UpdateUIContents();
 }
 
 nsresult
 nsCertTree::UpdateUIContents()
 {
   uint32_t count = mDispInfo.Length();
--- a/security/manager/ssl/src/nsCertTree.h
+++ b/security/manager/ssl/src/nsCertTree.h
@@ -85,17 +85,17 @@ public:
   nsCertTree();
 
   enum sortCriterion { sort_IssuerOrg, sort_Org, sort_Token, 
     sort_CommonName, sort_IssuedDateDescending, sort_Email, sort_None };
 
 protected:
   virtual ~nsCertTree();
 
-  nsresult InitCompareHash();
+  void InitCompareHash();
   void ClearCompareHash();
   void RemoveCacheEntry(void *key);
 
   typedef int (*nsCertCompareFunc)(void *, nsIX509Cert *a, nsIX509Cert *b);
 
   static CompareCacheHashEntry *getCacheEntry(void *cache, void *aCert);
   static void CmpInitCriterion(nsIX509Cert *cert, CompareCacheHashEntry *entry,
                                sortCriterion crit, int32_t level);
--- a/xpcom/ds/nsStaticNameTable.cpp
+++ b/xpcom/ds/nsStaticNameTable.cpp
@@ -133,21 +133,18 @@ nsStaticCaseInsensitiveNameTable::Init(c
   NS_ASSERTION(aLength, "0 length");
 
   mNameArray = (nsDependentCString*)
     nsMemory::Alloc(aLength * sizeof(nsDependentCString));
   if (!mNameArray) {
     return false;
   }
 
-  if (!PL_DHashTableInit(&mNameTable, &nametable_CaseInsensitiveHashTableOps,
-                         sizeof(NameTableEntry), fallible,
-                         aLength)) {
-    return false;
-  }
+  PL_DHashTableInit(&mNameTable, &nametable_CaseInsensitiveHashTableOps,
+                    sizeof(NameTableEntry), aLength);
 
   for (int32_t index = 0; index < aLength; ++index) {
     const char* raw = aNames[index];
 #ifdef DEBUG
     {
       // verify invariants of contents
       nsAutoCString temp1(raw);
       nsDependentCString temp2(raw);
--- a/xpcom/glue/pldhash.cpp
+++ b/xpcom/glue/pldhash.cpp
@@ -166,33 +166,26 @@ SizeOfEntryStore(uint32_t aCapacity, uin
   *aNbytes = aCapacity * aEntrySize;
   return uint64_t(*aNbytes) == nbytes64;   // returns false on overflow
 }
 
 PLDHashTable*
 PL_NewDHashTable(const PLDHashTableOps* aOps, uint32_t aEntrySize,
                  uint32_t aLength)
 {
-  PLDHashTable* table = (PLDHashTable*)malloc(sizeof(*table));
-
-  if (!table) {
-    return nullptr;
-  }
-  if (!PL_DHashTableInit(table, aOps, aEntrySize, fallible, aLength)) {
-    free(table);
-    return nullptr;
-  }
+  PLDHashTable* table = new PLDHashTable();
+  PL_DHashTableInit(table, aOps, aEntrySize, aLength);
   return table;
 }
 
 void
 PL_DHashTableDestroy(PLDHashTable* aTable)
 {
   PL_DHashTableFinish(aTable);
-  free(aTable);
+  delete aTable;
 }
 
 /*
  * Compute max and min load numbers (entry counts).  We have a secondary max
  * that allows us to overload a table reasonably if it cannot be grown further
  * (i.e. if ChangeTable() fails).  The table slows down drastically if the
  * secondary max is too close to 1, but 0.96875 gives only a slight slowdown
  * while allowing 1.3x more elements.
@@ -214,80 +207,59 @@ MinLoad(uint32_t aCapacity)
 }
 
 static inline uint32_t
 MinCapacity(uint32_t aLength)
 {
   return (aLength * 4 + (3 - 1)) / 3;   // == ceil(aLength * 4 / 3)
 }
 
-MOZ_ALWAYS_INLINE bool
+MOZ_ALWAYS_INLINE void
 PLDHashTable::Init(const PLDHashTableOps* aOps,
-                   uint32_t aEntrySize, const fallible_t&, uint32_t aLength)
+                   uint32_t aEntrySize, uint32_t aLength)
 {
   if (aLength > PL_DHASH_MAX_INITIAL_LENGTH) {
-    return false;
+    MOZ_CRASH("Initial length is too large");
   }
 
   // Compute the smallest capacity allowing |aLength| elements to be inserted
   // without rehashing.
   uint32_t capacity = MinCapacity(aLength);
   if (capacity < PL_DHASH_MIN_CAPACITY) {
     capacity = PL_DHASH_MIN_CAPACITY;
   }
 
   int log2 = CeilingLog2(capacity);
 
   capacity = 1u << log2;
   MOZ_ASSERT(capacity <= PL_DHASH_MAX_CAPACITY);
+  mOps = aOps;
   mHashShift = PL_DHASH_BITS - log2;
   mEntrySize = aEntrySize;
   mEntryCount = mRemovedCount = 0;
   mGeneration = 0;
   uint32_t nbytes;
   if (!SizeOfEntryStore(capacity, aEntrySize, &nbytes)) {
-    return false;  // overflowed
+    MOZ_CRASH("Initial entry store size is too large");
   }
 
   mEntryStore = nullptr;
 
   METER(memset(&mStats, 0, sizeof(mStats)));
 
-  // Set this only once we reach a point where we know we can't fail.
-  mOps = aOps;
-
 #ifdef DEBUG
   mRecursionLevel = 0;
 #endif
-
-  return true;
-}
-
-bool
-PL_DHashTableInit(PLDHashTable* aTable, const PLDHashTableOps* aOps,
-                  uint32_t aEntrySize,
-                  const fallible_t& aFallible, uint32_t aLength)
-{
-  return aTable->Init(aOps, aEntrySize, aFallible, aLength);
 }
 
 void
 PL_DHashTableInit(PLDHashTable* aTable, const PLDHashTableOps* aOps,
                   uint32_t aEntrySize, uint32_t aLength)
 {
-  if (!PL_DHashTableInit(aTable, aOps, aEntrySize, fallible, aLength)) {
-    if (aLength > PL_DHASH_MAX_INITIAL_LENGTH) {
-      MOZ_CRASH();          // the asked-for length was too big
-    }
-    uint32_t capacity = MinCapacity(aLength), nbytes;
-    if (!SizeOfEntryStore(capacity, aEntrySize, &nbytes)) {
-      MOZ_CRASH();          // the required mEntryStore size was too big
-    }
-    NS_ABORT_OOM(nbytes);   // allocation failed
-  }
+  aTable->Init(aOps, aEntrySize, aLength);
 }
 
 /*
  * Double hashing needs the second hash code to be relatively prime to table
  * size, so we simply make hash2 odd.
  */
 #define HASH1(hash0, shift)         ((hash0) >> (shift))
 #define HASH2(hash0,log2,shift)     ((((hash0) << (log2)) >> (shift)) | 1)
--- a/xpcom/glue/pldhash.h
+++ b/xpcom/glue/pldhash.h
@@ -5,17 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef pldhash_h___
 #define pldhash_h___
 /*
  * Double hashing, a la Knuth 6.
  */
 #include "mozilla/Attributes.h" // for MOZ_ALWAYS_INLINE
-#include "mozilla/fallible.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Types.h"
 #include "nscore.h"
 
 #ifdef PL_DHASHMETER
 #include <stdio.h>
 #endif
 
@@ -235,18 +234,17 @@ public:
   {
     return mEntryStore ? CapacityFromHashShift() : 0;
   }
 
   uint32_t EntrySize()  const { return mEntrySize; }
   uint32_t EntryCount() const { return mEntryCount; }
   uint32_t Generation() const { return mGeneration; }
 
-  bool Init(const PLDHashTableOps* aOps, uint32_t aEntrySize,
-            const mozilla::fallible_t&, uint32_t aLength);
+  void Init(const PLDHashTableOps* aOps, uint32_t aEntrySize, uint32_t aLength);
 
   void Finish();
 
   PLDHashEntryHdr* Search(const void* aKey);
   PLDHashEntryHdr* Add(const void* aKey);
   void Remove(const void* aKey);
 
   void RawRemove(PLDHashEntryHdr* aEntry);
@@ -431,17 +429,17 @@ void PL_DHashFreeStringKey(PLDHashTable*
  * If you use PLDHashEntryStub or a subclass of it as your entry struct, and
  * if your entries move via memcpy and clear via memset(0), you can use these
  * stub operations.
  */
 const PLDHashTableOps* PL_DHashGetStubOps(void);
 
 /*
  * Dynamically allocate a new PLDHashTable, initialize it using
- * PL_DHashTableInit, and return its address. Return null on allocation failure.
+ * PL_DHashTableInit, and return its address. Never returns null.
  */
 PLDHashTable* PL_NewDHashTable(
   const PLDHashTableOps* aOps, uint32_t aEntrySize,
   uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
 
 /*
  * Free |aTable|'s entry storage and |aTable| itself (both via
  * aTable->mOps->freeTable). Use this function to destroy a PLDHashTable that
@@ -459,25 +457,16 @@ void PL_DHashTableDestroy(PLDHashTable* 
  *
  * This function will crash if |aEntrySize| and/or |aLength| are too large.
  */
 void PL_DHashTableInit(
   PLDHashTable* aTable, const PLDHashTableOps* aOps,
   uint32_t aEntrySize, uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
 
 /*
- * Initialize aTable. This is the same as PL_DHashTableInit, except that it
- * returns a boolean indicating success, rather than crashing on failure.
- */
-MOZ_WARN_UNUSED_RESULT bool PL_DHashTableInit(
-  PLDHashTable* aTable, const PLDHashTableOps* aOps,
-  uint32_t aEntrySize, const mozilla::fallible_t&,
-  uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
-
-/*
  * Free |aTable|'s entry storage (via aTable->mOps->freeTable). Use this
  * function to destroy a PLDHashTable that is allocated on the stack or in
  * static memory and was created via PL_DHashTableInit().
  */
 void PL_DHashTableFinish(PLDHashTable* aTable);
 
 /*
  * To search for a key in |table|, call:
--- a/xpcom/tests/TestPLDHash.cpp
+++ b/xpcom/tests/TestPLDHash.cpp
@@ -17,98 +17,45 @@ static bool test_pldhash_Init_capacity_o
   PLDHashTable t;
 
   // Check that the constructor nulls |ops|.
   if (t.IsInitialized()) {
     return false;
   }
 
   // Try the largest allowed capacity.  With PL_DHASH_MAX_CAPACITY==1<<26, this
-  // will allocate 0.5GB of entry store on 32-bit platforms and 1GB on 64-bit
-  // platforms.
-  if (!PL_DHashTableInit(&t, PL_DHashGetStubOps(), sizeof(PLDHashEntryStub),
-                         mozilla::fallible, PL_DHASH_MAX_INITIAL_LENGTH)) {
-    return false;
-  }
+  // would allocate (if we added an element) 0.5GB of entry store on 32-bit
+  // platforms and 1GB on 64-bit platforms.
+  //
+  // Ideally we'd also try (a) a too-large capacity, and (b) a large capacity
+  // combined with a large entry size that when multipled overflow. But those
+  // cases would cause the test to abort immediately.
+  //
+  // Furthermore, ideally we'd also try a large-but-ok capacity that almost but
+  // doesn't quite overflow, but that would result in allocating just under 4GB
+  // of entry storage.  That's very likely to fail on 32-bit platforms, so such
+  // a test wouldn't be reliable.
+  //
+  PL_DHashTableInit(&t, PL_DHashGetStubOps(), sizeof(PLDHashEntryStub),
+                    PL_DHASH_MAX_INITIAL_LENGTH);
 
   // Check that Init() sets |ops|.
   if (!t.IsInitialized()) {
     return false;
   }
 
   // Check that Finish() nulls |ops|.
   PL_DHashTableFinish(&t);
   if (t.IsInitialized()) {
     return false;
   }
 
   return true;
 }
 
-static bool test_pldhash_Init_capacity_too_large()
-{
-  PLDHashTable t;
-
-  // Check that the constructor nulls |ops|.
-  if (t.IsInitialized()) {
-    return false;
-  }
-
-  // Try the smallest too-large capacity.
-  if (PL_DHashTableInit(&t, PL_DHashGetStubOps(),
-                        sizeof(PLDHashEntryStub),
-                        mozilla::fallible,
-                        PL_DHASH_MAX_INITIAL_LENGTH + 1)) {
-    return false;   // it succeeded!?
-  }
-  // Don't call PL_DHashTableFinish() here; it's not safe after Init() failure.
-
-  // Check that |ops| is still null.
-  if (t.IsInitialized()) {
-    return false;
-  }
-
-  return true;
-}
-
-static bool test_pldhash_Init_overflow()
-{
-  PLDHashTable t;
-
-  // Check that the constructor nulls |ops|.
-  if (t.IsInitialized()) {
-    return false;
-  }
-
-  // Try an acceptable capacity, but one whose byte size overflows uint32_t.
-  //
-  // Ideally we'd also try a large-but-ok capacity that almost but doesn't
-  // quite overflow, but that would result in allocating just under 4GB of
-  // entry storage.  That's very likely to fail on 32-bit platforms, so such a
-  // test wouldn't be reliable.
-
-  struct OneKBEntry {
-      PLDHashEntryHdr hdr;
-      char buf[1024 - sizeof(PLDHashEntryHdr)];
-  };
-
-  if (PL_DHashTableInit(&t, PL_DHashGetStubOps(), sizeof(OneKBEntry),
-                        mozilla::fallible, PL_DHASH_MAX_INITIAL_LENGTH)) {
-    return false;   // it succeeded!?
-  }
-  // Don't call PL_DHashTableFinish() here; it's not safe after Init() failure.
-
-  // Check that |ops| is still null.
-  if (t.IsInitialized()) {
-    return false;
-  }
-
-  return true;
-}
-
 static bool test_pldhash_lazy_storage()
 {
   PLDHashTable t;
   PL_DHashTableInit(&t, PL_DHashGetStubOps(), sizeof(PLDHashEntryStub));
 
   // PLDHashTable allocates entry storage lazily. Check that all the non-add
   // operations work appropriately when the table is empty and the storage
   // hasn't yet been allocated.
@@ -220,18 +167,16 @@ static bool test_pldhash_grow_to_max_cap
 typedef bool (*TestFunc)();
 #define DECL_TEST(name) { #name, name }
 
 static const struct Test {
   const char* name;
   TestFunc    func;
 } tests[] = {
   DECL_TEST(test_pldhash_Init_capacity_ok),
-  DECL_TEST(test_pldhash_Init_capacity_too_large),
-  DECL_TEST(test_pldhash_Init_overflow),
   DECL_TEST(test_pldhash_lazy_storage),
 // See bug 931062, we skip this test on Android due to OOM.
 #ifndef MOZ_WIDGET_ANDROID
   DECL_TEST(test_pldhash_grow_to_max_capacity),
 #endif
   { nullptr, nullptr }
 };