diff --git a/dom/base/nsContentList.cpp b/dom/base/nsContentList.cpp index 14ad95178184..7485df9efadc 100644 --- a/dom/base/nsContentList.cpp +++ b/dom/base/nsContentList.cpp @@ -215,14 +215,14 @@ NS_GetContentList(nsINode* aRootNode, }; // Initialize the hashtable if needed. - if (!gContentListHashTable.ops) { + if (!gContentListHashTable.IsInitialized()) { PL_DHashTableInit(&gContentListHashTable, &hash_table_ops, sizeof(ContentListHashEntry)); } ContentListHashEntry *entry = nullptr; // First we look in our hashtable. Then we create a content list if needed - if (gContentListHashTable.ops) { + if (gContentListHashTable.IsInitialized()) { // A PL_DHASH_ADD is equivalent to a PL_DHASH_LOOKUP for cases // when the entry is already in the hashtable. @@ -325,14 +325,14 @@ GetFuncStringContentList(nsINode* aRootNode, }; // Initialize the hashtable if needed. - if (!gFuncStringContentListHashTable.ops) { + if (!gFuncStringContentListHashTable.IsInitialized()) { PL_DHashTableInit(&gFuncStringContentListHashTable, &hash_table_ops, sizeof(FuncStringContentListHashEntry)); } FuncStringContentListHashEntry *entry = nullptr; // First we look in our hashtable. Then we create a content list if needed - if (gFuncStringContentListHashTable.ops) { + if (gFuncStringContentListHashTable.IsInitialized()) { nsFuncStringCacheKey hashKey(aRootNode, aFunc, aString); // A PL_DHASH_ADD is equivalent to a PL_DHASH_LOOKUP for cases @@ -977,7 +977,7 @@ nsContentList::RemoveFromHashtable() sRecentlyUsedContentLists[recentlyUsedCacheIndex] = nullptr; } - if (!gContentListHashTable.ops) + if (!gContentListHashTable.IsInitialized()) return; PL_DHashTableRemove(&gContentListHashTable, &key); @@ -1015,7 +1015,7 @@ nsCacheableFuncStringContentList::~nsCacheableFuncStringContentList() void nsCacheableFuncStringContentList::RemoveFromFuncStringHashtable() { - if (!gFuncStringContentListHashTable.ops) { + if (!gFuncStringContentListHashTable.IsInitialized()) { return; } diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index c3bdec224936..dde489d71b0b 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -344,7 +344,7 @@ public: { // We don't measure the |EventListenerManager| objects pointed to by the // entries because those references are non-owning. - int64_t amount = sEventListenerManagersHash.ops + int64_t amount = sEventListenerManagersHash.IsInitialized() ? PL_DHashTableSizeOfExcludingThis( &sEventListenerManagersHash, nullptr, MallocSizeOf) : 0; @@ -476,7 +476,7 @@ nsContentUtils::Init() if (!InitializeEventTable()) return NS_ERROR_FAILURE; - if (!sEventListenerManagersHash.ops) { + if (!sEventListenerManagersHash.IsInitialized()) { static const PLDHashTableOps hash_table_ops = { PL_DHashVoidPtrKeyStub, @@ -1761,7 +1761,7 @@ nsContentUtils::Shutdown() delete sUserDefinedEvents; sUserDefinedEvents = nullptr; - if (sEventListenerManagersHash.ops) { + if (sEventListenerManagersHash.IsInitialized()) { NS_ASSERTION(sEventListenerManagersHash.EntryCount() == 0, "Event listener manager hash not empty at shutdown!"); @@ -3910,7 +3910,7 @@ ListenerEnumerator(PLDHashTable* aTable, PLDHashEntryHdr* aEntry, void nsContentUtils::UnmarkGrayJSListenersInCCGenerationDocuments(uint32_t aGeneration) { - if (sEventListenerManagersHash.ops) { + if (sEventListenerManagersHash.IsInitialized()) { PL_DHashTableEnumerate(&sEventListenerManagersHash, ListenerEnumerator, &aGeneration); } @@ -3921,7 +3921,7 @@ void nsContentUtils::TraverseListenerManager(nsINode *aNode, nsCycleCollectionTraversalCallback &cb) { - if (!sEventListenerManagersHash.ops) { + if (!sEventListenerManagersHash.IsInitialized()) { // We're already shut down, just return. return; } @@ -3938,7 +3938,7 @@ nsContentUtils::TraverseListenerManager(nsINode *aNode, EventListenerManager* nsContentUtils::GetListenerManagerForNode(nsINode *aNode) { - if (!sEventListenerManagersHash.ops) { + if (!sEventListenerManagersHash.IsInitialized()) { // We're already shut down, don't bother creating an event listener // manager. @@ -3969,7 +3969,7 @@ nsContentUtils::GetExistingListenerManagerForNode(const nsINode *aNode) return nullptr; } - if (!sEventListenerManagersHash.ops) { + if (!sEventListenerManagersHash.IsInitialized()) { // We're already shut down, don't bother creating an event listener // manager. @@ -3990,7 +3990,7 @@ nsContentUtils::GetExistingListenerManagerForNode(const nsINode *aNode) void nsContentUtils::RemoveListenerManager(nsINode *aNode) { - if (sEventListenerManagersHash.ops) { + if (sEventListenerManagersHash.IsInitialized()) { EventListenerManagerMapEntry *entry = static_cast (PL_DHashTableLookup(&sEventListenerManagersHash, aNode)); diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 0b3797929cfe..ee1cc2013fef 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -2032,7 +2032,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument) tmp->mAnimationController->Traverse(&cb); } - if (tmp->mSubDocuments && tmp->mSubDocuments->ops) { + if (tmp->mSubDocuments && tmp->mSubDocuments->IsInitialized()) { PL_DHashTableEnumerate(tmp->mSubDocuments, SubDocTraverser, &cb); } diff --git a/dom/base/nsPropertyTable.cpp b/dom/base/nsPropertyTable.cpp index ed17f35a28e7..886ee4f0379e 100644 --- a/dom/base/nsPropertyTable.cpp +++ b/dom/base/nsPropertyTable.cpp @@ -215,7 +215,7 @@ nsPropertyTable::SetPropertyInternal(nsPropertyOwner aObject, } else { propertyList = new PropertyList(aPropertyName, aPropDtorFunc, aPropDtorData, aTransfer); - if (!propertyList || !propertyList->mObjectValueMap.ops) { + if (!propertyList || !propertyList->mObjectValueMap.IsInitialized()) { delete propertyList; return NS_ERROR_OUT_OF_MEMORY; } diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index 63752354b6ec..8754bd828554 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -402,7 +402,7 @@ DestroyJSObjWrapperTable() static bool CreateNPObjWrapperTable() { - MOZ_ASSERT(!sNPObjWrappers.ops); + MOZ_ASSERT(!sNPObjWrappers.IsInitialized()); if (!RegisterGCCallbacks()) { return false; @@ -437,7 +437,7 @@ OnWrapperDestroyed() DestroyJSObjWrapperTable(); } - if (sNPObjWrappers.ops) { + if (sNPObjWrappers.IsInitialized()) { // No more wrappers, and our hash was initialized. Finish the // hash to prevent leaking it. DestroyNPObjWrapperTable(); @@ -1747,7 +1747,7 @@ NPObjWrapper_Finalize(js::FreeOp *fop, JSObject *obj) { NPObject *npobj = (NPObject *)::JS_GetPrivate(obj); if (npobj) { - if (sNPObjWrappers.ops) { + if (sNPObjWrappers.IsInitialized()) { PL_DHashTableRemove(&sNPObjWrappers, npobj); } } @@ -1763,7 +1763,7 @@ NPObjWrapper_ObjectMoved(JSObject *obj, const JSObject *old) // The wrapper JSObject has been moved, so we need to update the entry in the // sNPObjWrappers hash table, if present. - if (!sNPObjWrappers.ops) { + if (!sNPObjWrappers.IsInitialized()) { return; } @@ -1822,7 +1822,7 @@ nsNPObjWrapper::OnDestroy(NPObject *npobj) return; } - if (!sNPObjWrappers.ops) { + if (!sNPObjWrappers.IsInitialized()) { // No hash yet (or any more), no used wrappers available. return; @@ -1872,7 +1872,7 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj) return nullptr; } - if (!sNPObjWrappers.ops) { + if (!sNPObjWrappers.IsInitialized()) { // No hash yet (or any more), initialize it. if (!CreateNPObjWrapperTable()) { return nullptr; @@ -2028,7 +2028,7 @@ nsJSNPRuntime::OnPluginDestroy(NPP npp) // Use the safe JSContext here as we're not always able to find the // JSContext associated with the NPP any more. AutoSafeJSContext cx; - if (sNPObjWrappers.ops) { + if (sNPObjWrappers.IsInitialized()) { NppAndCx nppcx = { npp, cx }; PL_DHashTableEnumerate(&sNPObjWrappers, NPObjWrapperPluginDestroyedCallback, &nppcx); diff --git a/dom/xul/templates/nsContentSupportMap.cpp b/dom/xul/templates/nsContentSupportMap.cpp index 25fa5cf72639..00d5d51aed6f 100644 --- a/dom/xul/templates/nsContentSupportMap.cpp +++ b/dom/xul/templates/nsContentSupportMap.cpp @@ -15,14 +15,14 @@ nsContentSupportMap::Init() void nsContentSupportMap::Finish() { - if (mMap.ops) + if (mMap.IsInitialized()) PL_DHashTableFinish(&mMap); } nsresult nsContentSupportMap::Remove(nsIContent* aElement) { - if (!mMap.ops) + if (!mMap.IsInitialized()) return NS_ERROR_NOT_INITIALIZED; nsIContent* child = aElement; diff --git a/dom/xul/templates/nsContentSupportMap.h b/dom/xul/templates/nsContentSupportMap.h index c64c1a6190dd..216aab57d114 100644 --- a/dom/xul/templates/nsContentSupportMap.h +++ b/dom/xul/templates/nsContentSupportMap.h @@ -25,7 +25,7 @@ public: ~nsContentSupportMap() { Finish(); } nsresult Put(nsIContent* aElement, nsTemplateMatch* aMatch) { - if (!mMap.ops) + if (!mMap.IsInitialized()) return NS_ERROR_NOT_INITIALIZED; PLDHashEntryHdr* hdr = PL_DHashTableAdd(&mMap, aElement); @@ -39,7 +39,7 @@ public: return NS_OK; } bool Get(nsIContent* aElement, nsTemplateMatch** aMatch) { - if (!mMap.ops) + if (!mMap.IsInitialized()) return false; PLDHashEntryHdr* hdr = PL_DHashTableLookup(&mMap, aElement); diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 7bf8cd99809a..98d6b5fe621e 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -640,7 +640,7 @@ public: ~FontNameCache() { - if (!mMap.ops) { + if (!mMap.IsInitialized()) { return; } if (!mWriteNeeded || !mCache) { @@ -656,7 +656,7 @@ public: void Init() { - if (!mMap.ops || !mCache) { + if (!mMap.IsInitialized() || !mCache) { return; } uint32_t size; @@ -712,7 +712,7 @@ public: GetInfoForFile(const nsCString& aFileName, nsCString& aFaceList, uint32_t *aTimestamp, uint32_t *aFilesize) { - if (!mMap.ops) { + if (!mMap.IsInitialized()) { return; } PLDHashEntryHdr *hdr = @@ -736,7 +736,7 @@ public: CacheFileInfo(const nsCString& aFileName, const nsCString& aFaceList, uint32_t aTimestamp, uint32_t aFilesize) { - if (!mMap.ops) { + if (!mMap.IsInitialized()) { return; } FNCMapEntry* entry = diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index f4d282991849..ad23dc7489a7 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -153,7 +153,7 @@ nsFrameManager::GetPlaceholderFrameFor(const nsIFrame* aFrame) { NS_PRECONDITION(aFrame, "null param unexpected"); - if (mPlaceholderMap.ops) { + if (mPlaceholderMap.IsInitialized()) { PlaceholderMapEntry *entry = static_cast (PL_DHashTableLookup(const_cast(&mPlaceholderMap), aFrame)); @@ -171,7 +171,7 @@ nsFrameManager::RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame) NS_PRECONDITION(aPlaceholderFrame, "null param unexpected"); NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(), "unexpected frame type"); - if (!mPlaceholderMap.ops) { + if (!mPlaceholderMap.IsInitialized()) { PL_DHashTableInit(&mPlaceholderMap, &PlaceholderMapOps, sizeof(PlaceholderMapEntry)); } @@ -193,7 +193,7 @@ nsFrameManager::UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(), "unexpected frame type"); - if (mPlaceholderMap.ops) { + if (mPlaceholderMap.IsInitialized()) { PL_DHashTableRemove(&mPlaceholderMap, aPlaceholderFrame->GetOutOfFlowFrame()); } @@ -211,7 +211,7 @@ UnregisterPlaceholders(PLDHashTable* table, PLDHashEntryHdr* hdr, void nsFrameManager::ClearPlaceholderFrameMap() { - if (mPlaceholderMap.ops) { + if (mPlaceholderMap.IsInitialized()) { PL_DHashTableEnumerate(&mPlaceholderMap, UnregisterPlaceholders, nullptr); PL_DHashTableFinish(&mPlaceholderMap); } diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index 091b50930b26..3a27cfa740bf 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -555,16 +555,16 @@ RuleHash::~RuleHash() delete [] mEnumList; } // delete arena for strings and small objects - if (mIdTable.ops) { + if (mIdTable.IsInitialized()) { PL_DHashTableFinish(&mIdTable); } - if (mClassTable.ops) { + if (mClassTable.IsInitialized()) { PL_DHashTableFinish(&mClassTable); } - if (mTagTable.ops) { + if (mTagTable.IsInitialized()) { PL_DHashTableFinish(&mTagTable); } - if (mNameSpaceTable.ops) { + if (mNameSpaceTable.IsInitialized()) { PL_DHashTableFinish(&mNameSpaceTable); } } @@ -605,7 +605,7 @@ void RuleHash::AppendRule(const RuleSelectorPair& aRuleInfo) selector = selector->mNext; } if (nullptr != selector->mIDList) { - if (!mIdTable.ops) { + if (!mIdTable.IsInitialized()) { PL_DHashTableInit(&mIdTable, mQuirksMode ? &RuleHash_IdTable_CIOps.ops : &RuleHash_IdTable_CSOps.ops, @@ -615,7 +615,7 @@ void RuleHash::AppendRule(const RuleSelectorPair& aRuleInfo) RULE_HASH_STAT_INCREMENT(mIdSelectors); } else if (nullptr != selector->mClassList) { - if (!mClassTable.ops) { + if (!mClassTable.IsInitialized()) { PL_DHashTableInit(&mClassTable, mQuirksMode ? &RuleHash_ClassTable_CIOps.ops : &RuleHash_ClassTable_CSOps.ops, @@ -626,7 +626,7 @@ void RuleHash::AppendRule(const RuleSelectorPair& aRuleInfo) } else if (selector->mLowercaseTag) { RuleValue ruleValue(aRuleInfo, mRuleCount++, mQuirksMode); - if (!mTagTable.ops) { + if (!mTagTable.IsInitialized()) { PL_DHashTableInit(&mTagTable, &RuleHash_TagTable_Ops, sizeof(RuleHashTagTableEntry)); } @@ -639,7 +639,7 @@ void RuleHash::AppendRule(const RuleSelectorPair& aRuleInfo) } } else if (kNameSpaceID_Unknown != selector->mNameSpace) { - if (!mNameSpaceTable.ops) { + if (!mNameSpaceTable.IsInitialized()) { PL_DHashTableInit(&mNameSpaceTable, &RuleHash_NameSpaceTable_Ops, sizeof(RuleHashTableEntry)); } @@ -699,7 +699,7 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso RULE_HASH_STAT_INCREMENT_LIST_COUNT(mUniversalRules, mElementUniversalCalls); } // universal rules within the namespace - if (kNameSpaceID_Unknown != nameSpace && mNameSpaceTable.ops) { + if (kNameSpaceID_Unknown != nameSpace && mNameSpaceTable.IsInitialized()) { RuleHashTableEntry *entry = static_cast (PL_DHashTableLookup(&mNameSpaceTable, NS_INT32_TO_PTR(nameSpace))); if (PL_DHASH_ENTRY_IS_BUSY(entry)) { @@ -707,7 +707,7 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementNameSpaceCalls); } } - if (mTagTable.ops) { + if (mTagTable.IsInitialized()) { RuleHashTableEntry *entry = static_cast (PL_DHashTableLookup(&mTagTable, tag)); if (PL_DHASH_ENTRY_IS_BUSY(entry)) { @@ -715,7 +715,7 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementTagCalls); } } - if (id && mIdTable.ops) { + if (id && mIdTable.IsInitialized()) { RuleHashTableEntry *entry = static_cast (PL_DHashTableLookup(&mIdTable, id)); if (PL_DHASH_ENTRY_IS_BUSY(entry)) { @@ -723,7 +723,7 @@ void RuleHash::EnumerateAllRules(Element* aElement, ElementDependentRuleProcesso RULE_HASH_STAT_INCREMENT_LIST_COUNT(entry->mRules, mElementIdCalls); } } - if (mClassTable.ops) { + if (mClassTable.IsInitialized()) { for (int32_t index = 0; index < classCount; ++index) { RuleHashTableEntry *entry = static_cast (PL_DHashTableLookup(&mClassTable, classList->AtomAt(index))); @@ -786,25 +786,25 @@ RuleHash::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = 0; - if (mIdTable.ops) { + if (mIdTable.IsInitialized()) { n += PL_DHashTableSizeOfExcludingThis(&mIdTable, SizeOfRuleHashTableEntry, aMallocSizeOf); } - if (mClassTable.ops) { + if (mClassTable.IsInitialized()) { n += PL_DHashTableSizeOfExcludingThis(&mClassTable, SizeOfRuleHashTableEntry, aMallocSizeOf); } - if (mTagTable.ops) { + if (mTagTable.IsInitialized()) { n += PL_DHashTableSizeOfExcludingThis(&mTagTable, SizeOfRuleHashTableEntry, aMallocSizeOf); } - if (mNameSpaceTable.ops) { + if (mNameSpaceTable.IsInitialized()) { n += PL_DHashTableSizeOfExcludingThis(&mNameSpaceTable, SizeOfRuleHashTableEntry, aMallocSizeOf); @@ -3366,7 +3366,7 @@ struct CascadeEnumData { ~CascadeEnumData() { - if (mRulesByWeight.ops) + if (mRulesByWeight.IsInitialized()) PL_DHashTableFinish(&mRulesByWeight); PL_FinishArenaPool(&mArena); } @@ -3580,7 +3580,7 @@ nsCSSRuleProcessor::RefreshRuleCascade(nsPresContext* aPresContext) newCascade->mCounterStyleRules, newCascade->mCacheKey, mSheetType); - if (!data.mRulesByWeight.ops) + if (!data.mRulesByWeight.IsInitialized()) return; /* out of memory */ for (uint32_t i = 0; i < mSheets.Length(); ++i) { diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index 99d1ffc90e37..47ead13ef41f 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -242,10 +242,12 @@ nsHTMLStyleSheet::nsHTMLStyleSheet(nsIDocument* aDocument) nsHTMLStyleSheet::~nsHTMLStyleSheet() { - if (mLangRuleTable.ops) + if (mLangRuleTable.IsInitialized()) { PL_DHashTableFinish(&mLangRuleTable); - if (mMappedAttrTable.ops) + } + if (mMappedAttrTable.IsInitialized()) { PL_DHashTableFinish(&mMappedAttrTable); + } } NS_IMPL_ISUPPORTS(nsHTMLStyleSheet, nsIStyleRuleProcessor) @@ -423,10 +425,10 @@ nsHTMLStyleSheet::Reset() mVisitedRule = nullptr; mActiveRule = nullptr; - if (mLangRuleTable.ops) { + if (mLangRuleTable.IsInitialized()) { PL_DHashTableFinish(&mLangRuleTable); } - if (mMappedAttrTable.ops) { + if (mMappedAttrTable.IsInitialized()) { PL_DHashTableFinish(&mMappedAttrTable); } } @@ -477,7 +479,7 @@ nsHTMLStyleSheet::SetVisitedLinkColor(nscolor aColor) already_AddRefed nsHTMLStyleSheet::UniqueMappedAttributes(nsMappedAttributes* aMapped) { - if (!mMappedAttrTable.ops) { + if (!mMappedAttrTable.IsInitialized()) { PL_DHashTableInit(&mMappedAttrTable, &MappedAttrTable_Ops, sizeof(MappedAttrTableEntry)); } @@ -498,7 +500,7 @@ nsHTMLStyleSheet::DropMappedAttributes(nsMappedAttributes* aMapped) { NS_ENSURE_TRUE_VOID(aMapped); - NS_ASSERTION(mMappedAttrTable.ops, "table uninitialized"); + NS_ASSERTION(mMappedAttrTable.IsInitialized(), "table uninitialized"); #ifdef DEBUG uint32_t entryCount = mMappedAttrTable.EntryCount() - 1; #endif @@ -511,7 +513,7 @@ nsHTMLStyleSheet::DropMappedAttributes(nsMappedAttributes* aMapped) nsIStyleRule* nsHTMLStyleSheet::LangRuleFor(const nsString& aLanguage) { - if (!mLangRuleTable.ops) { + if (!mLangRuleTable.IsInitialized()) { PL_DHashTableInit(&mLangRuleTable, &LangRuleTable_Ops, sizeof(LangRuleTableEntry)); } @@ -541,7 +543,7 @@ nsHTMLStyleSheet::DOMSizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const { size_t n = aMallocSizeOf(this); - if (mMappedAttrTable.ops) { + if (mMappedAttrTable.IsInitialized()) { n += PL_DHashTableSizeOfExcludingThis(&mMappedAttrTable, SizeOfAttributesEntryExcludingThis, aMallocSizeOf); diff --git a/layout/tables/SpanningCellSorter.cpp b/layout/tables/SpanningCellSorter.cpp index 1d2d84deb5e7..8a4c015cb28f 100644 --- a/layout/tables/SpanningCellSorter.cpp +++ b/layout/tables/SpanningCellSorter.cpp @@ -23,7 +23,7 @@ SpanningCellSorter::SpanningCellSorter() SpanningCellSorter::~SpanningCellSorter() { - if (mHashTable.ops) { + if (mHashTable.IsInitialized()) { PL_DHashTableFinish(&mHashTable); } delete [] mSortedHashTable; @@ -70,7 +70,7 @@ SpanningCellSorter::AddCell(int32_t aColSpan, int32_t aRow, int32_t aCol) i->next = mArray[index]; mArray[index] = i; } else { - if (!mHashTable.ops) { + if (!mHashTable.IsInitialized()) { PL_DHashTableInit(&mHashTable, &HashTableOps, sizeof(HashTableEntry)); } @@ -145,7 +145,7 @@ SpanningCellSorter::GetNext(int32_t *aColSpan) /* prepare to enumerate the hash */ mState = ENUMERATING_HASH; mEnumerationIndex = 0; - if (mHashTable.ops) { + if (mHashTable.IsInitialized()) { HashTableEntry **sh = new HashTableEntry*[mHashTable.EntryCount()]; if (!sh) { @@ -160,7 +160,9 @@ SpanningCellSorter::GetNext(int32_t *aColSpan) } /* fall through */ case ENUMERATING_HASH: - if (mHashTable.ops && mEnumerationIndex < mHashTable.EntryCount()) { + if (mHashTable.IsInitialized() && + mEnumerationIndex < mHashTable.EntryCount()) + { Item *result = mSortedHashTable[mEnumerationIndex]->mItems; *aColSpan = mSortedHashTable[mEnumerationIndex]->mColSpan; NS_ASSERTION(result, "holes in hash table"); diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index 070043b6d2f5..e00c1909e91a 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -235,7 +235,7 @@ Preferences::SizeOfIncludingThisAndOtherStuff(mozilla::MallocSizeOf aMallocSizeO NS_ENSURE_TRUE(InitStaticMembers(), 0); size_t n = aMallocSizeOf(sPreferences); - if (gHashTable.ops) { + if (gHashTable.IsInitialized()) { // pref keys are allocated in a private arena, which we count elsewhere. // pref stringvals are allocated out of the same private arena. n += PL_DHashTableSizeOfExcludingThis(&gHashTable, nullptr, aMallocSizeOf); @@ -955,7 +955,7 @@ Preferences::WritePrefFile(nsIFile* aFile) uint32_t writeAmount; nsresult rv; - if (!gHashTable.ops) + if (!gHashTable.IsInitialized()) return NS_ERROR_NOT_INITIALIZED; // execute a "safe" save by saving through a tempfile diff --git a/modules/libpref/nsPrefBranch.cpp b/modules/libpref/nsPrefBranch.cpp index d0302b961ef6..5135fe461378 100644 --- a/modules/libpref/nsPrefBranch.cpp +++ b/modules/libpref/nsPrefBranch.cpp @@ -555,7 +555,7 @@ NS_IMETHODIMP nsPrefBranch::GetChildList(const char *aStartingAt, uint32_t *aCou *aChildArray = nullptr; *aCount = 0; - if (!gHashTable.ops) + if (!gHashTable.IsInitialized()) return NS_ERROR_NOT_INITIALIZED; // this will contain a list of all the pref name strings diff --git a/modules/libpref/prefapi.cpp b/modules/libpref/prefapi.cpp index 59852b0f646e..9978f463f6e3 100644 --- a/modules/libpref/prefapi.cpp +++ b/modules/libpref/prefapi.cpp @@ -145,7 +145,7 @@ static nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, u nsresult PREF_Init() { - if (!gHashTable.ops) { + if (!gHashTable.IsInitialized()) { if (!PL_DHashTableInit(&gHashTable, &pref_HashTableOps, sizeof(PrefHashEntry), fallible_t(), PREF_HASHTABLE_INITIAL_LENGTH)) { @@ -181,7 +181,7 @@ void PREF_Cleanup() /* Frees up all the objects except the callback list. */ void PREF_CleanupPrefs() { - if (gHashTable.ops) { + if (gHashTable.IsInitialized()) { PL_DHashTableFinish(&gHashTable); PL_FinishArenaPool(&gPrefNameArena); } @@ -464,7 +464,7 @@ pref_CompareStrings(const void *v1, const void *v2, void *unused) bool PREF_HasUserPref(const char *pref_name) { - if (!gHashTable.ops) + if (!gHashTable.IsInitialized()) return false; PrefHashEntry *pref = pref_HashTableLookup(pref_name); @@ -478,7 +478,7 @@ bool PREF_HasUserPref(const char *pref_name) nsresult PREF_CopyCharPref(const char *pref_name, char ** return_buffer, bool get_default) { - if (!gHashTable.ops) + if (!gHashTable.IsInitialized()) return NS_ERROR_NOT_INITIALIZED; nsresult rv = NS_ERROR_UNEXPECTED; @@ -502,7 +502,7 @@ PREF_CopyCharPref(const char *pref_name, char ** return_buffer, bool get_default nsresult PREF_GetIntPref(const char *pref_name,int32_t * return_int, bool get_default) { - if (!gHashTable.ops) + if (!gHashTable.IsInitialized()) return NS_ERROR_NOT_INITIALIZED; nsresult rv = NS_ERROR_UNEXPECTED; @@ -526,7 +526,7 @@ nsresult PREF_GetIntPref(const char *pref_name,int32_t * return_int, bool get_de nsresult PREF_GetBoolPref(const char *pref_name, bool * return_value, bool get_default) { - if (!gHashTable.ops) + if (!gHashTable.IsInitialized()) return NS_ERROR_NOT_INITIALIZED; nsresult rv = NS_ERROR_UNEXPECTED; @@ -577,7 +577,7 @@ PREF_DeleteBranch(const char *branch_name) int len = (int)strlen(branch_name); - if (!gHashTable.ops) + if (!gHashTable.IsInitialized()) return NS_ERROR_NOT_INITIALIZED; /* The following check insures that if the branch name already has a "." @@ -600,7 +600,7 @@ PREF_DeleteBranch(const char *branch_name) nsresult PREF_ClearUserPref(const char *pref_name) { - if (!gHashTable.ops) + if (!gHashTable.IsInitialized()) return NS_ERROR_NOT_INITIALIZED; PrefHashEntry* pref = pref_HashTableLookup(pref_name); @@ -646,7 +646,7 @@ PREF_ClearAllUserPrefs() MOZ_ASSERT(NS_IsMainThread()); #endif - if (!gHashTable.ops) + if (!gHashTable.IsInitialized()) return NS_ERROR_NOT_INITIALIZED; PL_DHashTableEnumerate(&gHashTable, pref_ClearUserPref, nullptr); @@ -657,7 +657,7 @@ PREF_ClearAllUserPrefs() nsresult PREF_LockPref(const char *key, bool lockit) { - if (!gHashTable.ops) + if (!gHashTable.IsInitialized()) return NS_ERROR_NOT_INITIALIZED; PrefHashEntry* pref = pref_HashTableLookup(key); @@ -743,7 +743,7 @@ nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t MOZ_ASSERT(NS_IsMainThread()); #endif - if (!gHashTable.ops) + if (!gHashTable.IsInitialized()) return NS_ERROR_OUT_OF_MEMORY; PrefHashEntry* pref = static_cast(PL_DHashTableAdd(&gHashTable, key)); @@ -834,7 +834,7 @@ pref_SizeOfPrivateData(MallocSizeOf aMallocSizeOf) PrefType PREF_GetPrefType(const char *pref_name) { - if (gHashTable.ops) + if (gHashTable.IsInitialized()) { PrefHashEntry* pref = pref_HashTableLookup(pref_name); if (pref) @@ -856,7 +856,7 @@ bool PREF_PrefIsLocked(const char *pref_name) { bool result = false; - if (gIsAnyPrefLocked && gHashTable.ops) { + if (gIsAnyPrefLocked && gHashTable.IsInitialized()) { PrefHashEntry* pref = pref_HashTableLookup(pref_name); if (pref && PREF_IS_LOCKED(pref)) result = true; diff --git a/netwerk/base/src/nsLoadGroup.cpp b/netwerk/base/src/nsLoadGroup.cpp index fe69adadb62c..6438af325ee6 100644 --- a/netwerk/base/src/nsLoadGroup.cpp +++ b/netwerk/base/src/nsLoadGroup.cpp @@ -139,7 +139,7 @@ nsLoadGroup::~nsLoadGroup() DebugOnly rv = Cancel(NS_BINDING_ABORTED); NS_ASSERTION(NS_SUCCEEDED(rv), "Cancel failed"); - if (mRequests.ops) { + if (mRequests.IsInitialized()) { PL_DHashTableFinish(&mRequests); } diff --git a/netwerk/protocol/http/nsHttp.cpp b/netwerk/protocol/http/nsHttp.cpp index 1495da30c2a1..8cc0162cec35 100644 --- a/netwerk/protocol/http/nsHttp.cpp +++ b/netwerk/protocol/http/nsHttp.cpp @@ -96,7 +96,7 @@ static const PLDHashTableOps ops = { nsresult nsHttp::CreateAtomTable() { - MOZ_ASSERT(!sAtomTable.ops, "atom table already initialized"); + MOZ_ASSERT(!sAtomTable.IsInitialized(), "atom table already initialized"); if (!sLock) { sLock = new Mutex("nsHttp.sLock"); @@ -134,7 +134,7 @@ nsHttp::CreateAtomTable() void nsHttp::DestroyAtomTable() { - if (sAtomTable.ops) { + if (sAtomTable.IsInitialized()) { PL_DHashTableFinish(&sAtomTable); } @@ -162,7 +162,7 @@ nsHttp::ResolveAtom(const char *str) { nsHttpAtom atom = { nullptr }; - if (!str || !sAtomTable.ops) + if (!str || !sAtomTable.IsInitialized()) return atom; MutexAutoLock lock(*sLock); diff --git a/parser/htmlparser/nsHTMLEntities.cpp b/parser/htmlparser/nsHTMLEntities.cpp index 8dd7cae84fca..c372b2210f94 100644 --- a/parser/htmlparser/nsHTMLEntities.cpp +++ b/parser/htmlparser/nsHTMLEntities.cpp @@ -131,10 +131,10 @@ nsHTMLEntities::ReleaseTable(void) if (--gTableRefCnt != 0) return; - if (gEntityToUnicode.ops) { + if (gEntityToUnicode.IsInitialized()) { PL_DHashTableFinish(&gEntityToUnicode); } - if (gUnicodeToEntity.ops) { + if (gUnicodeToEntity.IsInitialized()) { PL_DHashTableFinish(&gUnicodeToEntity); } } @@ -142,8 +142,9 @@ nsHTMLEntities::ReleaseTable(void) int32_t nsHTMLEntities::EntityToUnicode(const nsCString& aEntity) { - NS_ASSERTION(gEntityToUnicode.ops, "no lookup table, needs addref"); - if (!gEntityToUnicode.ops) + NS_ASSERTION(gEntityToUnicode.IsInitialized(), + "no lookup table, needs addref"); + if (!gEntityToUnicode.IsInitialized()) return -1; //this little piece of code exists because entities may or may not have the terminating ';'. @@ -180,7 +181,8 @@ nsHTMLEntities::EntityToUnicode(const nsAString& aEntity) { const char* nsHTMLEntities::UnicodeToEntity(int32_t aUnicode) { - NS_ASSERTION(gUnicodeToEntity.ops, "no lookup table, needs addref"); + NS_ASSERTION(gUnicodeToEntity.IsInitialized(), + "no lookup table, needs addref"); EntityNodeEntry* entry = static_cast (PL_DHashTableLookup(&gUnicodeToEntity, NS_INT32_TO_PTR(aUnicode))); diff --git a/rdf/base/nsInMemoryDataSource.cpp b/rdf/base/nsInMemoryDataSource.cpp index 30fc4881445f..b32766dad998 100644 --- a/rdf/base/nsInMemoryDataSource.cpp +++ b/rdf/base/nsInMemoryDataSource.cpp @@ -807,7 +807,7 @@ InMemoryDataSource::~InMemoryDataSource() fprintf(stdout, "%d - RDF: InMemoryDataSource\n", gInstanceCount); #endif - if (mForwardArcs.ops) { + if (mForwardArcs.IsInitialized()) { // This'll release all of the Assertion objects that are // associated with this data source. We only need to do this // for the forward arcs, because the reverse arcs table @@ -815,7 +815,7 @@ InMemoryDataSource::~InMemoryDataSource() PL_DHashTableEnumerate(&mForwardArcs, DeleteForwardArcsEntry, nullptr); PL_DHashTableFinish(&mForwardArcs); } - if (mReverseArcs.ops) + if (mReverseArcs.IsInitialized()) PL_DHashTableFinish(&mReverseArcs); PR_LOG(gLog, PR_LOG_NOTICE, diff --git a/rdf/base/nsRDFService.cpp b/rdf/base/nsRDFService.cpp index 3e4a5b87f072..612f0ddd67e5 100644 --- a/rdf/base/nsRDFService.cpp +++ b/rdf/base/nsRDFService.cpp @@ -770,15 +770,15 @@ RDFServiceImpl::~RDFServiceImpl() PL_HashTableDestroy(mNamedDataSources); mNamedDataSources = nullptr; } - if (mResources.ops) + if (mResources.IsInitialized()) PL_DHashTableFinish(&mResources); - if (mLiterals.ops) + if (mLiterals.IsInitialized()) PL_DHashTableFinish(&mLiterals); - if (mInts.ops) + if (mInts.IsInitialized()) PL_DHashTableFinish(&mInts); - if (mDates.ops) + if (mDates.IsInitialized()) PL_DHashTableFinish(&mDates); - if (mBlobs.ops) + if (mBlobs.IsInitialized()) PL_DHashTableFinish(&mBlobs); gRDFService = nullptr; } diff --git a/security/manager/boot/src/nsSecureBrowserUIImpl.cpp b/security/manager/boot/src/nsSecureBrowserUIImpl.cpp index d04a20e26ad7..6ce493962c6e 100644 --- a/security/manager/boot/src/nsSecureBrowserUIImpl.cpp +++ b/security/manager/boot/src/nsSecureBrowserUIImpl.cpp @@ -133,7 +133,7 @@ nsSecureBrowserUIImpl::nsSecureBrowserUIImpl() nsSecureBrowserUIImpl::~nsSecureBrowserUIImpl() { - if (mTransferringRequests.ops) { + if (mTransferringRequests.IsInitialized()) { PL_DHashTableFinish(&mTransferringRequests); } } @@ -467,7 +467,7 @@ void nsSecureBrowserUIImpl::ResetStateTracking() ReentrantMonitorAutoEnter lock(mReentrantMonitor); mDocumentRequestsInProgress = 0; - if (mTransferringRequests.ops) { + if (mTransferringRequests.IsInitialized()) { PL_DHashTableFinish(&mTransferringRequests); } PL_DHashTableInit(&mTransferringRequests, &gMapOps, sizeof(RequestHashEntry)); diff --git a/security/manager/ssl/src/nsCertTree.cpp b/security/manager/ssl/src/nsCertTree.cpp index 2b178661b087..f7d82d9876bc 100644 --- a/security/manager/ssl/src/nsCertTree.cpp +++ b/security/manager/ssl/src/nsCertTree.cpp @@ -173,7 +173,7 @@ nsCertTree::nsCertTree() : mTreeArray(nullptr) void nsCertTree::ClearCompareHash() { - if (mCompareCache.ops) { + if (mCompareCache.IsInitialized()) { PL_DHashTableFinish(&mCompareCache); } } diff --git a/security/manager/ssl/src/nsNSSShutDown.cpp b/security/manager/ssl/src/nsNSSShutDown.cpp index d8af30c9b95a..f20490673ae1 100644 --- a/security/manager/ssl/src/nsNSSShutDown.cpp +++ b/security/manager/ssl/src/nsNSSShutDown.cpp @@ -53,10 +53,10 @@ nsNSSShutDownList::nsNSSShutDownList() nsNSSShutDownList::~nsNSSShutDownList() { - if (mObjects.ops) { + if (mObjects.IsInitialized()) { PL_DHashTableFinish(&mObjects); } - if (mPK11LogoutCancelObjects.ops) { + if (mPK11LogoutCancelObjects.IsInitialized()) { PL_DHashTableFinish(&mPK11LogoutCancelObjects); } PR_ASSERT(this == singleton); diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index 312de92c05d0..06b2b6689f3a 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -139,7 +139,7 @@ nsDocLoader::SetDocLoaderParent(nsDocLoader *aParent) nsresult nsDocLoader::Init() { - if (!mRequestInfoHash.ops) { + if (!mRequestInfoHash.IsInitialized()) { return NS_ERROR_OUT_OF_MEMORY; } @@ -172,7 +172,7 @@ nsDocLoader::~nsDocLoader() PR_LOG(gDocLoaderLog, PR_LOG_DEBUG, ("DocLoader:%p: deleted.\n", this)); - if (mRequestInfoHash.ops) { + if (mRequestInfoHash.IsInitialized()) { PL_DHashTableFinish(&mRequestInfoHash); } } @@ -1380,7 +1380,7 @@ RemoveInfoCallback(PLDHashTable *table, PLDHashEntryHdr *hdr, uint32_t number, void nsDocLoader::ClearRequestInfoHash(void) { - if (!mRequestInfoHash.ops || !mRequestInfoHash.EntryCount()) { + if (!mRequestInfoHash.IsInitialized() || !mRequestInfoHash.EntryCount()) { // No hash, or the hash is empty, nothing to do here then... return; diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index 45f66a60b2f9..d8245f955b7d 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -836,7 +836,7 @@ public: ~CCGraph() { - if (mPtrToNodeMap.ops) { + if (mPtrToNodeMap.IsInitialized()) { PL_DHashTableFinish(&mPtrToNodeMap); } } @@ -862,7 +862,7 @@ public: { return mNodes.IsEmpty() && mEdges.IsEmpty() && mWeakMaps.IsEmpty() && mRootCount == 0 && - !mPtrToNodeMap.ops; + !mPtrToNodeMap.IsInitialized(); } #endif diff --git a/xpcom/ds/nsAtomTable.cpp b/xpcom/ds/nsAtomTable.cpp index 7953386a9cae..ae3bda994ad4 100644 --- a/xpcom/ds/nsAtomTable.cpp +++ b/xpcom/ds/nsAtomTable.cpp @@ -40,8 +40,6 @@ using namespace mozilla; * XXX This should be manipulated in a threadsafe way or we should make * sure it's only manipulated from the main thread. Probably the latter * is better, since the former would hurt performance. - * - * If |gAtomTable.ops| is 0, then the table is uninitialized. */ static PLDHashTable gAtomTable; @@ -342,7 +340,7 @@ NS_PurgeAtomTable() { delete gStaticAtomTable; - if (gAtomTable.ops) { + if (gAtomTable.IsInitialized()) { #ifdef DEBUG const char* dumpAtomLeaks = PR_GetEnv("MOZ_DUMP_ATOM_LEAKS"); if (dumpAtomLeaks && *dumpAtomLeaks) { @@ -402,14 +400,14 @@ AtomImpl::AtomImpl(nsStringBuffer* aStringBuffer, uint32_t aLength, AtomImpl::~AtomImpl() { - NS_PRECONDITION(gAtomTable.ops, "uninitialized atom hashtable"); + NS_PRECONDITION(gAtomTable.IsInitialized(), "uninitialized atom hashtable"); // Permanent atoms are removed from the hashtable at shutdown, and we // don't want to remove them twice. See comment above in // |AtomTableClearEntry|. if (!IsPermanentInDestructor()) { AtomTableKey key(mString, mLength, mHash); PL_DHashTableRemove(&gAtomTable, &key); - if (gAtomTable.ops && gAtomTable.EntryCount() == 0) { + if (gAtomTable.IsInitialized() && gAtomTable.EntryCount() == 0) { PL_DHashTableFinish(&gAtomTable); NS_ASSERTION(gAtomTable.EntryCount() == 0, "PL_DHashTableFinish changed the entry count"); @@ -528,7 +526,7 @@ void NS_SizeOfAtomTablesIncludingThis(MallocSizeOf aMallocSizeOf, size_t* aMain, size_t* aStatic) { - *aMain = gAtomTable.ops + *aMain = gAtomTable.IsInitialized() ? PL_DHashTableSizeOfExcludingThis(&gAtomTable, SizeOfAtomTableEntryExcludingThis, aMallocSizeOf) @@ -546,7 +544,7 @@ NS_SizeOfAtomTablesIncludingThis(MallocSizeOf aMallocSizeOf, static inline void EnsureTableExists() { - if (!gAtomTable.ops) { + if (!gAtomTable.IsInitialized()) { PL_DHashTableInit(&gAtomTable, &AtomTableOps, sizeof(AtomTableEntry), ATOM_HASHTABLE_INITIAL_LENGTH); } diff --git a/xpcom/ds/nsPersistentProperties.cpp b/xpcom/ds/nsPersistentProperties.cpp index f107562c4066..7911b49ea67e 100644 --- a/xpcom/ds/nsPersistentProperties.cpp +++ b/xpcom/ds/nsPersistentProperties.cpp @@ -469,7 +469,7 @@ nsPersistentProperties::nsPersistentProperties() nsPersistentProperties::~nsPersistentProperties() { PL_FinishArenaPool(&mArena); - if (mTable.ops) { + if (mTable.IsInitialized()) { PL_DHashTableFinish(&mTable); } } diff --git a/xpcom/ds/nsStaticNameTable.cpp b/xpcom/ds/nsStaticNameTable.cpp index 52b307352378..0e03406bd659 100644 --- a/xpcom/ds/nsStaticNameTable.cpp +++ b/xpcom/ds/nsStaticNameTable.cpp @@ -117,7 +117,7 @@ nsStaticCaseInsensitiveNameTable::~nsStaticCaseInsensitiveNameTable() } nsMemory::Free((void*)mNameArray); } - if (mNameTable.ops) { + if (mNameTable.IsInitialized()) { PL_DHashTableFinish(&mNameTable); } MOZ_COUNT_DTOR(nsStaticCaseInsensitiveNameTable); @@ -128,7 +128,7 @@ nsStaticCaseInsensitiveNameTable::Init(const char* const aNames[], int32_t aLength) { NS_ASSERTION(!mNameArray, "double Init"); - NS_ASSERTION(!mNameTable.ops, "double Init"); + NS_ASSERTION(!mNameTable.IsInitialized(), "double Init"); NS_ASSERTION(aNames, "null name table"); NS_ASSERTION(aLength, "0 length"); @@ -185,7 +185,7 @@ int32_t nsStaticCaseInsensitiveNameTable::Lookup(const nsACString& aName) { NS_ASSERTION(mNameArray, "not inited"); - NS_ASSERTION(mNameTable.ops, "not inited"); + NS_ASSERTION(mNameTable.IsInitialized(), "not inited"); const nsAFlatCString& str = PromiseFlatCString(aName); @@ -203,7 +203,7 @@ int32_t nsStaticCaseInsensitiveNameTable::Lookup(const nsAString& aName) { NS_ASSERTION(mNameArray, "not inited"); - NS_ASSERTION(mNameTable.ops, "not inited"); + NS_ASSERTION(mNameTable.IsInitialized(), "not inited"); const nsAFlatString& str = PromiseFlatString(aName); @@ -221,7 +221,7 @@ const nsAFlatCString& nsStaticCaseInsensitiveNameTable::GetStringValue(int32_t aIndex) { NS_ASSERTION(mNameArray, "not inited"); - NS_ASSERTION(mNameTable.ops, "not inited"); + NS_ASSERTION(mNameTable.IsInitialized(), "not inited"); if ((NOT_FOUND < aIndex) && ((uint32_t)aIndex < mNameTable.EntryCount())) { return mNameArray[aIndex]; diff --git a/xpcom/glue/nsBaseHashtable.h b/xpcom/glue/nsBaseHashtable.h index 75f63cb7d53f..031048cc2236 100644 --- a/xpcom/glue/nsBaseHashtable.h +++ b/xpcom/glue/nsBaseHashtable.h @@ -167,7 +167,7 @@ public: */ uint32_t EnumerateRead(EnumReadFunction aEnumFunc, void* aUserArg) const { - NS_ASSERTION(this->mTable.ops, + NS_ASSERTION(this->mTable.IsInitialized(), "nsBaseHashtable was not initialized properly."); s_EnumReadArgs enumData = { aEnumFunc, aUserArg }; @@ -199,7 +199,7 @@ public: */ uint32_t Enumerate(EnumFunction aEnumFunc, void* aUserArg) { - NS_ASSERTION(this->mTable.ops, + NS_ASSERTION(this->mTable.IsInitialized(), "nsBaseHashtable was not initialized properly."); s_EnumArgs enumData = { aEnumFunc, aUserArg }; diff --git a/xpcom/glue/nsTHashtable.h b/xpcom/glue/nsTHashtable.h index bd3ccc1f3e80..e13695e8f9f9 100644 --- a/xpcom/glue/nsTHashtable.h +++ b/xpcom/glue/nsTHashtable.h @@ -126,7 +126,8 @@ public: */ EntryType* GetEntry(KeyType aKey) const { - NS_ASSERTION(mTable.ops, "nsTHashtable was not initialized properly."); + NS_ASSERTION(mTable.IsInitialized(), + "nsTHashtable was not initialized properly."); EntryType* entry = reinterpret_cast( PL_DHashTableLookup(const_cast(&mTable), @@ -157,7 +158,8 @@ public: } EntryType* PutEntry(KeyType aKey, const fallible_t&) NS_WARN_UNUSED_RESULT { - NS_ASSERTION(mTable.ops, "nsTHashtable was not initialized properly."); + NS_ASSERTION(mTable.IsInitialized(), + "nsTHashtable was not initialized properly."); return static_cast(PL_DHashTableAdd( &mTable, EntryType::KeyToPointer(aKey))); @@ -169,7 +171,8 @@ public: */ void RemoveEntry(KeyType aKey) { - NS_ASSERTION(mTable.ops, "nsTHashtable was not initialized properly."); + NS_ASSERTION(mTable.IsInitialized(), + "nsTHashtable was not initialized properly."); PL_DHashTableRemove(&mTable, EntryType::KeyToPointer(aKey)); @@ -209,7 +212,8 @@ public: */ uint32_t EnumerateEntries(Enumerator aEnumFunc, void* aUserArg) { - NS_ASSERTION(mTable.ops, "nsTHashtable was not initialized properly."); + NS_ASSERTION(mTable.IsInitialized(), + "nsTHashtable was not initialized properly."); s_EnumArgs args = { aEnumFunc, aUserArg }; return PL_DHashTableEnumerate(&mTable, s_EnumStub, &args); @@ -220,7 +224,8 @@ public: */ void Clear() { - NS_ASSERTION(mTable.ops, "nsTHashtable was not initialized properly."); + NS_ASSERTION(mTable.IsInitialized(), + "nsTHashtable was not initialized properly."); PL_DHashTableEnumerate(&mTable, PL_DHashStubEnumRemove, nullptr); } @@ -309,7 +314,8 @@ public: */ void MarkImmutable() { - NS_ASSERTION(mTable.ops, "nsTHashtable was not initialized properly."); + NS_ASSERTION(mTable.IsInitialized(), + "nsTHashtable was not initialized properly."); PL_DHashMarkTableImmutable(&mTable); } @@ -408,7 +414,7 @@ nsTHashtable::nsTHashtable(nsTHashtable&& aOther) template nsTHashtable::~nsTHashtable() { - if (mTable.ops) { + if (mTable.IsInitialized()) { PL_DHashTableFinish(&mTable); } } diff --git a/xpcom/glue/pldhash.h b/xpcom/glue/pldhash.h index 9b5bee1c3cac..5f4c9f9a23c2 100644 --- a/xpcom/glue/pldhash.h +++ b/xpcom/glue/pldhash.h @@ -222,8 +222,9 @@ private: #endif public: - // All the other fields are initialized in Init(), but we zero |ops| here - // because it's used to determine if Init() has been called. + // The most important thing here is that we zero |ops| because it's used to + // determine if Init() has been called. (The use of MOZ_CONSTEXPR means all + // the other members must be initialized too.) MOZ_CONSTEXPR PLDHashTable() : ops(nullptr) , mHashShift(0) @@ -238,6 +239,8 @@ public: #endif {} + bool IsInitialized() const { return !!ops; } + /* * Size in entries (gross, not net of free and removed sentinels) for table. * We store mHashShift rather than sizeLog2 to optimize the collision-free diff --git a/xpcom/tests/TestPLDHash.cpp b/xpcom/tests/TestPLDHash.cpp index 0fa32a1d6cd7..8609c3f51958 100644 --- a/xpcom/tests/TestPLDHash.cpp +++ b/xpcom/tests/TestPLDHash.cpp @@ -19,7 +19,7 @@ static bool test_pldhash_Init_capacity_ok() PLDHashTable t; // Check that the constructor nulls |ops|. - if (t.ops) { + if (t.IsInitialized()) { return false; } @@ -32,13 +32,13 @@ static bool test_pldhash_Init_capacity_ok() } // Check that Init() sets |ops|. - if (!t.ops) { + if (!t.IsInitialized()) { return false; } // Check that Finish() nulls |ops|. PL_DHashTableFinish(&t); - if (t.ops) { + if (t.IsInitialized()) { return false; } @@ -50,7 +50,7 @@ static bool test_pldhash_Init_capacity_too_large() PLDHashTable t; // Check that the constructor nulls |ops|. - if (t.ops) { + if (t.IsInitialized()) { return false; } @@ -64,7 +64,7 @@ static bool test_pldhash_Init_capacity_too_large() // Don't call PL_DHashTableFinish() here; it's not safe after Init() failure. // Check that |ops| is still null. - if (t.ops) { + if (t.IsInitialized()) { return false; } @@ -76,7 +76,7 @@ static bool test_pldhash_Init_overflow() PLDHashTable t; // Check that the constructor nulls |ops|. - if (t.ops) { + if (t.IsInitialized()) { return false; } @@ -99,7 +99,7 @@ static bool test_pldhash_Init_overflow() // Don't call PL_DHashTableFinish() here; it's not safe after Init() failure. // Check that |ops| is still null. - if (t.ops) { + if (t.IsInitialized()) { return false; } @@ -130,8 +130,8 @@ static bool test_pldhash_grow_to_max_capacity() // This is infallible. PLDHashTable* t = PL_NewDHashTable(&ops, sizeof(PLDHashEntryStub), 128); - // Check that New() sets |ops|. - if (!t->ops) { + // Check that New() sets |t->ops|. + if (!t->IsInitialized()) { return false; }