Bug 1121304 (part 2) - Remove PLDHashTableOps::{alloc,free}Table. r=froydnj.

This commit is contained in:
Nicholas Nethercote 2015-01-14 14:35:56 -08:00
parent 41dc319a7c
commit e9735966fa
33 changed files with 13 additions and 145 deletions

View File

@ -208,8 +208,6 @@ NS_GetContentList(nsINode* aRootNode,
static const PLDHashTableOps hash_table_ops =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
ContentListHashtableHashKey,
ContentListHashtableMatchEntry,
PL_DHashMoveEntryStub,
@ -320,8 +318,6 @@ GetFuncStringContentList(nsINode* aRootNode,
static const PLDHashTableOps hash_table_ops =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
FuncStringContentListHashtableHashKey,
FuncStringContentListHashtableMatchEntry,
PL_DHashMoveEntryStub,

View File

@ -479,8 +479,6 @@ nsContentUtils::Init()
if (!sEventListenerManagersHash.ops) {
static const PLDHashTableOps hash_table_ops =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
PL_DHashMatchEntryStub,
PL_DHashMoveEntryStub,

View File

@ -3972,8 +3972,6 @@ nsDocument::SetSubDocumentFor(Element* aElement, nsIDocument* aSubDoc)
static const PLDHashTableOps hash_table_ops =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
PL_DHashMatchEntryStub,
PL_DHashMoveEntryStub,

View File

@ -320,8 +320,6 @@ nsScriptNameSpaceManager::Init()
{
static const PLDHashTableOps hash_table_ops =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
GlobalNameHashHashKey,
GlobalNameHashMatchEntry,
PL_DHashMoveEntryStub,

View File

@ -760,8 +760,6 @@ XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener,
}
static const PLDHashTableOps gOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
PL_DHashMatchEntryStub,
PL_DHashMoveEntryStub,

View File

@ -16,8 +16,6 @@ using namespace mozilla;
const PLDHashTableOps nsCommandParams::sHashOps =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
HashKey,
HashMatchEntry,
HashMoveEntry,

View File

@ -622,8 +622,6 @@ public:
: mWriteNeeded(false)
{
mOps = (PLDHashTableOps) {
PL_DHashAllocTable,
PL_DHashFreeTable,
StringHash,
HashMatchEntry,
MoveEntry,

View File

@ -212,8 +212,6 @@ Native2WrappedNativeMap::SizeOfEntryExcludingThis(PLDHashEntryHdr *hdr,
const struct PLDHashTableOps IID2WrappedJSClassMap::Entry::sOps =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
HashIIDPtrKey,
MatchIIDPtrKey,
PL_DHashMoveEntryStub,
@ -248,8 +246,6 @@ IID2WrappedJSClassMap::~IID2WrappedJSClassMap()
const struct PLDHashTableOps IID2NativeInterfaceMap::Entry::sOps =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
HashIIDPtrKey,
MatchIIDPtrKey,
PL_DHashMoveEntryStub,
@ -452,8 +448,6 @@ NativeSetMap::Entry::Match(PLDHashTable *table,
const struct PLDHashTableOps NativeSetMap::Entry::sOps =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
HashNativeKey,
Match,
PL_DHashMoveEntryStub,
@ -518,8 +512,6 @@ IID2ThisTranslatorMap::Entry::Clear(PLDHashTable *table, PLDHashEntryHdr *entry)
const struct PLDHashTableOps IID2ThisTranslatorMap::Entry::sOps =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
HashIIDPtrKey,
Match,
PL_DHashMoveEntryStub,
@ -596,8 +588,6 @@ XPCNativeScriptableSharedMap::Entry::Match(PLDHashTable *table,
const struct PLDHashTableOps XPCNativeScriptableSharedMap::Entry::sOps =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
Hash,
Match,
PL_DHashMoveEntryStub,

View File

@ -69,8 +69,6 @@ PlaceholderMapMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
}
static const PLDHashTableOps PlaceholderMapOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
PlaceholderMapMatchEntry,
PL_DHashMoveEntryStub,

View File

@ -362,8 +362,6 @@ RuleHash_NameSpaceTable_MatchEntry(PLDHashTable *table,
}
static const PLDHashTableOps RuleHash_TagTable_Ops = {
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
RuleHash_TagTable_MatchEntry,
RuleHash_TagTable_MoveEntry,
@ -374,8 +372,6 @@ static const PLDHashTableOps RuleHash_TagTable_Ops = {
// Case-sensitive ops.
static const RuleHashTableOps RuleHash_ClassTable_CSOps = {
{
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
RuleHash_CSMatchEntry,
RuleHash_MoveEntry,
@ -388,8 +384,6 @@ static const RuleHashTableOps RuleHash_ClassTable_CSOps = {
// Case-insensitive ops.
static const RuleHashTableOps RuleHash_ClassTable_CIOps = {
{
PL_DHashAllocTable,
PL_DHashFreeTable,
RuleHash_CIHashKey,
RuleHash_CIMatchEntry,
RuleHash_MoveEntry,
@ -402,8 +396,6 @@ static const RuleHashTableOps RuleHash_ClassTable_CIOps = {
// Case-sensitive ops.
static const RuleHashTableOps RuleHash_IdTable_CSOps = {
{
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
RuleHash_CSMatchEntry,
RuleHash_MoveEntry,
@ -416,8 +408,6 @@ static const RuleHashTableOps RuleHash_IdTable_CSOps = {
// Case-insensitive ops.
static const RuleHashTableOps RuleHash_IdTable_CIOps = {
{
PL_DHashAllocTable,
PL_DHashFreeTable,
RuleHash_CIHashKey,
RuleHash_CIMatchEntry,
RuleHash_MoveEntry,
@ -428,8 +418,6 @@ static const RuleHashTableOps RuleHash_IdTable_CIOps = {
};
static const PLDHashTableOps RuleHash_NameSpaceTable_Ops = {
PL_DHashAllocTable,
PL_DHashFreeTable,
RuleHash_NameSpaceTable_HashKey,
RuleHash_NameSpaceTable_MatchEntry,
RuleHash_MoveEntry,
@ -887,8 +875,6 @@ AtomSelector_GetKey(PLDHashTable *table, const PLDHashEntryHdr *hdr)
// Case-sensitive ops.
static const PLDHashTableOps AtomSelector_CSOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
PL_DHashMatchEntryStub,
AtomSelector_MoveEntry,
@ -899,8 +885,6 @@ static const PLDHashTableOps AtomSelector_CSOps = {
// Case-insensitive ops.
static const RuleHashTableOps AtomSelector_CIOps = {
{
PL_DHashAllocTable,
PL_DHashFreeTable,
RuleHash_CIHashKey,
RuleHash_CIMatchEntry,
AtomSelector_MoveEntry,
@ -3337,8 +3321,6 @@ InitWeightEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
}
static const PLDHashTableOps gRulesByWeightOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
HashIntKey,
MatchWeightEntry,
PL_DHashMoveEntryStub,

View File

@ -169,8 +169,6 @@ MappedAttrTable_MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr,
}
static const PLDHashTableOps MappedAttrTable_Ops = {
PL_DHashAllocTable,
PL_DHashFreeTable,
MappedAttrTable_HashKey,
MappedAttrTable_MatchEntry,
PL_DHashMoveEntryStub,
@ -225,8 +223,6 @@ LangRuleTable_InitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
}
static const PLDHashTableOps LangRuleTable_Ops = {
PL_DHashAllocTable,
PL_DHashFreeTable,
LangRuleTable_HashKey,
LangRuleTable_MatchEntry,
PL_DHashMoveEntryStub,

View File

@ -114,8 +114,6 @@ nsRuleNode::ChildrenHashOps = {
// free rather than the pres shell's arena because the table doesn't
// grow very often and the pres shell's arena doesn't recycle very
// large size allocations.
PL_DHashAllocTable,
PL_DHashFreeTable,
ChildrenHashHashKey,
ChildrenHashMatchEntry,
PL_DHashMoveEntryStub,

View File

@ -33,8 +33,6 @@ SpanningCellSorter::~SpanningCellSorter()
/* static */ const PLDHashTableOps
SpanningCellSorter::HashTableOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
HashTableHashKey,
HashTableMatchEntry,
PL_DHashMoveEntryStub,

View File

@ -77,8 +77,6 @@ static bool gShouldCleanupDeadNodes = false;
static PLDHashTableOps pref_HashTableOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashStringKey,
matchPrefEntry,
PL_DHashMoveEntryStub,

View File

@ -1156,8 +1156,6 @@ nsresult nsLoadGroup::Init()
{
static const PLDHashTableOps hash_table_ops =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
RequestHashMatchEntry,
PL_DHashMoveEntryStub,

View File

@ -377,8 +377,6 @@ nsCacheEntryInfo::IsStreamBased(bool * result)
const PLDHashTableOps
nsCacheEntryHashTable::ops =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
HashKey,
MatchEntry,
MoveEntry,

View File

@ -124,8 +124,6 @@ nsDiskCacheBinding::EnsureStreamIO()
const PLDHashTableOps nsDiskCacheBindery::ops =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
HashKey,
MatchEntry,
MoveEntry,

View File

@ -463,8 +463,6 @@ HostDB_InitEntry(PLDHashTable *table,
static const PLDHashTableOps gHostDB_ops =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
HostDB_HashKey,
HostDB_MatchEntry,
HostDB_MoveEntry,

View File

@ -85,8 +85,6 @@ StringCompare(PLDHashTable *table, const PLDHashEntryHdr *entry,
}
static const PLDHashTableOps ops = {
PL_DHashAllocTable,
PL_DHashFreeTable,
StringHash,
StringCompare,
PL_DHashMoveEntryStub,

View File

@ -52,8 +52,6 @@ static PLDHashNumber
static const PLDHashTableOps EntityToUnicodeOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashStringKey,
matchNodeString,
PL_DHashMoveEntryStub,
@ -62,8 +60,6 @@ static const PLDHashTableOps EntityToUnicodeOps = {
};
static const PLDHashTableOps UnicodeToEntityOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
hashUnicodeValue,
matchNodeUnicode,
PL_DHashMoveEntryStub,

View File

@ -140,8 +140,6 @@ struct ResourceHashEntry : public PLDHashEntryHdr {
};
static const PLDHashTableOps gResourceTableOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
ResourceHashEntry::HashKey,
ResourceHashEntry::MatchEntry,
PL_DHashMoveEntryStub,
@ -177,8 +175,6 @@ struct LiteralHashEntry : public PLDHashEntryHdr {
};
static const PLDHashTableOps gLiteralTableOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
LiteralHashEntry::HashKey,
LiteralHashEntry::MatchEntry,
PL_DHashMoveEntryStub,
@ -213,8 +209,6 @@ struct IntHashEntry : public PLDHashEntryHdr {
};
static const PLDHashTableOps gIntTableOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
IntHashEntry::HashKey,
IntHashEntry::MatchEntry,
PL_DHashMoveEntryStub,
@ -253,8 +247,6 @@ struct DateHashEntry : public PLDHashEntryHdr {
};
static const PLDHashTableOps gDateTableOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
DateHashEntry::HashKey,
DateHashEntry::MatchEntry,
PL_DHashMoveEntryStub,
@ -372,8 +364,6 @@ struct BlobHashEntry : public PLDHashEntryHdr {
};
static const PLDHashTableOps gBlobTableOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
BlobHashEntry::HashKey,
BlobHashEntry::MatchEntry,
PL_DHashMoveEntryStub,

View File

@ -80,8 +80,6 @@ RequestMapInitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
}
static const PLDHashTableOps gMapOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
RequestMapMatchEntry,
PL_DHashMoveEntryStub,

View File

@ -92,8 +92,6 @@ CompareCacheClearEntry(PLDHashTable *table, PLDHashEntryHdr *hdr)
}
static const PLDHashTableOps gMapOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
CompareCacheMatchEntry,
PL_DHashMoveEntryStub,

View File

@ -33,8 +33,6 @@ ObjectSetInitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr,
}
static const PLDHashTableOps gSetOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
ObjectSetMatchEntry,
PL_DHashMoveEntryStub,

View File

@ -114,8 +114,6 @@ nsDocLoader::nsDocLoader()
static const PLDHashTableOps hash_table_ops =
{
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
PL_DHashMatchEntryStub,
PL_DHashMoveEntryStub,

View File

@ -801,8 +801,6 @@ PtrToNodeMatchEntry(PLDHashTable* aTable,
}
static PLDHashTableOps PtrNodeOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
PtrToNodeMatchEntry,
PL_DHashMoveEntryStub,

View File

@ -288,8 +288,6 @@ AtomTableInitEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry,
static const PLDHashTableOps AtomTableOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
AtomTableGetHash,
AtomTableMatchKey,
PL_DHashMoveEntryStub,

View File

@ -50,8 +50,6 @@ ArenaStrdup(const nsAFlatCString& aString, PLArenaPool* aArena)
}
static const struct PLDHashTableOps property_HashTableOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashStringKey,
PL_DHashMatchStringKey,
PL_DHashMoveEntryStub,

View File

@ -94,8 +94,6 @@ caseInsensitiveStringHashKey(PLDHashTable* aTable, const void* aKey)
}
static const struct PLDHashTableOps nametable_CaseInsensitiveHashTableOps = {
PL_DHashAllocTable,
PL_DHashFreeTable,
caseInsensitiveStringHashKey,
matchNameKeysCaseInsensitive,
PL_DHashMoveEntryStub,

View File

@ -419,8 +419,6 @@ nsTHashtable<EntryType>::Init(uint32_t aInitLength)
{
static const PLDHashTableOps sOps =
{
::PL_DHashAllocTable,
::PL_DHashFreeTable,
s_HashKey,
s_MatchEntry,
EntryType::ALLOW_MEMMOVE ? ::PL_DHashMoveEntryStub : s_CopyEntry,

View File

@ -68,18 +68,6 @@
using namespace mozilla;
void*
PL_DHashAllocTable(PLDHashTable* aTable, uint32_t aNBytes)
{
return malloc(aNBytes);
}
void
PL_DHashFreeTable(PLDHashTable* aTable, void* aPtr)
{
free(aPtr);
}
PLDHashNumber
PL_DHashStringKey(PLDHashTable* aTable, const void* aKey)
{
@ -158,8 +146,6 @@ PL_DHashFreeStringKey(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
}
static const PLDHashTableOps stub_ops = {
PL_DHashAllocTable,
PL_DHashFreeTable,
PL_DHashVoidPtrKeyStub,
PL_DHashMatchEntryStub,
PL_DHashMoveEntryStub,
@ -185,13 +171,13 @@ PLDHashTable*
PL_NewDHashTable(const PLDHashTableOps* aOps, uint32_t aEntrySize,
uint32_t aLength)
{
PLDHashTable* table = (PLDHashTable*)aOps->allocTable(NULL, sizeof(*table));
PLDHashTable* table = (PLDHashTable*)malloc(sizeof(*table));
if (!table) {
return nullptr;
}
if (!PL_DHashTableInit(table, aOps, aEntrySize, fallible_t(), aLength)) {
aOps->freeTable(NULL, table);
free(table);
return nullptr;
}
return table;
@ -201,7 +187,7 @@ void
PL_DHashTableDestroy(PLDHashTable* aTable)
{
PL_DHashTableFinish(aTable);
aTable->ops->freeTable(NULL, aTable);
free(aTable);
}
/*
@ -263,7 +249,7 @@ PLDHashTable::Init(const PLDHashTableOps* aOps,
return false; // overflowed
}
mEntryStore = (char*)aOps->allocTable(this, nbytes);
mEntryStore = (char*)malloc(nbytes);
if (!mEntryStore) {
return false;
}
@ -352,7 +338,7 @@ PLDHashTable::Finish()
MOZ_ASSERT(RECURSION_LEVEL_SAFE_TO_FINISH(this));
/* Free entry storage last. */
ops->freeTable(this, mEntryStore);
free(mEntryStore);
}
void
@ -495,7 +481,7 @@ PLDHashTable::ChangeTable(int aDeltaLog2)
return false; // overflowed
}
char* newEntryStore = (char*)ops->allocTable(this, nbytes);
char* newEntryStore = (char*)malloc(nbytes);
if (!newEntryStore) {
return false;
}
@ -534,7 +520,7 @@ PLDHashTable::ChangeTable(int aDeltaLog2)
oldEntryAddr += mEntrySize;
}
ops->freeTable(this, oldEntryStore);
free(oldEntryStore);
return true;
}

View File

@ -299,15 +299,6 @@ private:
bool ChangeTable(int aDeltaLog2);
};
/*
* Table space at mEntryStore is allocated and freed using these callbacks.
* The allocator should return null on error only (not if called with aNBytes
* equal to 0; but note that pldhash.c code will never call with 0 aNBytes).
*/
typedef void* (*PLDHashAllocTable)(PLDHashTable* aTable, uint32_t aNBytes);
typedef void (*PLDHashFreeTable)(PLDHashTable* aTable, void* aPtr);
/*
* Compute the hash code for a given key to be looked up, added, or removed
* from aTable. A hash code may have any PLDHashNumber value.
@ -352,13 +343,11 @@ typedef bool (*PLDHashInitEntry)(PLDHashTable* aTable, PLDHashEntryHdr* aEntry,
const void* aKey);
/*
* Finally, the "vtable" structure for PLDHashTable. The first six hooks
* Finally, the "vtable" structure for PLDHashTable. The first four hooks
* must be provided by implementations; they're called unconditionally by the
* generic pldhash.c code. Hooks after these may be null.
*
* Summary of allocation-related hook usage with C++ placement new emphasis:
* allocTable Allocate raw bytes with malloc, no ctors run.
* freeTable Free raw bytes with free, no dtors run.
* initEntry Call placement new using default key-based ctor.
* Return true on success, false on error.
* moveEntry Call placement new using copy ctor, run dtor on old
@ -379,8 +368,6 @@ typedef bool (*PLDHashInitEntry)(PLDHashTable* aTable, PLDHashEntryHdr* aEntry,
struct PLDHashTableOps
{
/* Mandatory hooks. All implementations must provide these. */
PLDHashAllocTable allocTable;
PLDHashFreeTable freeTable;
PLDHashHashKey hashKey;
PLDHashMatchEntry matchEntry;
PLDHashMoveEntry moveEntry;
@ -393,9 +380,6 @@ struct PLDHashTableOps
/*
* Default implementations for the above ops.
*/
void* PL_DHashAllocTable(PLDHashTable* aTable, uint32_t aNBytes);
void PL_DHashFreeTable(PLDHashTable* aTable, void* aPtr);
PLDHashNumber PL_DHashStringKey(PLDHashTable* aTable, const void* aKey);
@ -433,10 +417,8 @@ void PL_DHashFreeStringKey(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
const PLDHashTableOps* PL_DHashGetStubOps(void);
/*
* Dynamically allocate a new PLDHashTable using malloc, initialize it using
* PL_DHashTableInit, and return its address. Return null on malloc failure.
* Note that the entry storage at aTable->mEntryStore will be allocated using
* the aOps->allocTable callback.
* Dynamically allocate a new PLDHashTable, initialize it using
* PL_DHashTableInit, and return its address. Return null on allocation failure.
*/
PLDHashTable* PL_NewDHashTable(
const PLDHashTableOps* aOps, uint32_t aEntrySize,
@ -490,9 +472,9 @@ void PL_DHashTableFinish(PLDHashTable* aTable);
* entry = PL_DHashTableOperate(table, key, PL_DHASH_ADD);
*
* If entry is null upon return, then either the table is severely overloaded,
* and memory can't be allocated for entry storage via aTable->ops->allocTable;
* Or if aTable->ops->initEntry is non-null, the aTable->ops->initEntry op may
* have returned false.
* and memory can't be allocated for entry storage. Or if
* aTable->ops->initEntry is non-null, the aTable->ops->initEntry op may have
* returned false.
*
* Otherwise, aEntry->keyHash has been set so that PL_DHASH_ENTRY_IS_BUSY(entry)
* is true, and it is up to the caller to initialize the key and value parts

View File

@ -80,8 +80,6 @@ hash(PLDHashTable *table, const void *key)
static bool test_pldhash_grow_to_max_capacity()
{
static const PLDHashTableOps ops = {
PL_DHashAllocTable,
PL_DHashFreeTable,
hash,
PL_DHashMatchEntryStub,
PL_DHashMoveEntryStub,