зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1131901 (part 1) - Make PL_DHashTableAdd() infallible by default, and add a fallible alternative. r=froydnj.
I kept all the existing PL_DHashTableAdd() calls fallible, in order to be conservative, except for the ones in nsAtomTable.cpp which already were followed immediately by an abort on failure. --HG-- extra : rebase_source : 526d96ab65e4d7d71197b90d086d19fbdd79b7b5
This commit is contained in:
Родитель
45dd8cbfb3
Коммит
3a7b0a9f57
|
@ -224,7 +224,7 @@ NS_GetContentList(nsINode* aRootNode,
|
|||
// First we look in our hashtable. Then we create a content list if needed
|
||||
if (gContentListHashTable.IsInitialized()) {
|
||||
entry = static_cast<ContentListHashEntry *>
|
||||
(PL_DHashTableAdd(&gContentListHashTable, &hashKey));
|
||||
(PL_DHashTableAdd(&gContentListHashTable, &hashKey, fallible));
|
||||
if (entry)
|
||||
list = entry->mContentList;
|
||||
}
|
||||
|
@ -332,8 +332,7 @@ GetFuncStringContentList(nsINode* aRootNode,
|
|||
nsFuncStringCacheKey hashKey(aRootNode, aFunc, aString);
|
||||
|
||||
entry = static_cast<FuncStringContentListHashEntry *>
|
||||
(PL_DHashTableAdd(&gFuncStringContentListHashTable,
|
||||
&hashKey));
|
||||
(PL_DHashTableAdd(&gFuncStringContentListHashTable, &hashKey, fallible));
|
||||
if (entry) {
|
||||
list = entry->mContentList;
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -3963,7 +3963,7 @@ nsContentUtils::GetListenerManagerForNode(nsINode *aNode)
|
|||
|
||||
EventListenerManagerMapEntry *entry =
|
||||
static_cast<EventListenerManagerMapEntry *>
|
||||
(PL_DHashTableAdd(&sEventListenerManagersHash, aNode));
|
||||
(PL_DHashTableAdd(&sEventListenerManagersHash, aNode, fallible));
|
||||
|
||||
if (!entry) {
|
||||
return nullptr;
|
||||
|
|
|
@ -4007,9 +4007,8 @@ nsDocument::SetSubDocumentFor(Element* aElement, nsIDocument* aSubDoc)
|
|||
}
|
||||
|
||||
// Add a mapping to the hash table
|
||||
SubDocMapEntry *entry =
|
||||
static_cast<SubDocMapEntry*>
|
||||
(PL_DHashTableAdd(mSubDocuments, aElement));
|
||||
SubDocMapEntry *entry = static_cast<SubDocMapEntry*>
|
||||
(PL_DHashTableAdd(mSubDocuments, aElement, fallible));
|
||||
|
||||
if (!entry) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
|
|
@ -230,7 +230,7 @@ nsPropertyTable::SetPropertyInternal(nsPropertyOwner aObject,
|
|||
// value is destroyed
|
||||
nsresult result = NS_OK;
|
||||
PropertyListMapEntry *entry = static_cast<PropertyListMapEntry*>
|
||||
(PL_DHashTableAdd(&propertyList->mObjectValueMap, aObject));
|
||||
(PL_DHashTableAdd(&propertyList->mObjectValueMap, aObject, fallible));
|
||||
if (!entry)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
// A nullptr entry->key is the sign that the entry has just been allocated
|
||||
|
|
|
@ -140,9 +140,8 @@ nsGlobalNameStruct *
|
|||
nsScriptNameSpaceManager::AddToHash(PLDHashTable *aTable, const nsAString *aKey,
|
||||
const char16_t **aClassName)
|
||||
{
|
||||
GlobalNameMapEntry *entry =
|
||||
static_cast<GlobalNameMapEntry *>
|
||||
(PL_DHashTableAdd(aTable, aKey));
|
||||
GlobalNameMapEntry *entry = static_cast<GlobalNameMapEntry *>
|
||||
(PL_DHashTableAdd(aTable, aKey, fallible));
|
||||
|
||||
if (!entry) {
|
||||
return nullptr;
|
||||
|
|
|
@ -1872,7 +1872,7 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj)
|
|||
}
|
||||
|
||||
NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
|
||||
(PL_DHashTableAdd(&sNPObjWrappers, npobj));
|
||||
(PL_DHashTableAdd(&sNPObjWrappers, npobj, fallible));
|
||||
|
||||
if (!entry) {
|
||||
// Out of memory
|
||||
|
@ -2035,7 +2035,7 @@ LookupNPP(NPObject *npobj)
|
|||
}
|
||||
|
||||
NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
|
||||
(PL_DHashTableAdd(&sNPObjWrappers, npobj));
|
||||
(PL_DHashTableAdd(&sNPObjWrappers, npobj, fallible));
|
||||
|
||||
if (!entry) {
|
||||
return nullptr;
|
||||
|
|
|
@ -781,9 +781,8 @@ XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener,
|
|||
(PL_DHashTableSearch(mBroadcasterMap, &aBroadcaster));
|
||||
|
||||
if (!entry) {
|
||||
entry =
|
||||
static_cast<BroadcasterMapEntry*>
|
||||
(PL_DHashTableAdd(mBroadcasterMap, &aBroadcaster));
|
||||
entry = static_cast<BroadcasterMapEntry*>
|
||||
(PL_DHashTableAdd(mBroadcasterMap, &aBroadcaster, fallible));
|
||||
|
||||
if (! entry) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
|
|
|
@ -28,7 +28,8 @@ public:
|
|||
if (!mMap.IsInitialized())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
PLDHashEntryHdr* hdr = PL_DHashTableAdd(&mMap, aElement);
|
||||
PLDHashEntryHdr* hdr =
|
||||
PL_DHashTableAdd(&mMap, aElement, mozilla::fallible);
|
||||
if (!hdr)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ public:
|
|||
NS_ASSERTION(!PL_DHashTableSearch(&mTable, aContent),
|
||||
"aContent already in map");
|
||||
|
||||
Entry* entry = static_cast<Entry*>(PL_DHashTableAdd(&mTable, aContent));
|
||||
Entry* entry = static_cast<Entry*>
|
||||
(PL_DHashTableAdd(&mTable, aContent, fallible));
|
||||
|
||||
if (entry) {
|
||||
entry->mContent = aContent;
|
||||
|
|
|
@ -230,7 +230,8 @@ nsCommandParams::GetOrMakeEntry(const char* aName, uint8_t entryType)
|
|||
return foundEntry;
|
||||
}
|
||||
|
||||
foundEntry = (HashEntry *)PL_DHashTableAdd(&mValuesHash, (void *)aName);
|
||||
foundEntry = static_cast<HashEntry*>
|
||||
(PL_DHashTableAdd(&mValuesHash, (void *)aName, fallible));
|
||||
if (!foundEntry) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -688,9 +688,8 @@ public:
|
|||
}
|
||||
uint32_t filesize = strtoul(beginning, nullptr, 10);
|
||||
|
||||
FNCMapEntry* mapEntry =
|
||||
static_cast<FNCMapEntry*>
|
||||
(PL_DHashTableAdd(&mMap, filename.get()));
|
||||
FNCMapEntry* mapEntry = static_cast<FNCMapEntry*>
|
||||
(PL_DHashTableAdd(&mMap, filename.get(), fallible));
|
||||
if (mapEntry) {
|
||||
mapEntry->mFilename.Assign(filename);
|
||||
mapEntry->mTimestamp = timestamp;
|
||||
|
@ -737,9 +736,8 @@ public:
|
|||
if (!mMap.IsInitialized()) {
|
||||
return;
|
||||
}
|
||||
FNCMapEntry* entry =
|
||||
static_cast<FNCMapEntry*>
|
||||
(PL_DHashTableAdd(&mMap, aFileName.get()));
|
||||
FNCMapEntry* entry = static_cast<FNCMapEntry*>
|
||||
(PL_DHashTableAdd(&mMap, aFileName.get(), fallible));
|
||||
if (entry) {
|
||||
entry->mFilename.Assign(aFileName);
|
||||
entry->mTimestamp = aTimestamp;
|
||||
|
|
|
@ -626,7 +626,8 @@ XPCNativeScriptableSharedMap::GetNewOrUsed(uint32_t flags,
|
|||
NS_PRECONDITION(si,"bad param");
|
||||
|
||||
XPCNativeScriptableShared key(flags, name);
|
||||
Entry* entry = (Entry*) PL_DHashTableAdd(mTable, &key);
|
||||
Entry* entry = static_cast<Entry*>
|
||||
(PL_DHashTableAdd(mTable, &key, fallible));
|
||||
if (!entry)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -120,7 +120,8 @@ public:
|
|||
NS_PRECONDITION(wrapper,"bad param");
|
||||
nsISupports* obj = wrapper->GetIdentityObject();
|
||||
MOZ_ASSERT(!Find(obj), "wrapper already in new scope!");
|
||||
Entry* entry = (Entry*) PL_DHashTableAdd(mTable, obj);
|
||||
Entry* entry = static_cast<Entry*>
|
||||
(PL_DHashTableAdd(mTable, obj, mozilla::fallible));
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
if (entry->key)
|
||||
|
@ -185,7 +186,8 @@ public:
|
|||
{
|
||||
NS_PRECONDITION(clazz,"bad param");
|
||||
const nsIID* iid = &clazz->GetIID();
|
||||
Entry* entry = (Entry*) PL_DHashTableAdd(mTable, iid);
|
||||
Entry* entry = static_cast<Entry*>
|
||||
(PL_DHashTableAdd(mTable, iid, mozilla::fallible));
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
if (entry->key)
|
||||
|
@ -238,7 +240,8 @@ public:
|
|||
{
|
||||
NS_PRECONDITION(iface,"bad param");
|
||||
const nsIID* iid = iface->GetIID();
|
||||
Entry* entry = (Entry*) PL_DHashTableAdd(mTable, iid);
|
||||
Entry* entry = static_cast<Entry*>
|
||||
(PL_DHashTableAdd(mTable, iid, mozilla::fallible));
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
if (entry->key)
|
||||
|
@ -293,7 +296,8 @@ public:
|
|||
inline XPCNativeSet* Add(nsIClassInfo* info, XPCNativeSet* set)
|
||||
{
|
||||
NS_PRECONDITION(info,"bad param");
|
||||
Entry* entry = (Entry*) PL_DHashTableAdd(mTable, info);
|
||||
Entry* entry = static_cast<Entry*>
|
||||
(PL_DHashTableAdd(mTable, info, mozilla::fallible));
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
if (entry->key)
|
||||
|
@ -349,7 +353,8 @@ public:
|
|||
inline XPCWrappedNativeProto* Add(nsIClassInfo* info, XPCWrappedNativeProto* proto)
|
||||
{
|
||||
NS_PRECONDITION(info,"bad param");
|
||||
Entry* entry = (Entry*) PL_DHashTableAdd(mTable, info);
|
||||
Entry* entry = static_cast<Entry*>
|
||||
(PL_DHashTableAdd(mTable, info, mozilla::fallible));
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
if (entry->key)
|
||||
|
@ -411,7 +416,8 @@ public:
|
|||
{
|
||||
NS_PRECONDITION(key,"bad param");
|
||||
NS_PRECONDITION(set,"bad param");
|
||||
Entry* entry = (Entry*) PL_DHashTableAdd(mTable, key);
|
||||
Entry* entry = static_cast<Entry*>
|
||||
(PL_DHashTableAdd(mTable, key, mozilla::fallible));
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
if (entry->key_value)
|
||||
|
@ -483,8 +489,8 @@ public:
|
|||
inline nsIXPCFunctionThisTranslator* Add(REFNSIID iid,
|
||||
nsIXPCFunctionThisTranslator* obj)
|
||||
{
|
||||
|
||||
Entry* entry = (Entry*) PL_DHashTableAdd(mTable, &iid);
|
||||
Entry* entry = static_cast<Entry*>
|
||||
(PL_DHashTableAdd(mTable, &iid, mozilla::fallible));
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
entry->value = obj;
|
||||
|
@ -555,8 +561,8 @@ public:
|
|||
inline XPCWrappedNativeProto* Add(XPCWrappedNativeProto* proto)
|
||||
{
|
||||
NS_PRECONDITION(proto,"bad param");
|
||||
PLDHashEntryStub* entry = (PLDHashEntryStub*)
|
||||
PL_DHashTableAdd(mTable, proto);
|
||||
PLDHashEntryStub* entry = static_cast<PLDHashEntryStub*>
|
||||
(PL_DHashTableAdd(mTable, proto, mozilla::fallible));
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
if (entry->key)
|
||||
|
|
|
@ -175,8 +175,9 @@ nsFrameManager::RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame)
|
|||
PL_DHashTableInit(&mPlaceholderMap, &PlaceholderMapOps,
|
||||
sizeof(PlaceholderMapEntry));
|
||||
}
|
||||
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>(PL_DHashTableAdd(&mPlaceholderMap,
|
||||
aPlaceholderFrame->GetOutOfFlowFrame()));
|
||||
PlaceholderMapEntry *entry = static_cast<PlaceholderMapEntry*>
|
||||
(PL_DHashTableAdd(&mPlaceholderMap,
|
||||
aPlaceholderFrame->GetOutOfFlowFrame(), fallible));
|
||||
if (!entry)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
@ -569,7 +569,7 @@ void RuleHash::AppendRuleToTable(PLDHashTable* aTable, const void* aKey,
|
|||
{
|
||||
// Get a new or existing entry.
|
||||
RuleHashTableEntry *entry = static_cast<RuleHashTableEntry*>
|
||||
(PL_DHashTableAdd(aTable, aKey));
|
||||
(PL_DHashTableAdd(aTable, aKey, fallible));
|
||||
if (!entry)
|
||||
return;
|
||||
entry->mRules.AppendElement(RuleValue(aRuleInfo, mRuleCount++, mQuirksMode));
|
||||
|
@ -581,7 +581,7 @@ AppendRuleToTagTable(PLDHashTable* aTable, nsIAtom* aKey,
|
|||
{
|
||||
// Get a new or exisiting entry
|
||||
RuleHashTagTableEntry *entry = static_cast<RuleHashTagTableEntry*>
|
||||
(PL_DHashTableAdd(aTable, aKey));
|
||||
(PL_DHashTableAdd(aTable, aKey, fallible));
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
|
@ -1035,7 +1035,7 @@ RuleCascadeData::AttributeListFor(nsIAtom* aAttribute)
|
|||
{
|
||||
AtomSelectorEntry *entry =
|
||||
static_cast<AtomSelectorEntry*>
|
||||
(PL_DHashTableAdd(&mAttributeSelectors, aAttribute));
|
||||
(PL_DHashTableAdd(&mAttributeSelectors, aAttribute, fallible));
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
return &entry->mSelectors;
|
||||
|
@ -3128,9 +3128,8 @@ AddSelector(RuleCascadeData* aCascade,
|
|||
if (negation == aSelectorInTopLevel) {
|
||||
for (nsAtomList* curID = negation->mIDList; curID;
|
||||
curID = curID->mNext) {
|
||||
AtomSelectorEntry *entry =
|
||||
static_cast<AtomSelectorEntry*>(PL_DHashTableAdd(&aCascade->mIdSelectors,
|
||||
curID->mAtom));
|
||||
AtomSelectorEntry *entry = static_cast<AtomSelectorEntry*>
|
||||
(PL_DHashTableAdd(&aCascade->mIdSelectors, curID->mAtom, fallible));
|
||||
if (entry) {
|
||||
entry->mSelectors.AppendElement(aSelectorInTopLevel);
|
||||
}
|
||||
|
@ -3143,9 +3142,9 @@ AddSelector(RuleCascadeData* aCascade,
|
|||
if (negation == aSelectorInTopLevel) {
|
||||
for (nsAtomList* curClass = negation->mClassList; curClass;
|
||||
curClass = curClass->mNext) {
|
||||
AtomSelectorEntry *entry =
|
||||
static_cast<AtomSelectorEntry*>(PL_DHashTableAdd(&aCascade->mClassSelectors,
|
||||
curClass->mAtom));
|
||||
AtomSelectorEntry *entry = static_cast<AtomSelectorEntry*>
|
||||
(PL_DHashTableAdd(&aCascade->mClassSelectors, curClass->mAtom,
|
||||
fallible));
|
||||
if (entry) {
|
||||
entry->mSelectors.AppendElement(aSelectorInTopLevel);
|
||||
}
|
||||
|
@ -3402,7 +3401,8 @@ CascadeRuleEnumFunc(css::Rule* aRule, void* aData)
|
|||
sel; sel = sel->mNext) {
|
||||
int32_t weight = sel->mWeight;
|
||||
RuleByWeightEntry *entry = static_cast<RuleByWeightEntry*>(
|
||||
PL_DHashTableAdd(&data->mRulesByWeight, NS_INT32_TO_PTR(weight)));
|
||||
PL_DHashTableAdd(&data->mRulesByWeight, NS_INT32_TO_PTR(weight),
|
||||
fallible));
|
||||
if (!entry)
|
||||
return false;
|
||||
entry->data.mWeight = weight;
|
||||
|
|
|
@ -480,8 +480,9 @@ nsHTMLStyleSheet::UniqueMappedAttributes(nsMappedAttributes* aMapped)
|
|||
PL_DHashTableInit(&mMappedAttrTable, &MappedAttrTable_Ops,
|
||||
sizeof(MappedAttrTableEntry));
|
||||
}
|
||||
MappedAttrTableEntry *entry = static_cast<MappedAttrTableEntry*>
|
||||
(PL_DHashTableAdd(&mMappedAttrTable, aMapped));
|
||||
MappedAttrTableEntry *entry =
|
||||
static_cast<MappedAttrTableEntry*>
|
||||
(PL_DHashTableAdd(&mMappedAttrTable, aMapped, fallible));
|
||||
if (!entry)
|
||||
return nullptr;
|
||||
if (!entry->mAttributes) {
|
||||
|
@ -515,7 +516,7 @@ nsHTMLStyleSheet::LangRuleFor(const nsString& aLanguage)
|
|||
sizeof(LangRuleTableEntry));
|
||||
}
|
||||
LangRuleTableEntry *entry = static_cast<LangRuleTableEntry*>
|
||||
(PL_DHashTableAdd(&mLangRuleTable, &aLanguage));
|
||||
(PL_DHashTableAdd(&mLangRuleTable, &aLanguage, fallible));
|
||||
if (!entry) {
|
||||
NS_ASSERTION(false, "out of memory");
|
||||
return nullptr;
|
||||
|
|
|
@ -1533,7 +1533,7 @@ nsRuleNode::Transition(nsIStyleRule* aRule, uint8_t aLevel,
|
|||
|
||||
if (ChildrenAreHashed()) {
|
||||
ChildrenHashEntry *entry = static_cast<ChildrenHashEntry*>
|
||||
(PL_DHashTableAdd(ChildrenHash(), &key));
|
||||
(PL_DHashTableAdd(ChildrenHash(), &key, fallible));
|
||||
if (!entry) {
|
||||
NS_WARNING("out of memory");
|
||||
return this;
|
||||
|
@ -1611,7 +1611,7 @@ nsRuleNode::ConvertChildrenToHash(int32_t aNumKids)
|
|||
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));
|
||||
PL_DHashTableAdd(hash, curr->mRule, fallible));
|
||||
NS_ASSERTION(!entry->mRuleNode, "duplicate entries in list");
|
||||
entry->mRuleNode = curr;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,8 @@ SpanningCellSorter::AddCell(int32_t aColSpan, int32_t aRow, int32_t aCol)
|
|||
sizeof(HashTableEntry));
|
||||
}
|
||||
HashTableEntry *entry = static_cast<HashTableEntry*>
|
||||
(PL_DHashTableAdd(&mHashTable, NS_INT32_TO_PTR(aColSpan)));
|
||||
(PL_DHashTableAdd(&mHashTable, NS_INT32_TO_PTR(aColSpan),
|
||||
fallible));
|
||||
NS_ENSURE_TRUE(entry, false);
|
||||
|
||||
NS_ASSERTION(entry->mColSpan == 0 || entry->mColSpan == aColSpan,
|
||||
|
|
|
@ -740,7 +740,8 @@ nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t
|
|||
if (!gHashTable.IsInitialized())
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PrefHashEntry* pref = static_cast<PrefHashEntry*>(PL_DHashTableAdd(&gHashTable, key));
|
||||
PrefHashEntry* pref = static_cast<PrefHashEntry*>
|
||||
(PL_DHashTableAdd(&gHashTable, key, fallible));
|
||||
|
||||
if (!pref)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
|
|
@ -509,9 +509,8 @@ nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt)
|
|||
// Add the request to the list of active requests...
|
||||
//
|
||||
|
||||
RequestMapEntry *entry =
|
||||
static_cast<RequestMapEntry *>
|
||||
(PL_DHashTableAdd(&mRequests, request));
|
||||
RequestMapEntry *entry = static_cast<RequestMapEntry *>
|
||||
(PL_DHashTableAdd(&mRequests, request, fallible));
|
||||
|
||||
if (!entry) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
|
|
@ -443,7 +443,7 @@ nsCacheEntryHashTable::AddEntry( nsCacheEntry *cacheEntry)
|
|||
if (!initialized) return NS_ERROR_NOT_INITIALIZED;
|
||||
if (!cacheEntry) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
hashEntry = PL_DHashTableAdd(&table, &(cacheEntry->mKey));
|
||||
hashEntry = PL_DHashTableAdd(&table, &(cacheEntry->mKey), fallible);
|
||||
#ifndef DEBUG_dougt
|
||||
NS_ASSERTION(((nsCacheEntryHashTableEntry *)hashEntry)->cacheEntry == 0,
|
||||
"### nsCacheEntryHashTable::AddEntry - entry already used");
|
||||
|
|
|
@ -236,7 +236,8 @@ nsDiskCacheBindery::AddBinding(nsDiskCacheBinding * binding)
|
|||
HashTableEntry * hashEntry;
|
||||
hashEntry = (HashTableEntry *)
|
||||
PL_DHashTableAdd(&table,
|
||||
(void *)(uintptr_t) binding->mRecord.HashNumber());
|
||||
(void *)(uintptr_t) binding->mRecord.HashNumber(),
|
||||
fallible);
|
||||
if (!hashEntry) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (hashEntry->mBinding == nullptr) {
|
||||
|
|
|
@ -765,7 +765,7 @@ nsHostResolver::ResolveHost(const char *host,
|
|||
|
||||
nsHostKey key = { host, flags, af };
|
||||
nsHostDBEnt *he = static_cast<nsHostDBEnt *>
|
||||
(PL_DHashTableAdd(&mDB, &key));
|
||||
(PL_DHashTableAdd(&mDB, &key, fallible));
|
||||
|
||||
// if the record is null, the hash table OOM'd.
|
||||
if (!he) {
|
||||
|
|
|
@ -120,7 +120,7 @@ nsHttp::CreateAtomTable()
|
|||
|
||||
for (int i = 0; atoms[i]; ++i) {
|
||||
PLDHashEntryStub *stub = reinterpret_cast<PLDHashEntryStub *>
|
||||
(PL_DHashTableAdd(&sAtomTable, atoms[i]));
|
||||
(PL_DHashTableAdd(&sAtomTable, atoms[i], fallible));
|
||||
if (!stub)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -168,7 +168,7 @@ nsHttp::ResolveAtom(const char *str)
|
|||
MutexAutoLock lock(*sLock);
|
||||
|
||||
PLDHashEntryStub *stub = reinterpret_cast<PLDHashEntryStub *>
|
||||
(PL_DHashTableAdd(&sAtomTable, str));
|
||||
(PL_DHashTableAdd(&sAtomTable, str, fallible));
|
||||
if (!stub)
|
||||
return atom; // out of memory
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ nsHTMLEntities::AddRefTable(void)
|
|||
// add to Entity->Unicode table
|
||||
EntityNodeEntry* entry =
|
||||
static_cast<EntityNodeEntry*>
|
||||
(PL_DHashTableAdd(&gEntityToUnicode, node->mStr));
|
||||
(PL_DHashTableAdd(&gEntityToUnicode, node->mStr, fallible));
|
||||
NS_ASSERTION(entry, "Error adding an entry");
|
||||
// Prefer earlier entries when we have duplication.
|
||||
if (!entry->node)
|
||||
|
@ -110,7 +110,8 @@ nsHTMLEntities::AddRefTable(void)
|
|||
// add to Unicode->Entity table
|
||||
entry = static_cast<EntityNodeEntry*>
|
||||
(PL_DHashTableAdd(&gUnicodeToEntity,
|
||||
NS_INT32_TO_PTR(node->mUnicode)));
|
||||
NS_INT32_TO_PTR(node->mUnicode),
|
||||
fallible));
|
||||
NS_ASSERTION(entry, "Error adding an entry");
|
||||
// Prefer earlier entries when we have duplication.
|
||||
if (!entry->node)
|
||||
|
|
|
@ -332,7 +332,8 @@ public:
|
|||
void
|
||||
SetForwardArcs(nsIRDFResource* u, Assertion* as) {
|
||||
if (as) {
|
||||
Entry* entry = static_cast<Entry*>(PL_DHashTableAdd(&mForwardArcs, u));
|
||||
Entry* entry = static_cast<Entry*>
|
||||
(PL_DHashTableAdd(&mForwardArcs, u, mozilla::fallible));
|
||||
if (entry) {
|
||||
entry->mNode = u;
|
||||
entry->mAssertions = as;
|
||||
|
@ -346,7 +347,8 @@ public:
|
|||
void
|
||||
SetReverseArcs(nsIRDFNode* v, Assertion* as) {
|
||||
if (as) {
|
||||
Entry* entry = static_cast<Entry*>(PL_DHashTableAdd(&mReverseArcs, v));
|
||||
Entry* entry = static_cast<Entry*>
|
||||
(PL_DHashTableAdd(&mReverseArcs, v, mozilla::fallible));
|
||||
if (entry) {
|
||||
entry->mNode = v;
|
||||
entry->mAssertions = as;
|
||||
|
@ -1184,7 +1186,8 @@ InMemoryDataSource::LockedAssert(nsIRDFResource* aSource,
|
|||
}
|
||||
else
|
||||
{
|
||||
hdr = PL_DHashTableAdd(next->u.hash.mPropertyHash, aProperty);
|
||||
hdr = PL_DHashTableAdd(next->u.hash.mPropertyHash, aProperty,
|
||||
mozilla::fallible);
|
||||
if (hdr)
|
||||
{
|
||||
Entry* entry = static_cast<Entry*>(hdr);
|
||||
|
@ -1295,8 +1298,9 @@ InMemoryDataSource::LockedUnassert(nsIRDFResource* aSource,
|
|||
PL_DHashTableRawRemove(root->u.hash.mPropertyHash, hdr);
|
||||
|
||||
if (next && next->mNext) {
|
||||
PLDHashEntryHdr* hdr = PL_DHashTableAdd(root->u.hash.mPropertyHash,
|
||||
aProperty);
|
||||
PLDHashEntryHdr* hdr =
|
||||
PL_DHashTableAdd(root->u.hash.mPropertyHash, aProperty,
|
||||
mozilla::fallible);
|
||||
if (hdr) {
|
||||
Entry* entry = static_cast<Entry*>(hdr);
|
||||
entry->mNode = aProperty;
|
||||
|
@ -1740,7 +1744,8 @@ InMemoryDataSource::EnsureFastContainment(nsIRDFResource* aSource)
|
|||
val->mNext = first;
|
||||
}
|
||||
else {
|
||||
PLDHashEntryHdr* hdr = PL_DHashTableAdd(table, prop);
|
||||
PLDHashEntryHdr* hdr = PL_DHashTableAdd(table, prop,
|
||||
mozilla::fallible);
|
||||
if (hdr) {
|
||||
Entry* entry = static_cast<Entry*>(hdr);
|
||||
entry->mNode = prop;
|
||||
|
|
|
@ -1162,7 +1162,7 @@ RDFServiceImpl::RegisterResource(nsIRDFResource* aResource, bool aReplace)
|
|||
aResource, (const char*) uri));
|
||||
}
|
||||
else {
|
||||
hdr = PL_DHashTableAdd(&mResources, uri);
|
||||
hdr = PL_DHashTableAdd(&mResources, uri, fallible);
|
||||
if (! hdr)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -1399,7 +1399,7 @@ RDFServiceImpl::RegisterLiteral(nsIRDFLiteral* aLiteral)
|
|||
NS_ASSERTION(!PL_DHashTableSearch(&mLiterals, value),
|
||||
"literal already registered");
|
||||
|
||||
PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mLiterals, value);
|
||||
PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mLiterals, value, fallible);
|
||||
if (! hdr)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -1451,7 +1451,7 @@ RDFServiceImpl::RegisterInt(nsIRDFInt* aInt)
|
|||
NS_ASSERTION(!PL_DHashTableSearch(&mInts, &value),
|
||||
"int already registered");
|
||||
|
||||
PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mInts, &value);
|
||||
PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mInts, &value, fallible);
|
||||
if (! hdr)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -1503,7 +1503,7 @@ RDFServiceImpl::RegisterDate(nsIRDFDate* aDate)
|
|||
NS_ASSERTION(!PL_DHashTableSearch(&mDates, &value),
|
||||
"date already registered");
|
||||
|
||||
PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mDates, &value);
|
||||
PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mDates, &value, fallible);
|
||||
if (! hdr)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@ -1550,7 +1550,7 @@ RDFServiceImpl::RegisterBlob(BlobImpl *aBlob)
|
|||
NS_ASSERTION(!PL_DHashTableSearch(&mBlobs, &aBlob->mData),
|
||||
"blob already registered");
|
||||
|
||||
PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mBlobs, &aBlob->mData);
|
||||
PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mBlobs, &aBlob->mData, fallible);
|
||||
if (! hdr)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
|
|
@ -860,8 +860,8 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
|
|||
// means, there has already been data transfered.
|
||||
|
||||
ReentrantMonitorAutoEnter lock(mReentrantMonitor);
|
||||
PL_DHashTableAdd(&mTransferringRequests, aRequest);
|
||||
|
||||
PL_DHashTableAdd(&mTransferringRequests, aRequest, fallible);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -199,9 +199,8 @@ CompareCacheHashEntry *
|
|||
nsCertTree::getCacheEntry(void *cache, void *aCert)
|
||||
{
|
||||
PLDHashTable &aCompareCache = *reinterpret_cast<PLDHashTable*>(cache);
|
||||
CompareCacheHashEntryPtr *entryPtr =
|
||||
static_cast<CompareCacheHashEntryPtr*>
|
||||
(PL_DHashTableAdd(&aCompareCache, aCert));
|
||||
CompareCacheHashEntryPtr *entryPtr = static_cast<CompareCacheHashEntryPtr*>
|
||||
(PL_DHashTableAdd(&aCompareCache, aCert, fallible));
|
||||
return entryPtr ? entryPtr->entry : nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ void nsNSSShutDownList::remember(nsNSSShutDownObject *o)
|
|||
|
||||
PR_ASSERT(o);
|
||||
MutexAutoLock lock(singleton->mListLock);
|
||||
PL_DHashTableAdd(&singleton->mObjects, o);
|
||||
PL_DHashTableAdd(&singleton->mObjects, o, fallible);
|
||||
}
|
||||
|
||||
void nsNSSShutDownList::forget(nsNSSShutDownObject *o)
|
||||
|
@ -88,7 +88,7 @@ void nsNSSShutDownList::remember(nsOnPK11LogoutCancelObject *o)
|
|||
|
||||
PR_ASSERT(o);
|
||||
MutexAutoLock lock(singleton->mListLock);
|
||||
PL_DHashTableAdd(&singleton->mPK11LogoutCancelObjects, o);
|
||||
PL_DHashTableAdd(&singleton->mPK11LogoutCancelObjects, o, fallible);
|
||||
}
|
||||
|
||||
void nsNSSShutDownList::forget(nsOnPK11LogoutCancelObject *o)
|
||||
|
|
|
@ -1338,7 +1338,7 @@ nsDocLoader::RefreshAttempted(nsIWebProgress* aWebProgress,
|
|||
|
||||
nsresult nsDocLoader::AddRequestInfo(nsIRequest *aRequest)
|
||||
{
|
||||
if (!PL_DHashTableAdd(&mRequestInfoHash, aRequest)) {
|
||||
if (!PL_DHashTableAdd(&mRequestInfoHash, aRequest, mozilla::fallible)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
|
|
@ -900,8 +900,8 @@ PtrToNodeEntry*
|
|||
CCGraph::AddNodeToMap(void* aPtr)
|
||||
{
|
||||
JS::AutoSuppressGCAnalysis suppress;
|
||||
PtrToNodeEntry* e =
|
||||
static_cast<PtrToNodeEntry*>(PL_DHashTableAdd(&mPtrToNodeMap, aPtr));
|
||||
PtrToNodeEntry* e = static_cast<PtrToNodeEntry*>
|
||||
(PL_DHashTableAdd(&mPtrToNodeMap, aPtr, fallible));
|
||||
if (!e) {
|
||||
// Caller should track OOMs
|
||||
return nullptr;
|
||||
|
|
|
@ -553,12 +553,8 @@ GetAtomHashEntry(const char* aString, uint32_t aLength, uint32_t* aHashOut)
|
|||
MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
|
||||
EnsureTableExists();
|
||||
AtomTableKey key(aString, aLength, aHashOut);
|
||||
AtomTableEntry* e = static_cast<AtomTableEntry*>(
|
||||
PL_DHashTableAdd(&gAtomTable, &key));
|
||||
if (!e) {
|
||||
NS_ABORT_OOM(gAtomTable.EntryCount() * gAtomTable.EntrySize());
|
||||
}
|
||||
return e;
|
||||
// This is an infallible add.
|
||||
return static_cast<AtomTableEntry*>(PL_DHashTableAdd(&gAtomTable, &key));
|
||||
}
|
||||
|
||||
static inline AtomTableEntry*
|
||||
|
@ -567,12 +563,8 @@ GetAtomHashEntry(const char16_t* aString, uint32_t aLength, uint32_t* aHashOut)
|
|||
MOZ_ASSERT(NS_IsMainThread(), "wrong thread");
|
||||
EnsureTableExists();
|
||||
AtomTableKey key(aString, aLength, aHashOut);
|
||||
AtomTableEntry* e = static_cast<AtomTableEntry*>(
|
||||
PL_DHashTableAdd(&gAtomTable, &key));
|
||||
if (!e) {
|
||||
NS_ABORT_OOM(gAtomTable.EntryCount() * gAtomTable.EntrySize());
|
||||
}
|
||||
return e;
|
||||
// This is an infallible add.
|
||||
return static_cast<AtomTableEntry*>(PL_DHashTableAdd(&gAtomTable, &key));
|
||||
}
|
||||
|
||||
class CheckStaticAtomSizes
|
||||
|
|
|
@ -528,7 +528,7 @@ nsPersistentProperties::SetStringProperty(const nsACString& aKey,
|
|||
{
|
||||
const nsAFlatCString& flatKey = PromiseFlatCString(aKey);
|
||||
PropertyTableEntry* entry = static_cast<PropertyTableEntry*>(
|
||||
PL_DHashTableAdd(&mTable, flatKey.get()));
|
||||
PL_DHashTableAdd(&mTable, flatKey.get(), mozilla::fallible));
|
||||
|
||||
if (entry->mKey) {
|
||||
aOldValue = entry->mValue;
|
||||
|
|
|
@ -164,8 +164,8 @@ nsStaticCaseInsensitiveNameTable::Init(const char* const aNames[],
|
|||
|
||||
NameTableKey key(strPtr);
|
||||
|
||||
NameTableEntry* entry =
|
||||
static_cast<NameTableEntry*>(PL_DHashTableAdd(&mNameTable, &key));
|
||||
NameTableEntry* entry = static_cast<NameTableEntry*>
|
||||
(PL_DHashTableAdd(&mNameTable, &key, fallible));
|
||||
if (!entry) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -149,19 +149,21 @@ public:
|
|||
*/
|
||||
EntryType* PutEntry(KeyType aKey)
|
||||
{
|
||||
EntryType* e = PutEntry(aKey, mozilla::fallible);
|
||||
if (!e) {
|
||||
NS_ABORT_OOM(mTable.EntrySize() * mTable.EntryCount());
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
EntryType* PutEntry(KeyType aKey, const fallible_t&) NS_WARN_UNUSED_RESULT {
|
||||
NS_ASSERTION(mTable.IsInitialized(),
|
||||
"nsTHashtable was not initialized properly.");
|
||||
|
||||
return static_cast<EntryType*>(PL_DHashTableAdd(
|
||||
&mTable, EntryType::KeyToPointer(aKey)));
|
||||
return static_cast<EntryType*> // infallible add
|
||||
(PL_DHashTableAdd(&mTable, EntryType::KeyToPointer(aKey)));
|
||||
}
|
||||
|
||||
EntryType* PutEntry(KeyType aKey, const fallible_t&) NS_WARN_UNUSED_RESULT
|
||||
{
|
||||
NS_ASSERTION(mTable.IsInitialized(),
|
||||
"nsTHashtable was not initialized properly.");
|
||||
|
||||
return static_cast<EntryType*>
|
||||
(PL_DHashTableAdd(&mTable, EntryType::KeyToPointer(aKey),
|
||||
mozilla::fallible));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -570,7 +570,7 @@ PLDHashTable::Search(const void* aKey)
|
|||
}
|
||||
|
||||
MOZ_ALWAYS_INLINE PLDHashEntryHdr*
|
||||
PLDHashTable::Add(const void* aKey)
|
||||
PLDHashTable::Add(const void* aKey, const mozilla::fallible_t&)
|
||||
{
|
||||
PLDHashNumber keyHash;
|
||||
PLDHashEntryHdr* entry;
|
||||
|
@ -671,10 +671,24 @@ PL_DHashTableSearch(PLDHashTable* aTable, const void* aKey)
|
|||
return aTable->Search(aKey);
|
||||
}
|
||||
|
||||
PLDHashEntryHdr* PL_DHASH_FASTCALL
|
||||
PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey,
|
||||
const fallible_t& aFallible)
|
||||
{
|
||||
return aTable->Add(aKey, aFallible);
|
||||
}
|
||||
|
||||
PLDHashEntryHdr* PL_DHASH_FASTCALL
|
||||
PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey)
|
||||
{
|
||||
return aTable->Add(aKey);
|
||||
PLDHashEntryHdr* entry = PL_DHashTableAdd(aTable, aKey, fallible);
|
||||
if (!entry) {
|
||||
// There are two ways the Add could fail: (a) a entry storage reallocation
|
||||
// failed, or (b) mOps->initEntry failed. The number we're reporting here
|
||||
// is the one for case (a), which is the more likely of the two.
|
||||
NS_ABORT_OOM(aTable->EntrySize() * aTable->EntryCount());
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
void PL_DHASH_FASTCALL
|
||||
|
|
|
@ -244,7 +244,7 @@ public:
|
|||
void Finish();
|
||||
|
||||
PLDHashEntryHdr* Search(const void* aKey);
|
||||
PLDHashEntryHdr* Add(const void* aKey);
|
||||
PLDHashEntryHdr* Add(const void* aKey, const mozilla::fallible_t&);
|
||||
void Remove(const void* aKey);
|
||||
|
||||
void RawRemove(PLDHashEntryHdr* aEntry);
|
||||
|
@ -481,7 +481,7 @@ PL_DHashTableSearch(PLDHashTable* aTable, const void* aKey);
|
|||
/*
|
||||
* To add an entry identified by key to table, call:
|
||||
*
|
||||
* entry = PL_DHashTableAdd(table, key);
|
||||
* entry = PL_DHashTableAdd(table, key, mozilla::fallible);
|
||||
*
|
||||
* If entry is null upon return, then either (a) the table is severely
|
||||
* overloaded and memory can't be allocated for entry storage, or (b)
|
||||
|
@ -495,6 +495,14 @@ PL_DHashTableSearch(PLDHashTable* aTable, const void* aKey);
|
|||
* optional initEntry hook was not used).
|
||||
*/
|
||||
PLDHashEntryHdr* PL_DHASH_FASTCALL
|
||||
PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey,
|
||||
const mozilla::fallible_t&);
|
||||
|
||||
/*
|
||||
* This is like the other PL_DHashTableAdd() function, but infallible, and so
|
||||
* never returns null.
|
||||
*/
|
||||
PLDHashEntryHdr* PL_DHASH_FASTCALL
|
||||
PL_DHashTableAdd(PLDHashTable* aTable, const void* aKey);
|
||||
|
||||
/*
|
||||
|
|
|
@ -138,7 +138,7 @@ static bool test_pldhash_grow_to_max_capacity()
|
|||
// Keep inserting elements until failure occurs because the table is full.
|
||||
size_t numInserted = 0;
|
||||
while (true) {
|
||||
if (!PL_DHashTableAdd(t, (const void*)numInserted)) {
|
||||
if (!PL_DHashTableAdd(t, (const void*)numInserted, mozilla::fallible)) {
|
||||
break;
|
||||
}
|
||||
numInserted++;
|
||||
|
|
Загрузка…
Ссылка в новой задаче