mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 1418156 - Move the PLDHashTable ops into PrefHashEntry. r=glandium
MozReview-Commit-ID: HJfjz2PzW0I --HG-- extra : rebase_source : 717a3d5121a33ca01da5c0b5298386f4c8345eae
This commit is contained in:
parent
cb911105fb
commit
e7c913bc12
@ -189,6 +189,37 @@ public:
|
||||
|
||||
// Other operations.
|
||||
|
||||
static bool MatchEntry(const PLDHashEntryHdr* aEntry, const void* aKey)
|
||||
{
|
||||
auto pref = static_cast<const PrefHashEntry*>(aEntry);
|
||||
|
||||
if (pref->mKey == aKey) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!pref->mKey || !aKey) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto otherKey = static_cast<const char*>(aKey);
|
||||
return (strcmp(pref->mKey, otherKey) == 0);
|
||||
}
|
||||
|
||||
static void ClearEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
|
||||
{
|
||||
auto pref = static_cast<PrefHashEntry*>(aEntry);
|
||||
|
||||
if (pref->IsTypeString()) {
|
||||
free(const_cast<char*>(pref->mDefaultValue.mStringVal));
|
||||
free(const_cast<char*>(pref->mUserValue.mStringVal));
|
||||
}
|
||||
|
||||
// Don't need to free this because it's allocated in memory owned by
|
||||
// gPrefNameArena.
|
||||
pref->mKey = nullptr;
|
||||
memset(aEntry, 0, aTable->EntrySize());
|
||||
}
|
||||
|
||||
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf)
|
||||
{
|
||||
// Note: mKey is allocated in gPrefNameArena, measured elsewhere.
|
||||
@ -220,38 +251,6 @@ public:
|
||||
PrefValue mUserValue;
|
||||
};
|
||||
|
||||
static void
|
||||
ClearPrefEntry(PLDHashTable* aTable, PLDHashEntryHdr* aEntry)
|
||||
{
|
||||
auto pref = static_cast<PrefHashEntry*>(aEntry);
|
||||
if (pref->IsTypeString()) {
|
||||
free(const_cast<char*>(pref->mDefaultValue.mStringVal));
|
||||
free(const_cast<char*>(pref->mUserValue.mStringVal));
|
||||
}
|
||||
|
||||
// Don't need to free this because it's allocated in memory owned by
|
||||
// gPrefNameArena.
|
||||
pref->mKey = nullptr;
|
||||
memset(aEntry, 0, aTable->EntrySize());
|
||||
}
|
||||
|
||||
static bool
|
||||
MatchPrefEntry(const PLDHashEntryHdr* aEntry, const void* aKey)
|
||||
{
|
||||
auto pref = static_cast<const PrefHashEntry*>(aEntry);
|
||||
|
||||
if (pref->mKey == aKey) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!pref->mKey || !aKey) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto otherKey = static_cast<const char*>(aKey);
|
||||
return (strcmp(pref->mKey, otherKey) == 0);
|
||||
}
|
||||
|
||||
struct CallbackNode
|
||||
{
|
||||
const char* mDomain;
|
||||
@ -282,9 +281,9 @@ static bool gShouldCleanupDeadNodes = false;
|
||||
|
||||
static PLDHashTableOps pref_HashTableOps = {
|
||||
PLDHashTable::HashStringKey,
|
||||
MatchPrefEntry,
|
||||
PrefHashEntry::MatchEntry,
|
||||
PLDHashTable::MoveEntryStub,
|
||||
ClearPrefEntry,
|
||||
PrefHashEntry::ClearEntry,
|
||||
nullptr,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user