forked from mirrors/gecko-dev
Bug 1131199, part 2 - Make PLDHashtInitEntry infallible. r=froydnj
Also, drop the unused table argument.
This commit is contained in:
parent
6ec7fe58dd
commit
31ba9aaed9
16 changed files with 37 additions and 76 deletions
|
|
@ -379,13 +379,11 @@ public:
|
||||||
nsRefPtr<EventListenerManager> mListenerManager;
|
nsRefPtr<EventListenerManager> mListenerManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
EventListenerManagerHashInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
|
EventListenerManagerHashInitEntry(PLDHashEntryHdr *entry, const void *key)
|
||||||
const void *key)
|
|
||||||
{
|
{
|
||||||
// Initialize the entry with placement new
|
// Initialize the entry with placement new
|
||||||
new (entry) EventListenerManagerMapEntry(key);
|
new (entry) EventListenerManagerMapEntry(key);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -3957,8 +3957,8 @@ SubDocClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
SubDocInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry, const void *key)
|
SubDocInitEntry(PLDHashEntryHdr *entry, const void *key)
|
||||||
{
|
{
|
||||||
SubDocMapEntry *e =
|
SubDocMapEntry *e =
|
||||||
const_cast<SubDocMapEntry *>
|
const_cast<SubDocMapEntry *>
|
||||||
|
|
@ -3968,7 +3968,6 @@ SubDocInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry, const void *key)
|
||||||
NS_ADDREF(e->mKey);
|
NS_ADDREF(e->mKey);
|
||||||
|
|
||||||
e->mSubDocument = nullptr;
|
e->mSubDocument = nullptr;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|
|
||||||
|
|
@ -99,9 +99,8 @@ GlobalNameHashClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
|
||||||
memset(&e->mGlobalName, 0, sizeof(nsGlobalNameStruct));
|
memset(&e->mGlobalName, 0, sizeof(nsGlobalNameStruct));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
GlobalNameHashInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
|
GlobalNameHashInitEntry(PLDHashEntryHdr *entry, const void *key)
|
||||||
const void *key)
|
|
||||||
{
|
{
|
||||||
GlobalNameMapEntry *e = static_cast<GlobalNameMapEntry *>(entry);
|
GlobalNameMapEntry *e = static_cast<GlobalNameMapEntry *>(entry);
|
||||||
const nsAString *keyStr = static_cast<const nsAString *>(key);
|
const nsAString *keyStr = static_cast<const nsAString *>(key);
|
||||||
|
|
@ -112,7 +111,6 @@ GlobalNameHashInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
|
||||||
// This will set e->mGlobalName.mType to
|
// This will set e->mGlobalName.mType to
|
||||||
// nsGlobalNameStruct::eTypeNotInitialized
|
// nsGlobalNameStruct::eTypeNotInitialized
|
||||||
memset(&e->mGlobalName, 0, sizeof(nsGlobalNameStruct));
|
memset(&e->mGlobalName, 0, sizeof(nsGlobalNameStruct));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(
|
NS_IMPL_ISUPPORTS(
|
||||||
|
|
|
||||||
|
|
@ -244,13 +244,11 @@ RuleHash_CSMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
||||||
return match_atom == entry_atom;
|
return match_atom == entry_atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
RuleHash_InitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
RuleHash_InitEntry(PLDHashEntryHdr *hdr, const void *key)
|
||||||
const void *key)
|
|
||||||
{
|
{
|
||||||
RuleHashTableEntry* entry = static_cast<RuleHashTableEntry*>(hdr);
|
RuleHashTableEntry* entry = static_cast<RuleHashTableEntry*>(hdr);
|
||||||
new (entry) RuleHashTableEntry();
|
new (entry) RuleHashTableEntry();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -284,14 +282,12 @@ RuleHash_TagTable_MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
||||||
return match_atom == entry_atom;
|
return match_atom == entry_atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
RuleHash_TagTable_InitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
RuleHash_TagTable_InitEntry(PLDHashEntryHdr *hdr, const void *key)
|
||||||
const void *key)
|
|
||||||
{
|
{
|
||||||
RuleHashTagTableEntry* entry = static_cast<RuleHashTagTableEntry*>(hdr);
|
RuleHashTagTableEntry* entry = static_cast<RuleHashTagTableEntry*>(hdr);
|
||||||
new (entry) RuleHashTagTableEntry();
|
new (entry) RuleHashTagTableEntry();
|
||||||
entry->mTag = const_cast<nsIAtom*>(static_cast<const nsIAtom*>(key));
|
entry->mTag = const_cast<nsIAtom*>(static_cast<const nsIAtom*>(key));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -836,14 +832,12 @@ AtomSelector_ClearEntry(PLDHashTable *table, PLDHashEntryHdr *hdr)
|
||||||
(static_cast<AtomSelectorEntry*>(hdr))->~AtomSelectorEntry();
|
(static_cast<AtomSelectorEntry*>(hdr))->~AtomSelectorEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
AtomSelector_InitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
AtomSelector_InitEntry(PLDHashEntryHdr *hdr, const void *key)
|
||||||
const void *key)
|
|
||||||
{
|
{
|
||||||
AtomSelectorEntry *entry = static_cast<AtomSelectorEntry*>(hdr);
|
AtomSelectorEntry *entry = static_cast<AtomSelectorEntry*>(hdr);
|
||||||
new (entry) AtomSelectorEntry();
|
new (entry) AtomSelectorEntry();
|
||||||
entry->mAtom = const_cast<nsIAtom*>(static_cast<const nsIAtom*>(key));
|
entry->mAtom = const_cast<nsIAtom*>(static_cast<const nsIAtom*>(key));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -3320,13 +3314,11 @@ MatchWeightEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
||||||
return entry->data.mWeight == NS_PTR_TO_INT32(key);
|
return entry->data.mWeight == NS_PTR_TO_INT32(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
InitWeightEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
InitWeightEntry(PLDHashEntryHdr *hdr, const void *key)
|
||||||
const void *key)
|
|
||||||
{
|
{
|
||||||
RuleByWeightEntry* entry = static_cast<RuleByWeightEntry*>(hdr);
|
RuleByWeightEntry* entry = static_cast<RuleByWeightEntry*>(hdr);
|
||||||
new (entry) RuleByWeightEntry();
|
new (entry) RuleByWeightEntry();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const PLDHashTableOps gRulesByWeightOps = {
|
static const PLDHashTableOps gRulesByWeightOps = {
|
||||||
|
|
|
||||||
|
|
@ -208,9 +208,8 @@ LangRuleTable_MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
||||||
return entry->mRule->mLang == *lang;
|
return entry->mRule->mLang == *lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
LangRuleTable_InitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
LangRuleTable_InitEntry(PLDHashEntryHdr *hdr, const void *key)
|
||||||
const void *key)
|
|
||||||
{
|
{
|
||||||
const nsString *lang = static_cast<const nsString*>(key);
|
const nsString *lang = static_cast<const nsString*>(key);
|
||||||
|
|
||||||
|
|
@ -218,8 +217,6 @@ LangRuleTable_InitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||||
|
|
||||||
// Create the unique rule for this language
|
// Create the unique rule for this language
|
||||||
entry->mRule = new nsHTMLStyleSheet::LangRule(*lang);
|
entry->mRule = new nsHTMLStyleSheet::LangRule(*lang);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const PLDHashTableOps LangRuleTable_Ops = {
|
static const PLDHashTableOps LangRuleTable_Ops = {
|
||||||
|
|
|
||||||
|
|
@ -78,16 +78,14 @@ RequestHashClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
|
||||||
e->~RequestMapEntry();
|
e->~RequestMapEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
RequestHashInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
|
RequestHashInitEntry(PLDHashEntryHdr *entry, const void *key)
|
||||||
const void *key)
|
|
||||||
{
|
{
|
||||||
const nsIRequest *const_request = static_cast<const nsIRequest *>(key);
|
const nsIRequest *const_request = static_cast<const nsIRequest *>(key);
|
||||||
nsIRequest *request = const_cast<nsIRequest *>(const_request);
|
nsIRequest *request = const_cast<nsIRequest *>(const_request);
|
||||||
|
|
||||||
// Initialize the entry with placement new
|
// Initialize the entry with placement new
|
||||||
new (entry) RequestMapEntry(request);
|
new (entry) RequestMapEntry(request);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -459,14 +459,12 @@ HostDB_ClearEntry(PLDHashTable *table,
|
||||||
NS_RELEASE(he->rec);
|
NS_RELEASE(he->rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
HostDB_InitEntry(PLDHashTable *table,
|
HostDB_InitEntry(PLDHashEntryHdr *entry,
|
||||||
PLDHashEntryHdr *entry,
|
|
||||||
const void *key)
|
const void *key)
|
||||||
{
|
{
|
||||||
nsHostDBEnt *he = static_cast<nsHostDBEnt *>(entry);
|
nsHostDBEnt *he = static_cast<nsHostDBEnt *>(entry);
|
||||||
nsHostRecord::Create(static_cast<const nsHostKey *>(key), &he->rec);
|
nsHostRecord::Create(static_cast<const nsHostKey *>(key), &he->rec);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const PLDHashTableOps gHostDB_ops =
|
static const PLDHashTableOps gHostDB_ops =
|
||||||
|
|
|
||||||
|
|
@ -63,13 +63,11 @@ RequestMapMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
||||||
return entry->r == key;
|
return entry->r == key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
RequestMapInitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
RequestMapInitEntry(PLDHashEntryHdr *hdr, const void *key)
|
||||||
const void *key)
|
|
||||||
{
|
{
|
||||||
RequestHashEntry *entry = static_cast<RequestHashEntry*>(hdr);
|
RequestHashEntry *entry = static_cast<RequestHashEntry*>(hdr);
|
||||||
entry->r = (void*)key;
|
entry->r = (void*)key;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const PLDHashTableOps gMapOps = {
|
static const PLDHashTableOps gMapOps = {
|
||||||
|
|
|
||||||
|
|
@ -71,14 +71,12 @@ CompareCacheMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
||||||
return entryPtr->entry->key == key;
|
return entryPtr->entry->key == key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
CompareCacheInitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
CompareCacheInitEntry(PLDHashEntryHdr *hdr, const void *key)
|
||||||
const void *key)
|
|
||||||
{
|
{
|
||||||
new (hdr) CompareCacheHashEntryPtr();
|
new (hdr) CompareCacheHashEntryPtr();
|
||||||
CompareCacheHashEntryPtr *entryPtr = static_cast<CompareCacheHashEntryPtr*>(hdr);
|
CompareCacheHashEntryPtr *entryPtr = static_cast<CompareCacheHashEntryPtr*>(hdr);
|
||||||
entryPtr->entry->key = (void*)key;
|
entryPtr->entry->key = (void*)key;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,11 @@ ObjectSetMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
|
||||||
return entry->obj == static_cast<const nsNSSShutDownObject*>(key);
|
return entry->obj == static_cast<const nsNSSShutDownObject*>(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
ObjectSetInitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
ObjectSetInitEntry(PLDHashEntryHdr *hdr, const void *key)
|
||||||
const void *key)
|
|
||||||
{
|
{
|
||||||
ObjectHashEntry *entry = static_cast<ObjectHashEntry*>(hdr);
|
ObjectHashEntry *entry = static_cast<ObjectHashEntry*>(hdr);
|
||||||
entry->obj = const_cast<nsNSSShutDownObject*>(static_cast<const nsNSSShutDownObject*>(key));
|
entry->obj = const_cast<nsNSSShutDownObject*>(static_cast<const nsNSSShutDownObject*>(key));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const PLDHashTableOps gSetOps = {
|
static const PLDHashTableOps gSetOps = {
|
||||||
|
|
|
||||||
|
|
@ -64,14 +64,12 @@ void GetURIStringFromRequest(nsIRequest* request, nsACString &name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
void
|
||||||
nsDocLoader::RequestInfoHashInitEntry(PLDHashTable* table,
|
nsDocLoader::RequestInfoHashInitEntry(PLDHashEntryHdr* entry,
|
||||||
PLDHashEntryHdr* entry,
|
|
||||||
const void* key)
|
const void* key)
|
||||||
{
|
{
|
||||||
// Initialize the entry with placement new
|
// Initialize the entry with placement new
|
||||||
new (entry) nsRequestInfo(key);
|
new (entry) nsRequestInfo(key);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -246,8 +246,7 @@ protected:
|
||||||
nsAutoPtr<nsStatusInfo> mLastStatus;
|
nsAutoPtr<nsStatusInfo> mLastStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool RequestInfoHashInitEntry(PLDHashTable* table, PLDHashEntryHdr* entry,
|
static void RequestInfoHashInitEntry(PLDHashEntryHdr* entry, const void* key);
|
||||||
const void* key);
|
|
||||||
static void RequestInfoHashClearEntry(PLDHashTable* table, PLDHashEntryHdr* entry);
|
static void RequestInfoHashClearEntry(PLDHashTable* table, PLDHashEntryHdr* entry);
|
||||||
|
|
||||||
// IMPORTANT: The ownership implicit in the following member
|
// IMPORTANT: The ownership implicit in the following member
|
||||||
|
|
|
||||||
|
|
@ -283,13 +283,10 @@ AtomTableClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
AtomTableInitEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry,
|
AtomTableInitEntry(PLDHashEntryHdr* aEntry, const void* aKey)
|
||||||
const void* aKey)
|
|
||||||
{
|
{
|
||||||
static_cast<AtomTableEntry*>(aEntry)->mAtom = nullptr;
|
static_cast<AtomTableEntry*>(aEntry)->mAtom = nullptr;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -335,8 +335,7 @@ protected:
|
||||||
|
|
||||||
static void s_ClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
|
static void s_ClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
|
||||||
|
|
||||||
static bool s_InitEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry,
|
static void s_InitEntry(PLDHashEntryHdr* aEntry, const void* aKey);
|
||||||
const void* aKey);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* passed internally during enumeration. Allocated on the stack.
|
* passed internally during enumeration. Allocated on the stack.
|
||||||
|
|
@ -486,13 +485,11 @@ nsTHashtable<EntryType>::s_ClearEntry(PLDHashTable* aTable,
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class EntryType>
|
template<class EntryType>
|
||||||
bool
|
void
|
||||||
nsTHashtable<EntryType>::s_InitEntry(PLDHashTable* aTable,
|
nsTHashtable<EntryType>::s_InitEntry(PLDHashEntryHdr* aEntry,
|
||||||
PLDHashEntryHdr* aEntry,
|
|
||||||
const void* aKey)
|
const void* aKey)
|
||||||
{
|
{
|
||||||
new (aEntry) EntryType(reinterpret_cast<KeyTypePointer>(aKey));
|
new (aEntry) EntryType(reinterpret_cast<KeyTypePointer>(aKey));
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class EntryType>
|
template<class EntryType>
|
||||||
|
|
|
||||||
|
|
@ -622,11 +622,8 @@ PLDHashTable::Add(const void* aKey)
|
||||||
mRemovedCount--;
|
mRemovedCount--;
|
||||||
keyHash |= COLLISION_FLAG;
|
keyHash |= COLLISION_FLAG;
|
||||||
}
|
}
|
||||||
if (mOps->initEntry && !mOps->initEntry(this, entry, aKey)) {
|
if (mOps->initEntry) {
|
||||||
/* We haven't claimed entry yet; fail with null return. */
|
mOps->initEntry(entry, aKey);
|
||||||
memset(entry + 1, 0, mEntrySize - sizeof(*entry));
|
|
||||||
entry = nullptr;
|
|
||||||
goto exit;
|
|
||||||
}
|
}
|
||||||
entry->mKeyHash = keyHash;
|
entry->mKeyHash = keyHash;
|
||||||
mEntryCount++;
|
mEntryCount++;
|
||||||
|
|
|
||||||
|
|
@ -349,8 +349,7 @@ typedef void (*PLDHashClearEntry)(PLDHashTable* aTable,
|
||||||
* new one. At that point, aEntry->mKeyHash is not set yet, to avoid claiming
|
* new one. At that point, aEntry->mKeyHash is not set yet, to avoid claiming
|
||||||
* the last free entry in a severely overloaded table.
|
* the last free entry in a severely overloaded table.
|
||||||
*/
|
*/
|
||||||
typedef bool (*PLDHashInitEntry)(PLDHashTable* aTable, PLDHashEntryHdr* aEntry,
|
typedef void (*PLDHashInitEntry)(PLDHashEntryHdr* aEntry, const void* aKey);
|
||||||
const void* aKey);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finally, the "vtable" structure for PLDHashTable. The first four hooks
|
* Finally, the "vtable" structure for PLDHashTable. The first four hooks
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue