mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Back out all four patches from bug 1161377. r=me.
Due to Android startup regressions (bug 1163066) and plugin crashes (bug 1165155).
This commit is contained in:
parent
ccf93f6f15
commit
972275ed2b
@ -153,7 +153,7 @@ nsSimpleContentList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto
|
||||
}
|
||||
|
||||
// Hashtable for storing nsContentLists
|
||||
static PLDHashTable* gContentListHashTable;
|
||||
static PLDHashTable gContentListHashTable;
|
||||
|
||||
#define RECENTLY_USED_CONTENT_LIST_CACHE_SIZE 31
|
||||
static nsContentList*
|
||||
@ -215,17 +215,19 @@ NS_GetContentList(nsINode* aRootNode,
|
||||
};
|
||||
|
||||
// Initialize the hashtable if needed.
|
||||
if (!gContentListHashTable) {
|
||||
gContentListHashTable =
|
||||
new PLDHashTable(&hash_table_ops, sizeof(ContentListHashEntry));
|
||||
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
|
||||
entry = static_cast<ContentListHashEntry *>
|
||||
(PL_DHashTableAdd(gContentListHashTable, &hashKey, fallible));
|
||||
if (entry)
|
||||
list = entry->mContentList;
|
||||
if (gContentListHashTable.IsInitialized()) {
|
||||
entry = static_cast<ContentListHashEntry *>
|
||||
(PL_DHashTableAdd(&gContentListHashTable, &hashKey, fallible));
|
||||
if (entry)
|
||||
list = entry->mContentList;
|
||||
}
|
||||
|
||||
if (!list) {
|
||||
// We need to create a ContentList and add it to our new entry, if
|
||||
@ -270,7 +272,7 @@ nsCacheableFuncStringHTMLCollection::WrapObject(JSContext *cx, JS::Handle<JSObje
|
||||
}
|
||||
|
||||
// Hashtable for storing nsCacheableFuncStringContentList
|
||||
static PLDHashTable* gFuncStringContentListHashTable;
|
||||
static PLDHashTable gFuncStringContentListHashTable;
|
||||
|
||||
struct FuncStringContentListHashEntry : public PLDHashEntryHdr
|
||||
{
|
||||
@ -319,18 +321,18 @@ GetFuncStringContentList(nsINode* aRootNode,
|
||||
};
|
||||
|
||||
// Initialize the hashtable if needed.
|
||||
if (!gFuncStringContentListHashTable) {
|
||||
gFuncStringContentListHashTable =
|
||||
new PLDHashTable(&hash_table_ops, sizeof(FuncStringContentListHashEntry));
|
||||
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) {
|
||||
if (gFuncStringContentListHashTable.IsInitialized()) {
|
||||
nsFuncStringCacheKey hashKey(aRootNode, aFunc, aString);
|
||||
|
||||
entry = static_cast<FuncStringContentListHashEntry *>
|
||||
(PL_DHashTableAdd(gFuncStringContentListHashTable, &hashKey, fallible));
|
||||
(PL_DHashTableAdd(&gFuncStringContentListHashTable, &hashKey, fallible));
|
||||
if (entry) {
|
||||
list = entry->mContentList;
|
||||
#ifdef DEBUG
|
||||
@ -968,14 +970,13 @@ nsContentList::RemoveFromHashtable()
|
||||
sRecentlyUsedContentLists[recentlyUsedCacheIndex] = nullptr;
|
||||
}
|
||||
|
||||
if (!gContentListHashTable)
|
||||
if (!gContentListHashTable.IsInitialized())
|
||||
return;
|
||||
|
||||
PL_DHashTableRemove(gContentListHashTable, &key);
|
||||
PL_DHashTableRemove(&gContentListHashTable, &key);
|
||||
|
||||
if (gContentListHashTable->EntryCount() == 0) {
|
||||
delete gContentListHashTable;
|
||||
gContentListHashTable = nullptr;
|
||||
if (gContentListHashTable.EntryCount() == 0) {
|
||||
PL_DHashTableFinish(&gContentListHashTable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1007,16 +1008,15 @@ nsCacheableFuncStringContentList::~nsCacheableFuncStringContentList()
|
||||
void
|
||||
nsCacheableFuncStringContentList::RemoveFromFuncStringHashtable()
|
||||
{
|
||||
if (!gFuncStringContentListHashTable) {
|
||||
if (!gFuncStringContentListHashTable.IsInitialized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsFuncStringCacheKey key(mRootNode, mFunc, mString);
|
||||
PL_DHashTableRemove(gFuncStringContentListHashTable, &key);
|
||||
PL_DHashTableRemove(&gFuncStringContentListHashTable, &key);
|
||||
|
||||
if (gFuncStringContentListHashTable->EntryCount() == 0) {
|
||||
delete gFuncStringContentListHashTable;
|
||||
gFuncStringContentListHashTable = nullptr;
|
||||
if (gFuncStringContentListHashTable.EntryCount() == 0) {
|
||||
PL_DHashTableFinish(&gFuncStringContentListHashTable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ namespace {
|
||||
static NS_DEFINE_CID(kParserServiceCID, NS_PARSERSERVICE_CID);
|
||||
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
|
||||
|
||||
static PLDHashTable* sEventListenerManagersHash;
|
||||
static PLDHashTable sEventListenerManagersHash;
|
||||
|
||||
class DOMEventListenerManagersHashReporter final : public nsIMemoryReporter
|
||||
{
|
||||
@ -352,9 +352,9 @@ public:
|
||||
{
|
||||
// We don't measure the |EventListenerManager| objects pointed to by the
|
||||
// entries because those references are non-owning.
|
||||
int64_t amount = sEventListenerManagersHash
|
||||
int64_t amount = sEventListenerManagersHash.IsInitialized()
|
||||
? PL_DHashTableSizeOfExcludingThis(
|
||||
sEventListenerManagersHash, nullptr, MallocSizeOf)
|
||||
&sEventListenerManagersHash, nullptr, MallocSizeOf)
|
||||
: 0;
|
||||
|
||||
return MOZ_COLLECT_REPORT(
|
||||
@ -487,7 +487,7 @@ nsContentUtils::Init()
|
||||
if (!InitializeEventTable())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!sEventListenerManagersHash) {
|
||||
if (!sEventListenerManagersHash.IsInitialized()) {
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
@ -497,8 +497,8 @@ nsContentUtils::Init()
|
||||
EventListenerManagerHashInitEntry
|
||||
};
|
||||
|
||||
sEventListenerManagersHash =
|
||||
new PLDHashTable(&hash_table_ops, sizeof(EventListenerManagerMapEntry));
|
||||
PL_DHashTableInit(&sEventListenerManagersHash, &hash_table_ops,
|
||||
sizeof(EventListenerManagerMapEntry));
|
||||
|
||||
RegisterStrongMemoryReporter(new DOMEventListenerManagersHashReporter());
|
||||
}
|
||||
@ -1803,8 +1803,8 @@ nsContentUtils::Shutdown()
|
||||
delete sUserDefinedEvents;
|
||||
sUserDefinedEvents = nullptr;
|
||||
|
||||
if (sEventListenerManagersHash) {
|
||||
NS_ASSERTION(sEventListenerManagersHash->EntryCount() == 0,
|
||||
if (sEventListenerManagersHash.IsInitialized()) {
|
||||
NS_ASSERTION(sEventListenerManagersHash.EntryCount() == 0,
|
||||
"Event listener manager hash not empty at shutdown!");
|
||||
|
||||
// See comment above.
|
||||
@ -1816,9 +1816,8 @@ nsContentUtils::Shutdown()
|
||||
// it could leave dangling references in DOMClassInfo's preserved
|
||||
// wrapper table.
|
||||
|
||||
if (sEventListenerManagersHash->EntryCount() == 0) {
|
||||
delete sEventListenerManagersHash;
|
||||
sEventListenerManagersHash = nullptr;
|
||||
if (sEventListenerManagersHash.EntryCount() == 0) {
|
||||
PL_DHashTableFinish(&sEventListenerManagersHash);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3983,8 +3982,8 @@ ListenerEnumerator(PLDHashTable* aTable, PLDHashEntryHdr* aEntry,
|
||||
void
|
||||
nsContentUtils::UnmarkGrayJSListenersInCCGenerationDocuments(uint32_t aGeneration)
|
||||
{
|
||||
if (sEventListenerManagersHash) {
|
||||
PL_DHashTableEnumerate(sEventListenerManagersHash, ListenerEnumerator,
|
||||
if (sEventListenerManagersHash.IsInitialized()) {
|
||||
PL_DHashTableEnumerate(&sEventListenerManagersHash, ListenerEnumerator,
|
||||
&aGeneration);
|
||||
}
|
||||
}
|
||||
@ -3994,14 +3993,14 @@ void
|
||||
nsContentUtils::TraverseListenerManager(nsINode *aNode,
|
||||
nsCycleCollectionTraversalCallback &cb)
|
||||
{
|
||||
if (!sEventListenerManagersHash) {
|
||||
if (!sEventListenerManagersHash.IsInitialized()) {
|
||||
// We're already shut down, just return.
|
||||
return;
|
||||
}
|
||||
|
||||
EventListenerManagerMapEntry *entry =
|
||||
static_cast<EventListenerManagerMapEntry *>
|
||||
(PL_DHashTableSearch(sEventListenerManagersHash, aNode));
|
||||
(PL_DHashTableSearch(&sEventListenerManagersHash, aNode));
|
||||
if (entry) {
|
||||
CycleCollectionNoteChild(cb, entry->mListenerManager.get(),
|
||||
"[via hash] mListenerManager");
|
||||
@ -4011,7 +4010,7 @@ nsContentUtils::TraverseListenerManager(nsINode *aNode,
|
||||
EventListenerManager*
|
||||
nsContentUtils::GetListenerManagerForNode(nsINode *aNode)
|
||||
{
|
||||
if (!sEventListenerManagersHash) {
|
||||
if (!sEventListenerManagersHash.IsInitialized()) {
|
||||
// We're already shut down, don't bother creating an event listener
|
||||
// manager.
|
||||
|
||||
@ -4020,7 +4019,7 @@ nsContentUtils::GetListenerManagerForNode(nsINode *aNode)
|
||||
|
||||
EventListenerManagerMapEntry *entry =
|
||||
static_cast<EventListenerManagerMapEntry *>
|
||||
(PL_DHashTableAdd(sEventListenerManagersHash, aNode, fallible));
|
||||
(PL_DHashTableAdd(&sEventListenerManagersHash, aNode, fallible));
|
||||
|
||||
if (!entry) {
|
||||
return nullptr;
|
||||
@ -4042,7 +4041,7 @@ nsContentUtils::GetExistingListenerManagerForNode(const nsINode *aNode)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!sEventListenerManagersHash) {
|
||||
if (!sEventListenerManagersHash.IsInitialized()) {
|
||||
// We're already shut down, don't bother creating an event listener
|
||||
// manager.
|
||||
|
||||
@ -4051,7 +4050,7 @@ nsContentUtils::GetExistingListenerManagerForNode(const nsINode *aNode)
|
||||
|
||||
EventListenerManagerMapEntry *entry =
|
||||
static_cast<EventListenerManagerMapEntry *>
|
||||
(PL_DHashTableSearch(sEventListenerManagersHash, aNode));
|
||||
(PL_DHashTableSearch(&sEventListenerManagersHash, aNode));
|
||||
if (entry) {
|
||||
return entry->mListenerManager;
|
||||
}
|
||||
@ -4063,16 +4062,16 @@ nsContentUtils::GetExistingListenerManagerForNode(const nsINode *aNode)
|
||||
void
|
||||
nsContentUtils::RemoveListenerManager(nsINode *aNode)
|
||||
{
|
||||
if (sEventListenerManagersHash) {
|
||||
if (sEventListenerManagersHash.IsInitialized()) {
|
||||
EventListenerManagerMapEntry *entry =
|
||||
static_cast<EventListenerManagerMapEntry *>
|
||||
(PL_DHashTableSearch(sEventListenerManagersHash, aNode));
|
||||
(PL_DHashTableSearch(&sEventListenerManagersHash, aNode));
|
||||
if (entry) {
|
||||
nsRefPtr<EventListenerManager> listenerManager;
|
||||
listenerManager.swap(entry->mListenerManager);
|
||||
// Remove the entry and *then* do operations that could cause further
|
||||
// modification of sEventListenerManagersHash. See bug 334177.
|
||||
PL_DHashTableRawRemove(sEventListenerManagersHash, entry);
|
||||
PL_DHashTableRawRemove(&sEventListenerManagersHash, entry);
|
||||
if (listenerManager) {
|
||||
listenerManager->Disconnect();
|
||||
}
|
||||
@ -7750,4 +7749,4 @@ nsContentUtils::FirePageShowEvent(nsIDocShellTreeItem* aItem,
|
||||
if (doc->IsShowing() == aFireIfShowing) {
|
||||
doc->OnPageShow(true, aChromeEventHandler);
|
||||
}
|
||||
}
|
||||
}
|
@ -1713,8 +1713,11 @@ nsDocument::~nsDocument()
|
||||
|
||||
// Kill the subdocument map, doing this will release its strong
|
||||
// references, if any.
|
||||
delete mSubDocuments;
|
||||
mSubDocuments = nullptr;
|
||||
if (mSubDocuments) {
|
||||
PL_DHashTableDestroy(mSubDocuments);
|
||||
|
||||
mSubDocuments = nullptr;
|
||||
}
|
||||
|
||||
// Destroy link map now so we don't waste time removing
|
||||
// links one by one
|
||||
@ -2118,8 +2121,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
|
||||
tmp->mStyleSheetSetList = nullptr;
|
||||
}
|
||||
|
||||
delete tmp->mSubDocuments;
|
||||
tmp->mSubDocuments = nullptr;
|
||||
if (tmp->mSubDocuments) {
|
||||
PL_DHashTableDestroy(tmp->mSubDocuments);
|
||||
tmp->mSubDocuments = nullptr;
|
||||
}
|
||||
|
||||
tmp->mFrameRequestCallbacks.Clear();
|
||||
|
||||
@ -2315,8 +2320,11 @@ nsDocument::ResetToURI(nsIURI *aURI, nsILoadGroup *aLoadGroup,
|
||||
|
||||
// Delete references to sub-documents and kill the subdocument map,
|
||||
// if any. It holds strong references
|
||||
delete mSubDocuments;
|
||||
mSubDocuments = nullptr;
|
||||
if (mSubDocuments) {
|
||||
PL_DHashTableDestroy(mSubDocuments);
|
||||
|
||||
mSubDocuments = nullptr;
|
||||
}
|
||||
|
||||
// Destroy link map now so we don't waste time removing
|
||||
// links one by one
|
||||
@ -3997,7 +4005,7 @@ nsDocument::SetSubDocumentFor(Element* aElement, nsIDocument* aSubDoc)
|
||||
SubDocInitEntry
|
||||
};
|
||||
|
||||
mSubDocuments = new PLDHashTable(&hash_table_ops, sizeof(SubDocMapEntry));
|
||||
mSubDocuments = PL_NewDHashTable(&hash_table_ops, sizeof(SubDocMapEntry));
|
||||
}
|
||||
|
||||
// Add a mapping to the hash table
|
||||
|
@ -287,18 +287,21 @@ nsPropertyTable::PropertyList::PropertyList(nsIAtom *aName,
|
||||
void *aDtorData,
|
||||
bool aTransfer)
|
||||
: mName(aName),
|
||||
mObjectValueMap(PL_DHashGetStubOps(), sizeof(PropertyListMapEntry)),
|
||||
mDtorFunc(aDtorFunc),
|
||||
mDtorData(aDtorData),
|
||||
mTransfer(aTransfer),
|
||||
mNext(nullptr)
|
||||
{
|
||||
PL_DHashTableInit(&mObjectValueMap, PL_DHashGetStubOps(),
|
||||
sizeof(PropertyListMapEntry));
|
||||
}
|
||||
|
||||
nsPropertyTable::PropertyList::~PropertyList()
|
||||
{
|
||||
PL_DHashTableFinish(&mObjectValueMap);
|
||||
}
|
||||
|
||||
|
||||
static PLDHashOperator
|
||||
DestroyPropertyEnumerator(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
||||
uint32_t number, void *arg)
|
||||
|
@ -83,7 +83,7 @@ static JSObjWrapperTable sJSObjWrappers;
|
||||
static bool sJSObjWrappersAccessible = false;
|
||||
|
||||
// Hash of NPObject wrappers that wrap NPObjects as JSObjects.
|
||||
static PLDHashTable* sNPObjWrappers;
|
||||
static PLDHashTable sNPObjWrappers;
|
||||
|
||||
// Global wrapper count. This includes JSObject wrappers *and*
|
||||
// NPObject wrappers. When this count goes to zero, there are no more
|
||||
@ -401,24 +401,23 @@ DestroyJSObjWrapperTable()
|
||||
static bool
|
||||
CreateNPObjWrapperTable()
|
||||
{
|
||||
MOZ_ASSERT(!sNPObjWrappers);
|
||||
MOZ_ASSERT(!sNPObjWrappers.IsInitialized());
|
||||
|
||||
if (!RegisterGCCallbacks()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sNPObjWrappers =
|
||||
new PLDHashTable(PL_DHashGetStubOps(), sizeof(NPObjWrapperHashEntry));
|
||||
PL_DHashTableInit(&sNPObjWrappers, PL_DHashGetStubOps(),
|
||||
sizeof(NPObjWrapperHashEntry));
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyNPObjWrapperTable()
|
||||
{
|
||||
MOZ_ASSERT(sNPObjWrappers->EntryCount() == 0);
|
||||
MOZ_ASSERT(sNPObjWrappers.EntryCount() == 0);
|
||||
|
||||
delete sNPObjWrappers;
|
||||
sNPObjWrappers = nullptr;
|
||||
PL_DHashTableFinish(&sNPObjWrappers);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -437,7 +436,7 @@ OnWrapperDestroyed()
|
||||
DestroyJSObjWrapperTable();
|
||||
}
|
||||
|
||||
if (sNPObjWrappers) {
|
||||
if (sNPObjWrappers.IsInitialized()) {
|
||||
// No more wrappers, and our hash was initialized. Finish the
|
||||
// hash to prevent leaking it.
|
||||
DestroyNPObjWrapperTable();
|
||||
@ -1762,8 +1761,8 @@ NPObjWrapper_Finalize(js::FreeOp *fop, JSObject *obj)
|
||||
{
|
||||
NPObject *npobj = (NPObject *)::JS_GetPrivate(obj);
|
||||
if (npobj) {
|
||||
if (sNPObjWrappers) {
|
||||
PL_DHashTableRemove(sNPObjWrappers, npobj);
|
||||
if (sNPObjWrappers.IsInitialized()) {
|
||||
PL_DHashTableRemove(&sNPObjWrappers, npobj);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1778,7 +1777,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) {
|
||||
if (!sNPObjWrappers.IsInitialized()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1791,7 +1790,7 @@ NPObjWrapper_ObjectMoved(JSObject *obj, const JSObject *old)
|
||||
JS::AutoSuppressGCAnalysis nogc;
|
||||
|
||||
NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
|
||||
(PL_DHashTableSearch(sNPObjWrappers, npobj));
|
||||
(PL_DHashTableSearch(&sNPObjWrappers, npobj));
|
||||
MOZ_ASSERT(entry && entry->mJSObj);
|
||||
MOZ_ASSERT(entry->mJSObj == old);
|
||||
entry->mJSObj = obj;
|
||||
@ -1837,14 +1836,14 @@ nsNPObjWrapper::OnDestroy(NPObject *npobj)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sNPObjWrappers) {
|
||||
if (!sNPObjWrappers.IsInitialized()) {
|
||||
// No hash yet (or any more), no used wrappers available.
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
|
||||
(PL_DHashTableSearch(sNPObjWrappers, npobj));
|
||||
(PL_DHashTableSearch(&sNPObjWrappers, npobj));
|
||||
|
||||
if (entry && entry->mJSObj) {
|
||||
// Found a live NPObject wrapper, null out its JSObjects' private
|
||||
@ -1853,7 +1852,7 @@ nsNPObjWrapper::OnDestroy(NPObject *npobj)
|
||||
::JS_SetPrivate(entry->mJSObj, nullptr);
|
||||
|
||||
// Remove the npobj from the hash now that it went away.
|
||||
PL_DHashTableRawRemove(sNPObjWrappers, entry);
|
||||
PL_DHashTableRawRemove(&sNPObjWrappers, entry);
|
||||
|
||||
// The finalize hook will call OnWrapperDestroyed().
|
||||
}
|
||||
@ -1887,7 +1886,7 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!sNPObjWrappers) {
|
||||
if (!sNPObjWrappers.IsInitialized()) {
|
||||
// No hash yet (or any more), initialize it.
|
||||
if (!CreateNPObjWrapperTable()) {
|
||||
return nullptr;
|
||||
@ -1895,7 +1894,7 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj)
|
||||
}
|
||||
|
||||
NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
|
||||
(PL_DHashTableAdd(sNPObjWrappers, npobj, fallible));
|
||||
(PL_DHashTableAdd(&sNPObjWrappers, npobj, fallible));
|
||||
|
||||
if (!entry) {
|
||||
// Out of memory
|
||||
@ -1917,24 +1916,24 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, NPObject *npobj)
|
||||
entry->mNPObj = npobj;
|
||||
entry->mNpp = npp;
|
||||
|
||||
uint32_t generation = sNPObjWrappers->Generation();
|
||||
uint32_t generation = sNPObjWrappers.Generation();
|
||||
|
||||
// No existing JSObject, create one.
|
||||
|
||||
JS::Rooted<JSObject*> obj(cx, ::JS_NewObject(cx, js::Jsvalify(&sNPObjectJSWrapperClass)));
|
||||
|
||||
if (generation != sNPObjWrappers->Generation()) {
|
||||
if (generation != sNPObjWrappers.Generation()) {
|
||||
// Reload entry if the JS_NewObject call caused a GC and reallocated
|
||||
// the table (see bug 445229). This is guaranteed to succeed.
|
||||
|
||||
NS_ASSERTION(PL_DHashTableSearch(sNPObjWrappers, npobj),
|
||||
NS_ASSERTION(PL_DHashTableSearch(&sNPObjWrappers, npobj),
|
||||
"Hashtable didn't find what we just added?");
|
||||
}
|
||||
|
||||
if (!obj) {
|
||||
// OOM? Remove the stale entry from the hash.
|
||||
|
||||
PL_DHashTableRawRemove(sNPObjWrappers, entry);
|
||||
PL_DHashTableRawRemove(&sNPObjWrappers, entry);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@ -2040,9 +2039,9 @@ 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) {
|
||||
if (sNPObjWrappers.IsInitialized()) {
|
||||
NppAndCx nppcx = { npp, cx };
|
||||
PL_DHashTableEnumerate(sNPObjWrappers,
|
||||
PL_DHashTableEnumerate(&sNPObjWrappers,
|
||||
NPObjWrapperPluginDestroyedCallback, &nppcx);
|
||||
}
|
||||
}
|
||||
@ -2075,7 +2074,7 @@ LookupNPP(NPObject *npobj)
|
||||
}
|
||||
|
||||
NPObjWrapperHashEntry *entry = static_cast<NPObjWrapperHashEntry *>
|
||||
(PL_DHashTableAdd(sNPObjWrappers, npobj, fallible));
|
||||
(PL_DHashTableAdd(&sNPObjWrappers, npobj, fallible));
|
||||
|
||||
if (!entry) {
|
||||
return nullptr;
|
||||
|
@ -217,7 +217,9 @@ XULDocument::~XULDocument()
|
||||
mPersistenceIds.Clear();
|
||||
|
||||
// Destroy our broadcaster map.
|
||||
delete mBroadcasterMap;
|
||||
if (mBroadcasterMap) {
|
||||
PL_DHashTableDestroy(mBroadcasterMap);
|
||||
}
|
||||
|
||||
delete mTemplateBuilderTable;
|
||||
|
||||
@ -765,7 +767,7 @@ XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener,
|
||||
};
|
||||
|
||||
if (! mBroadcasterMap) {
|
||||
mBroadcasterMap = new PLDHashTable(&gOps, sizeof(BroadcasterMapEntry));
|
||||
mBroadcasterMap = PL_NewDHashTable(&gOps, sizeof(BroadcasterMapEntry));
|
||||
}
|
||||
|
||||
BroadcasterMapEntry* entry =
|
||||
|
@ -617,9 +617,18 @@ FT2FontFamily::AddFacesToFontList(InfallibleTArray<FontListEntry>* aFontList,
|
||||
class FontNameCache {
|
||||
public:
|
||||
FontNameCache()
|
||||
: mMap(&sMapOps, sizeof(FNCMapEntry), 0)
|
||||
, mWriteNeeded(false)
|
||||
: mWriteNeeded(false)
|
||||
{
|
||||
mOps = (PLDHashTableOps) {
|
||||
StringHash,
|
||||
HashMatchEntry,
|
||||
MoveEntry,
|
||||
PL_DHashClearEntryStub,
|
||||
nullptr
|
||||
};
|
||||
|
||||
PL_DHashTableInit(&mMap, &mOps, sizeof(FNCMapEntry), 0);
|
||||
|
||||
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default,
|
||||
"StartupCacheFontNameCache should only be used in chrome "
|
||||
"process");
|
||||
@ -630,12 +639,17 @@ public:
|
||||
|
||||
~FontNameCache()
|
||||
{
|
||||
if (!mMap.IsInitialized()) {
|
||||
return;
|
||||
}
|
||||
if (!mWriteNeeded || !mCache) {
|
||||
PL_DHashTableFinish(&mMap);
|
||||
return;
|
||||
}
|
||||
|
||||
nsAutoCString buf;
|
||||
PL_DHashTableEnumerate(&mMap, WriteOutMap, &buf);
|
||||
PL_DHashTableFinish(&mMap);
|
||||
mCache->PutBuffer(CACHE_KEY, buf.get(), buf.Length() + 1);
|
||||
}
|
||||
|
||||
@ -737,7 +751,7 @@ private:
|
||||
PLDHashTable mMap;
|
||||
bool mWriteNeeded;
|
||||
|
||||
static const PLDHashTableOps sMapOps;
|
||||
PLDHashTableOps mOps;
|
||||
|
||||
static PLDHashOperator WriteOutMap(PLDHashTable *aTable,
|
||||
PLDHashEntryHdr *aHdr,
|
||||
@ -796,15 +810,6 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
/* static */ const PLDHashTableOps FontNameCache::sMapOps =
|
||||
{
|
||||
FontNameCache::StringHash,
|
||||
FontNameCache::HashMatchEntry,
|
||||
FontNameCache::MoveEntry,
|
||||
PL_DHashClearEntryStub,
|
||||
nullptr
|
||||
};
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* gfxFT2FontList
|
||||
|
@ -182,12 +182,13 @@ Native2WrappedNativeMap::newMap(int length)
|
||||
|
||||
Native2WrappedNativeMap::Native2WrappedNativeMap(int length)
|
||||
{
|
||||
mTable = new PLDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
mTable = PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
}
|
||||
|
||||
Native2WrappedNativeMap::~Native2WrappedNativeMap()
|
||||
{
|
||||
delete mTable;
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -230,12 +231,13 @@ IID2WrappedJSClassMap::newMap(int length)
|
||||
|
||||
IID2WrappedJSClassMap::IID2WrappedJSClassMap(int length)
|
||||
{
|
||||
mTable = new PLDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
IID2WrappedJSClassMap::~IID2WrappedJSClassMap()
|
||||
{
|
||||
delete mTable;
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
}
|
||||
|
||||
|
||||
@ -263,12 +265,13 @@ IID2NativeInterfaceMap::newMap(int length)
|
||||
|
||||
IID2NativeInterfaceMap::IID2NativeInterfaceMap(int length)
|
||||
{
|
||||
mTable = new PLDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
IID2NativeInterfaceMap::~IID2NativeInterfaceMap()
|
||||
{
|
||||
delete mTable;
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -304,12 +307,13 @@ ClassInfo2NativeSetMap::newMap(int length)
|
||||
|
||||
ClassInfo2NativeSetMap::ClassInfo2NativeSetMap(int length)
|
||||
{
|
||||
mTable = new PLDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
mTable = PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
}
|
||||
|
||||
ClassInfo2NativeSetMap::~ClassInfo2NativeSetMap()
|
||||
{
|
||||
delete mTable;
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -342,12 +346,13 @@ ClassInfo2WrappedNativeProtoMap::newMap(int length)
|
||||
|
||||
ClassInfo2WrappedNativeProtoMap::ClassInfo2WrappedNativeProtoMap(int length)
|
||||
{
|
||||
mTable = new PLDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
mTable = PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry), length);
|
||||
}
|
||||
|
||||
ClassInfo2WrappedNativeProtoMap::~ClassInfo2WrappedNativeProtoMap()
|
||||
{
|
||||
delete mTable;
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -462,12 +467,13 @@ NativeSetMap::newMap(int length)
|
||||
|
||||
NativeSetMap::NativeSetMap(int length)
|
||||
{
|
||||
mTable = new PLDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
NativeSetMap::~NativeSetMap()
|
||||
{
|
||||
delete mTable;
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -525,12 +531,13 @@ IID2ThisTranslatorMap::newMap(int length)
|
||||
|
||||
IID2ThisTranslatorMap::IID2ThisTranslatorMap(int length)
|
||||
{
|
||||
mTable = new PLDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
IID2ThisTranslatorMap::~IID2ThisTranslatorMap()
|
||||
{
|
||||
delete mTable;
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
@ -601,12 +608,13 @@ XPCNativeScriptableSharedMap::newMap(int length)
|
||||
|
||||
XPCNativeScriptableSharedMap::XPCNativeScriptableSharedMap(int length)
|
||||
{
|
||||
mTable = new PLDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
mTable = PL_NewDHashTable(&Entry::sOps, sizeof(Entry), length);
|
||||
}
|
||||
|
||||
XPCNativeScriptableSharedMap::~XPCNativeScriptableSharedMap()
|
||||
{
|
||||
delete mTable;
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -652,13 +660,14 @@ XPCWrappedNativeProtoMap::newMap(int length)
|
||||
|
||||
XPCWrappedNativeProtoMap::XPCWrappedNativeProtoMap(int length)
|
||||
{
|
||||
mTable = new PLDHashTable(PL_DHashGetStubOps(),
|
||||
mTable = PL_NewDHashTable(PL_DHashGetStubOps(),
|
||||
sizeof(PLDHashEntryStub), length);
|
||||
}
|
||||
|
||||
XPCWrappedNativeProtoMap::~XPCWrappedNativeProtoMap()
|
||||
{
|
||||
delete mTable;
|
||||
if (mTable)
|
||||
PL_DHashTableDestroy(mTable);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -489,14 +489,6 @@ protected:
|
||||
|
||||
RuleHash::RuleHash(bool aQuirksMode)
|
||||
: mRuleCount(0),
|
||||
mIdTable(aQuirksMode ? &RuleHash_IdTable_CIOps.ops
|
||||
: &RuleHash_IdTable_CSOps.ops,
|
||||
sizeof(RuleHashTableEntry)),
|
||||
mClassTable(aQuirksMode ? &RuleHash_ClassTable_CIOps.ops
|
||||
: &RuleHash_ClassTable_CSOps.ops,
|
||||
sizeof(RuleHashTableEntry)),
|
||||
mTagTable(&RuleHash_TagTable_Ops, sizeof(RuleHashTagTableEntry)),
|
||||
mNameSpaceTable(&RuleHash_NameSpaceTable_Ops, sizeof(RuleHashTableEntry)),
|
||||
mUniversalRules(0),
|
||||
mEnumList(nullptr), mEnumListSize(0),
|
||||
mQuirksMode(aQuirksMode)
|
||||
@ -516,6 +508,20 @@ RuleHash::RuleHash(bool aQuirksMode)
|
||||
#endif
|
||||
{
|
||||
MOZ_COUNT_CTOR(RuleHash);
|
||||
|
||||
PL_DHashTableInit(&mIdTable, aQuirksMode ? &RuleHash_IdTable_CIOps.ops
|
||||
: &RuleHash_IdTable_CSOps.ops,
|
||||
sizeof(RuleHashTableEntry));
|
||||
|
||||
PL_DHashTableInit(&mClassTable, aQuirksMode ? &RuleHash_ClassTable_CIOps.ops
|
||||
: &RuleHash_ClassTable_CSOps.ops,
|
||||
sizeof(RuleHashTableEntry));
|
||||
|
||||
PL_DHashTableInit(&mTagTable, &RuleHash_TagTable_Ops,
|
||||
sizeof(RuleHashTagTableEntry));
|
||||
|
||||
PL_DHashTableInit(&mNameSpaceTable, &RuleHash_NameSpaceTable_Ops,
|
||||
sizeof(RuleHashTableEntry));
|
||||
}
|
||||
|
||||
RuleHash::~RuleHash()
|
||||
@ -557,6 +563,11 @@ RuleHash::~RuleHash()
|
||||
if (nullptr != mEnumList) {
|
||||
delete [] mEnumList;
|
||||
}
|
||||
// delete arena for strings and small objects
|
||||
PL_DHashTableFinish(&mIdTable);
|
||||
PL_DHashTableFinish(&mClassTable);
|
||||
PL_DHashTableFinish(&mTagTable);
|
||||
PL_DHashTableFinish(&mNameSpaceTable);
|
||||
}
|
||||
|
||||
void RuleHash::AppendRuleToTable(PLDHashTable* aTable, const void* aKey,
|
||||
@ -855,31 +866,42 @@ struct RuleCascadeData {
|
||||
: mRuleHash(aQuirksMode),
|
||||
mStateSelectors(),
|
||||
mSelectorDocumentStates(0),
|
||||
mClassSelectors(aQuirksMode ? &AtomSelector_CIOps.ops
|
||||
: &AtomSelector_CSOps,
|
||||
sizeof(AtomSelectorEntry)),
|
||||
mIdSelectors(aQuirksMode ? &AtomSelector_CIOps.ops
|
||||
: &AtomSelector_CSOps,
|
||||
sizeof(AtomSelectorEntry)),
|
||||
// mAttributeSelectors is matching on the attribute _name_, not the
|
||||
// value, and we case-fold names at parse-time, so this is a
|
||||
// case-sensitive match.
|
||||
mAttributeSelectors(&AtomSelector_CSOps, sizeof(AtomSelectorEntry)),
|
||||
mAnonBoxRules(&RuleHash_TagTable_Ops, sizeof(RuleHashTagTableEntry)),
|
||||
#ifdef MOZ_XUL
|
||||
mXULTreeRules(&RuleHash_TagTable_Ops, sizeof(RuleHashTagTableEntry)),
|
||||
#endif
|
||||
mKeyframesRuleTable(),
|
||||
mCounterStyleRuleTable(),
|
||||
mCacheKey(aMedium),
|
||||
mNext(nullptr),
|
||||
mQuirksMode(aQuirksMode)
|
||||
{
|
||||
// mAttributeSelectors is matching on the attribute _name_, not the value,
|
||||
// and we case-fold names at parse-time, so this is a case-sensitive match.
|
||||
PL_DHashTableInit(&mAttributeSelectors, &AtomSelector_CSOps,
|
||||
sizeof(AtomSelectorEntry));
|
||||
PL_DHashTableInit(&mAnonBoxRules, &RuleHash_TagTable_Ops,
|
||||
sizeof(RuleHashTagTableEntry));
|
||||
PL_DHashTableInit(&mIdSelectors,
|
||||
aQuirksMode ? &AtomSelector_CIOps.ops :
|
||||
&AtomSelector_CSOps,
|
||||
sizeof(AtomSelectorEntry));
|
||||
PL_DHashTableInit(&mClassSelectors,
|
||||
aQuirksMode ? &AtomSelector_CIOps.ops :
|
||||
&AtomSelector_CSOps,
|
||||
sizeof(AtomSelectorEntry));
|
||||
memset(mPseudoElementRuleHashes, 0, sizeof(mPseudoElementRuleHashes));
|
||||
#ifdef MOZ_XUL
|
||||
PL_DHashTableInit(&mXULTreeRules, &RuleHash_TagTable_Ops,
|
||||
sizeof(RuleHashTagTableEntry));
|
||||
#endif
|
||||
}
|
||||
|
||||
~RuleCascadeData()
|
||||
{
|
||||
PL_DHashTableFinish(&mAttributeSelectors);
|
||||
PL_DHashTableFinish(&mAnonBoxRules);
|
||||
PL_DHashTableFinish(&mIdSelectors);
|
||||
PL_DHashTableFinish(&mClassSelectors);
|
||||
#ifdef MOZ_XUL
|
||||
PL_DHashTableFinish(&mXULTreeRules);
|
||||
#endif
|
||||
for (uint32_t i = 0; i < ArrayLength(mPseudoElementRuleHashes); ++i) {
|
||||
delete mPseudoElementRuleHashes[i];
|
||||
}
|
||||
@ -3298,9 +3320,11 @@ struct CascadeEnumData {
|
||||
mPageRules(aPageRules),
|
||||
mCounterStyleRules(aCounterStyleRules),
|
||||
mCacheKey(aKey),
|
||||
mRulesByWeight(&gRulesByWeightOps, sizeof(RuleByWeightEntry), 32),
|
||||
mSheetType(aSheetType)
|
||||
{
|
||||
PL_DHashTableInit(&mRulesByWeight, &gRulesByWeightOps,
|
||||
sizeof(RuleByWeightEntry), 32);
|
||||
|
||||
// Initialize our arena
|
||||
PL_INIT_ARENA_POOL(&mArena, "CascadeEnumDataArena",
|
||||
NS_CASCADEENUMDATA_ARENA_BLOCK_SIZE);
|
||||
@ -3308,6 +3332,8 @@ struct CascadeEnumData {
|
||||
|
||||
~CascadeEnumData()
|
||||
{
|
||||
if (mRulesByWeight.IsInitialized())
|
||||
PL_DHashTableFinish(&mRulesByWeight);
|
||||
PL_FinishArenaPool(&mArena);
|
||||
}
|
||||
|
||||
|
@ -1431,7 +1431,7 @@ nsRuleNode::DestroyInternal(nsRuleNode ***aDestroyQueueTail)
|
||||
PL_DHashTableEnumerate(children, EnqueueRuleNodeChildren,
|
||||
&destroyQueueTail);
|
||||
*destroyQueueTail = nullptr; // ensure null-termination
|
||||
delete children;
|
||||
PL_DHashTableDestroy(children);
|
||||
} else if (HaveChildren()) {
|
||||
*destroyQueueTail = ChildrenList();
|
||||
do {
|
||||
@ -1614,7 +1614,7 @@ nsRuleNode::ConvertChildrenToHash(int32_t aNumKids)
|
||||
{
|
||||
NS_ASSERTION(!ChildrenAreHashed() && HaveChildren(),
|
||||
"must have a non-empty list of children");
|
||||
PLDHashTable *hash = new PLDHashTable(&ChildrenHashOps,
|
||||
PLDHashTable *hash = PL_NewDHashTable(&ChildrenHashOps,
|
||||
sizeof(ChildrenHashEntry),
|
||||
aNumKids);
|
||||
for (nsRuleNode* curr = ChildrenList(); curr; curr = curr->mNextSibling) {
|
||||
@ -9372,7 +9372,7 @@ nsRuleNode::SweepChildren(nsTArray<nsRuleNode*>& aSweepQueue)
|
||||
PL_DHashTableEnumerate(children, SweepHashEntry, &survivorsWithChildren);
|
||||
childrenDestroyed = oldChildCount - children->EntryCount();
|
||||
if (childrenDestroyed == oldChildCount) {
|
||||
delete children;
|
||||
PL_DHashTableDestroy(children);
|
||||
mChildren.asVoid = nullptr;
|
||||
}
|
||||
} else {
|
||||
|
@ -235,10 +235,10 @@ Preferences::SizeOfIncludingThisAndOtherStuff(mozilla::MallocSizeOf aMallocSizeO
|
||||
NS_ENSURE_TRUE(InitStaticMembers(), 0);
|
||||
|
||||
size_t n = aMallocSizeOf(sPreferences);
|
||||
if (gHashTable) {
|
||||
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);
|
||||
n += PL_DHashTableSizeOfExcludingThis(&gHashTable, nullptr, aMallocSizeOf);
|
||||
}
|
||||
if (gCacheData) {
|
||||
n += gCacheData->SizeOfIncludingThis(aMallocSizeOf);
|
||||
@ -738,8 +738,8 @@ Preferences::GetPreference(PrefSetting* aPref)
|
||||
void
|
||||
Preferences::GetPreferences(InfallibleTArray<PrefSetting>* aPrefs)
|
||||
{
|
||||
aPrefs->SetCapacity(gHashTable->Capacity());
|
||||
PL_DHashTableEnumerate(gHashTable, pref_GetPrefs, aPrefs);
|
||||
aPrefs->SetCapacity(gHashTable.Capacity());
|
||||
PL_DHashTableEnumerate(&gHashTable, pref_GetPrefs, aPrefs);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -944,7 +944,7 @@ Preferences::WritePrefFile(nsIFile* aFile)
|
||||
uint32_t writeAmount;
|
||||
nsresult rv;
|
||||
|
||||
if (!gHashTable)
|
||||
if (!gHashTable.IsInitialized())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// execute a "safe" save by saving through a tempfile
|
||||
@ -958,24 +958,23 @@ Preferences::WritePrefFile(nsIFile* aFile)
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsAutoArrayPtr<char*> valueArray(new char*[gHashTable->EntryCount()]);
|
||||
memset(valueArray, 0, gHashTable->EntryCount() * sizeof(char*));
|
||||
nsAutoArrayPtr<char*> valueArray(new char*[gHashTable.EntryCount()]);
|
||||
memset(valueArray, 0, gHashTable.EntryCount() * sizeof(char*));
|
||||
pref_saveArgs saveArgs;
|
||||
saveArgs.prefArray = valueArray;
|
||||
saveArgs.saveTypes = SAVE_ALL;
|
||||
|
||||
|
||||
// get the lines that we're supposed to be writing to the file
|
||||
PL_DHashTableEnumerate(gHashTable, pref_savePref, &saveArgs);
|
||||
|
||||
PL_DHashTableEnumerate(&gHashTable, pref_savePref, &saveArgs);
|
||||
|
||||
/* Sort the preferences to make a readable file on disk */
|
||||
NS_QuickSort(valueArray, gHashTable->EntryCount(), sizeof(char *),
|
||||
pref_CompareStrings, nullptr);
|
||||
|
||||
NS_QuickSort(valueArray, gHashTable.EntryCount(), sizeof(char *), pref_CompareStrings, nullptr);
|
||||
|
||||
// write out the file header
|
||||
outStream->Write(outHeader, sizeof(outHeader) - 1, &writeAmount);
|
||||
|
||||
char** walker = valueArray;
|
||||
for (uint32_t valueIdx = 0; valueIdx < gHashTable->EntryCount(); valueIdx++, walker++) {
|
||||
for (uint32_t valueIdx = 0; valueIdx < gHashTable.EntryCount(); valueIdx++, walker++) {
|
||||
if (*walker) {
|
||||
outStream->Write(*walker, strlen(*walker), &writeAmount);
|
||||
outStream->Write(NS_LINEBREAK, NS_LINEBREAK_LEN, &writeAmount);
|
||||
|
@ -555,15 +555,15 @@ NS_IMETHODIMP nsPrefBranch::GetChildList(const char *aStartingAt, uint32_t *aCou
|
||||
*aChildArray = nullptr;
|
||||
*aCount = 0;
|
||||
|
||||
if (!gHashTable->IsInitialized())
|
||||
if (!gHashTable.IsInitialized())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
// this will contain a list of all the pref name strings
|
||||
// allocate on the stack for speed
|
||||
|
||||
|
||||
ed.parent = getPrefName(aStartingAt);
|
||||
ed.pref_list = &prefArray;
|
||||
PL_DHashTableEnumerate(gHashTable, pref_enumChild, &ed);
|
||||
PL_DHashTableEnumerate(&gHashTable, pref_enumChild, &ed);
|
||||
|
||||
// now that we've built up the list, run the callback on
|
||||
// all the matching elements
|
||||
|
@ -68,7 +68,7 @@ matchPrefEntry(PLDHashTable*, const PLDHashEntryHdr* entry,
|
||||
return (strcmp(prefEntry->key, otherKey) == 0);
|
||||
}
|
||||
|
||||
PLDHashTable* gHashTable;
|
||||
PLDHashTable gHashTable;
|
||||
static PLArenaPool gPrefNameArena;
|
||||
bool gDirty = false;
|
||||
|
||||
@ -149,10 +149,9 @@ static nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, u
|
||||
|
||||
nsresult PREF_Init()
|
||||
{
|
||||
if (!gHashTable) {
|
||||
gHashTable = new PLDHashTable(&pref_HashTableOps,
|
||||
sizeof(PrefHashEntry),
|
||||
PREF_HASHTABLE_INITIAL_LENGTH);
|
||||
if (!gHashTable.IsInitialized()) {
|
||||
PL_DHashTableInit(&gHashTable, &pref_HashTableOps,
|
||||
sizeof(PrefHashEntry), PREF_HASHTABLE_INITIAL_LENGTH);
|
||||
|
||||
PL_INIT_ARENA_POOL(&gPrefNameArena, "PrefNameArena",
|
||||
PREFNAME_ARENA_SIZE);
|
||||
@ -183,9 +182,8 @@ void PREF_Cleanup()
|
||||
/* Frees up all the objects except the callback list. */
|
||||
void PREF_CleanupPrefs()
|
||||
{
|
||||
if (gHashTable) {
|
||||
delete gHashTable;
|
||||
gHashTable = nullptr;
|
||||
if (gHashTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&gHashTable);
|
||||
PL_FinishArenaPool(&gPrefNameArena);
|
||||
}
|
||||
}
|
||||
@ -468,7 +466,7 @@ pref_CompareStrings(const void *v1, const void *v2, void *unused)
|
||||
|
||||
bool PREF_HasUserPref(const char *pref_name)
|
||||
{
|
||||
if (!gHashTable)
|
||||
if (!gHashTable.IsInitialized())
|
||||
return false;
|
||||
|
||||
PrefHashEntry *pref = pref_HashTableLookup(pref_name);
|
||||
@ -482,7 +480,7 @@ bool PREF_HasUserPref(const char *pref_name)
|
||||
nsresult
|
||||
PREF_CopyCharPref(const char *pref_name, char ** return_buffer, bool get_default)
|
||||
{
|
||||
if (!gHashTable)
|
||||
if (!gHashTable.IsInitialized())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv = NS_ERROR_UNEXPECTED;
|
||||
@ -506,7 +504,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)
|
||||
if (!gHashTable.IsInitialized())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv = NS_ERROR_UNEXPECTED;
|
||||
@ -530,7 +528,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)
|
||||
if (!gHashTable.IsInitialized())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv = NS_ERROR_UNEXPECTED;
|
||||
@ -581,7 +579,7 @@ PREF_DeleteBranch(const char *branch_name)
|
||||
|
||||
int len = (int)strlen(branch_name);
|
||||
|
||||
if (!gHashTable)
|
||||
if (!gHashTable.IsInitialized())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
/* The following check insures that if the branch name already has a "."
|
||||
@ -594,7 +592,7 @@ PREF_DeleteBranch(const char *branch_name)
|
||||
if ((len > 1) && branch_name[len - 1] != '.')
|
||||
branch_dot += '.';
|
||||
|
||||
PL_DHashTableEnumerate(gHashTable, pref_DeleteItem,
|
||||
PL_DHashTableEnumerate(&gHashTable, pref_DeleteItem,
|
||||
(void*) branch_dot.get());
|
||||
gDirty = true;
|
||||
return NS_OK;
|
||||
@ -604,7 +602,7 @@ PREF_DeleteBranch(const char *branch_name)
|
||||
nsresult
|
||||
PREF_ClearUserPref(const char *pref_name)
|
||||
{
|
||||
if (!gHashTable)
|
||||
if (!gHashTable.IsInitialized())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
PrefHashEntry* pref = pref_HashTableLookup(pref_name);
|
||||
@ -613,7 +611,7 @@ PREF_ClearUserPref(const char *pref_name)
|
||||
pref->flags &= ~PREF_USERSET;
|
||||
|
||||
if (!(pref->flags & PREF_HAS_DEFAULT)) {
|
||||
PL_DHashTableRemove(gHashTable, pref_name);
|
||||
PL_DHashTableRemove(&gHashTable, pref_name);
|
||||
}
|
||||
|
||||
pref_DoCallback(pref_name);
|
||||
@ -649,11 +647,11 @@ PREF_ClearAllUserPrefs()
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
#endif
|
||||
|
||||
if (!gHashTable)
|
||||
if (!gHashTable.IsInitialized())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
std::vector<std::string> prefStrings;
|
||||
PL_DHashTableEnumerate(gHashTable, pref_ClearUserPref, static_cast<void*>(&prefStrings));
|
||||
PL_DHashTableEnumerate(&gHashTable, pref_ClearUserPref, static_cast<void*>(&prefStrings));
|
||||
|
||||
for (std::string& prefString : prefStrings) {
|
||||
pref_DoCallback(prefString.c_str());
|
||||
@ -665,7 +663,7 @@ PREF_ClearAllUserPrefs()
|
||||
|
||||
nsresult PREF_LockPref(const char *key, bool lockit)
|
||||
{
|
||||
if (!gHashTable)
|
||||
if (!gHashTable.IsInitialized())
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
PrefHashEntry* pref = pref_HashTableLookup(key);
|
||||
@ -736,7 +734,7 @@ PrefHashEntry* pref_HashTableLookup(const void *key)
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
#endif
|
||||
|
||||
return static_cast<PrefHashEntry*>(PL_DHashTableSearch(gHashTable, key));
|
||||
return static_cast<PrefHashEntry*>(PL_DHashTableSearch(&gHashTable, key));
|
||||
}
|
||||
|
||||
nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t flags)
|
||||
@ -745,11 +743,11 @@ nsresult pref_HashPref(const char *key, PrefValue value, PrefType type, uint32_t
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
#endif
|
||||
|
||||
if (!gHashTable)
|
||||
if (!gHashTable.IsInitialized())
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PrefHashEntry* pref = static_cast<PrefHashEntry*>
|
||||
(PL_DHashTableAdd(gHashTable, key, fallible));
|
||||
(PL_DHashTableAdd(&gHashTable, key, fallible));
|
||||
|
||||
if (!pref)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -841,7 +839,8 @@ pref_SizeOfPrivateData(MallocSizeOf aMallocSizeOf)
|
||||
PrefType
|
||||
PREF_GetPrefType(const char *pref_name)
|
||||
{
|
||||
if (gHashTable) {
|
||||
if (gHashTable.IsInitialized())
|
||||
{
|
||||
PrefHashEntry* pref = pref_HashTableLookup(pref_name);
|
||||
if (pref)
|
||||
{
|
||||
@ -862,7 +861,7 @@ bool
|
||||
PREF_PrefIsLocked(const char *pref_name)
|
||||
{
|
||||
bool result = false;
|
||||
if (gIsAnyPrefLocked && gHashTable) {
|
||||
if (gIsAnyPrefLocked && gHashTable.IsInitialized()) {
|
||||
PrefHashEntry* pref = pref_HashTableLookup(pref_name);
|
||||
if (pref && PREF_IS_LOCKED(pref))
|
||||
result = true;
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
|
||||
extern PLDHashTable* gHashTable;
|
||||
extern bool gDirty;
|
||||
extern PLDHashTable gHashTable;
|
||||
extern bool gDirty;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
@ -40,7 +40,7 @@ struct HttpHeapAtom {
|
||||
char value[1];
|
||||
};
|
||||
|
||||
static PLDHashTable *sAtomTable;
|
||||
static PLDHashTable sAtomTable;
|
||||
static struct HttpHeapAtom *sHeapAtoms = nullptr;
|
||||
static Mutex *sLock = nullptr;
|
||||
|
||||
@ -94,7 +94,7 @@ static const PLDHashTableOps ops = {
|
||||
nsresult
|
||||
nsHttp::CreateAtomTable()
|
||||
{
|
||||
MOZ_ASSERT(!sAtomTable, "atom table already initialized");
|
||||
MOZ_ASSERT(!sAtomTable.IsInitialized(), "atom table already initialized");
|
||||
|
||||
if (!sLock) {
|
||||
sLock = new Mutex("nsHttp.sLock");
|
||||
@ -103,8 +103,8 @@ nsHttp::CreateAtomTable()
|
||||
// The initial length for this table is a value greater than the number of
|
||||
// known atoms (NUM_HTTP_ATOMS) because we expect to encounter a few random
|
||||
// headers right off the bat.
|
||||
sAtomTable = new PLDHashTable(&ops, sizeof(PLDHashEntryStub),
|
||||
NUM_HTTP_ATOMS + 10);
|
||||
PL_DHashTableInit(&sAtomTable, &ops, sizeof(PLDHashEntryStub),
|
||||
NUM_HTTP_ATOMS + 10);
|
||||
|
||||
// fill the table with our known atoms
|
||||
const char *const atoms[] = {
|
||||
@ -116,7 +116,7 @@ nsHttp::CreateAtomTable()
|
||||
|
||||
for (int i = 0; atoms[i]; ++i) {
|
||||
PLDHashEntryStub *stub = reinterpret_cast<PLDHashEntryStub *>
|
||||
(PL_DHashTableAdd(sAtomTable, atoms[i], fallible));
|
||||
(PL_DHashTableAdd(&sAtomTable, atoms[i], fallible));
|
||||
if (!stub)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
@ -130,8 +130,9 @@ nsHttp::CreateAtomTable()
|
||||
void
|
||||
nsHttp::DestroyAtomTable()
|
||||
{
|
||||
delete sAtomTable;
|
||||
sAtomTable = nullptr;
|
||||
if (sAtomTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&sAtomTable);
|
||||
}
|
||||
|
||||
while (sHeapAtoms) {
|
||||
HttpHeapAtom *next = sHeapAtoms->next;
|
||||
@ -139,8 +140,10 @@ nsHttp::DestroyAtomTable()
|
||||
sHeapAtoms = next;
|
||||
}
|
||||
|
||||
delete sLock;
|
||||
sLock = nullptr;
|
||||
if (sLock) {
|
||||
delete sLock;
|
||||
sLock = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Mutex *
|
||||
@ -155,13 +158,13 @@ nsHttp::ResolveAtom(const char *str)
|
||||
{
|
||||
nsHttpAtom atom = { nullptr };
|
||||
|
||||
if (!str || !sAtomTable)
|
||||
if (!str || !sAtomTable.IsInitialized())
|
||||
return atom;
|
||||
|
||||
MutexAutoLock lock(*sLock);
|
||||
|
||||
PLDHashEntryStub *stub = reinterpret_cast<PLDHashEntryStub *>
|
||||
(PL_DHashTableAdd(sAtomTable, str, fallible));
|
||||
(PL_DHashTableAdd(&sAtomTable, str, fallible));
|
||||
if (!stub)
|
||||
return atom; // out of memory
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include "nsHTMLEntities.h"
|
||||
|
||||
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "pldhash.h"
|
||||
@ -65,8 +67,8 @@ static const PLDHashTableOps UnicodeToEntityOps = {
|
||||
nullptr,
|
||||
};
|
||||
|
||||
static PLDHashTable* gEntityToUnicode;
|
||||
static PLDHashTable* gUnicodeToEntity;
|
||||
static PLDHashTable gEntityToUnicode;
|
||||
static PLDHashTable gUnicodeToEntity;
|
||||
static nsrefcnt gTableRefCnt = 0;
|
||||
|
||||
#define HTML_ENTITY(_name, _value) { #_name, _value },
|
||||
@ -81,12 +83,10 @@ nsresult
|
||||
nsHTMLEntities::AddRefTable(void)
|
||||
{
|
||||
if (!gTableRefCnt) {
|
||||
gEntityToUnicode = new PLDHashTable(&EntityToUnicodeOps,
|
||||
sizeof(EntityNodeEntry),
|
||||
NS_HTML_ENTITY_COUNT);
|
||||
gUnicodeToEntity = new PLDHashTable(&UnicodeToEntityOps,
|
||||
sizeof(EntityNodeEntry),
|
||||
NS_HTML_ENTITY_COUNT);
|
||||
PL_DHashTableInit(&gEntityToUnicode, &EntityToUnicodeOps,
|
||||
sizeof(EntityNodeEntry), NS_HTML_ENTITY_COUNT);
|
||||
PL_DHashTableInit(&gUnicodeToEntity, &UnicodeToEntityOps,
|
||||
sizeof(EntityNodeEntry), NS_HTML_ENTITY_COUNT);
|
||||
for (const EntityNode *node = gEntityArray,
|
||||
*node_end = ArrayEnd(gEntityArray);
|
||||
node < node_end; ++node) {
|
||||
@ -94,7 +94,7 @@ nsHTMLEntities::AddRefTable(void)
|
||||
// add to Entity->Unicode table
|
||||
EntityNodeEntry* entry =
|
||||
static_cast<EntityNodeEntry*>
|
||||
(PL_DHashTableAdd(gEntityToUnicode, node->mStr, fallible));
|
||||
(PL_DHashTableAdd(&gEntityToUnicode, node->mStr, fallible));
|
||||
NS_ASSERTION(entry, "Error adding an entry");
|
||||
// Prefer earlier entries when we have duplication.
|
||||
if (!entry->node)
|
||||
@ -102,7 +102,7 @@ nsHTMLEntities::AddRefTable(void)
|
||||
|
||||
// add to Unicode->Entity table
|
||||
entry = static_cast<EntityNodeEntry*>
|
||||
(PL_DHashTableAdd(gUnicodeToEntity,
|
||||
(PL_DHashTableAdd(&gUnicodeToEntity,
|
||||
NS_INT32_TO_PTR(node->mUnicode),
|
||||
fallible));
|
||||
NS_ASSERTION(entry, "Error adding an entry");
|
||||
@ -111,8 +111,8 @@ nsHTMLEntities::AddRefTable(void)
|
||||
entry->node = node;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
PL_DHashMarkTableImmutable(gUnicodeToEntity);
|
||||
PL_DHashMarkTableImmutable(gEntityToUnicode);
|
||||
PL_DHashMarkTableImmutable(&gUnicodeToEntity);
|
||||
PL_DHashMarkTableImmutable(&gEntityToUnicode);
|
||||
#endif
|
||||
}
|
||||
++gTableRefCnt;
|
||||
@ -125,17 +125,20 @@ nsHTMLEntities::ReleaseTable(void)
|
||||
if (--gTableRefCnt != 0)
|
||||
return;
|
||||
|
||||
delete gEntityToUnicode;
|
||||
delete gUnicodeToEntity;
|
||||
gEntityToUnicode = nullptr;
|
||||
gUnicodeToEntity = nullptr;
|
||||
if (gEntityToUnicode.IsInitialized()) {
|
||||
PL_DHashTableFinish(&gEntityToUnicode);
|
||||
}
|
||||
if (gUnicodeToEntity.IsInitialized()) {
|
||||
PL_DHashTableFinish(&gUnicodeToEntity);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t
|
||||
nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
|
||||
{
|
||||
NS_ASSERTION(gEntityToUnicode, "no lookup table, needs addref");
|
||||
if (!gEntityToUnicode)
|
||||
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 ';'.
|
||||
@ -149,7 +152,7 @@ nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
|
||||
|
||||
EntityNodeEntry* entry =
|
||||
static_cast<EntityNodeEntry*>
|
||||
(PL_DHashTableSearch(gEntityToUnicode, aEntity.get()));
|
||||
(PL_DHashTableSearch(&gEntityToUnicode, aEntity.get()));
|
||||
|
||||
return entry ? entry->node->mUnicode : -1;
|
||||
}
|
||||
@ -169,10 +172,11 @@ nsHTMLEntities::EntityToUnicode(const nsAString& aEntity) {
|
||||
const char*
|
||||
nsHTMLEntities::UnicodeToEntity(int32_t aUnicode)
|
||||
{
|
||||
NS_ASSERTION(gUnicodeToEntity, "no lookup table, needs addref");
|
||||
NS_ASSERTION(gUnicodeToEntity.IsInitialized(),
|
||||
"no lookup table, needs addref");
|
||||
EntityNodeEntry* entry =
|
||||
static_cast<EntityNodeEntry*>
|
||||
(PL_DHashTableSearch(gUnicodeToEntity, NS_INT32_TO_PTR(aUnicode)));
|
||||
(PL_DHashTableSearch(&gUnicodeToEntity, NS_INT32_TO_PTR(aUnicode)));
|
||||
|
||||
return entry ? entry->node->mStr : nullptr;
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ Assertion::Assertion(nsIRDFResource* aSource)
|
||||
NS_ADDREF(mSource);
|
||||
|
||||
u.hash.mPropertyHash =
|
||||
new PLDHashTable(PL_DHashGetStubOps(), sizeof(Entry));
|
||||
PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry));
|
||||
}
|
||||
|
||||
Assertion::Assertion(nsIRDFResource* aSource,
|
||||
@ -194,7 +194,7 @@ Assertion::~Assertion()
|
||||
if (mHashEntry && u.hash.mPropertyHash) {
|
||||
PL_DHashTableEnumerate(u.hash.mPropertyHash, DeletePropertyHashEntry,
|
||||
nullptr);
|
||||
delete u.hash.mPropertyHash;
|
||||
PL_DHashTableDestroy(u.hash.mPropertyHash);
|
||||
u.hash.mPropertyHash = nullptr;
|
||||
}
|
||||
|
||||
|
@ -39,15 +39,22 @@ static const PLDHashTableOps gSetOps = {
|
||||
nsNSSShutDownList *nsNSSShutDownList::singleton = nullptr;
|
||||
|
||||
nsNSSShutDownList::nsNSSShutDownList()
|
||||
: mListLock("nsNSSShutDownList.mListLock")
|
||||
, mActiveSSLSockets(0)
|
||||
, mObjects(&gSetOps, sizeof(ObjectHashEntry))
|
||||
, mPK11LogoutCancelObjects(&gSetOps, sizeof(ObjectHashEntry))
|
||||
:mListLock("nsNSSShutDownList.mListLock")
|
||||
{
|
||||
mActiveSSLSockets = 0;
|
||||
PL_DHashTableInit(&mObjects, &gSetOps, sizeof(ObjectHashEntry));
|
||||
PL_DHashTableInit(&mPK11LogoutCancelObjects, &gSetOps,
|
||||
sizeof(ObjectHashEntry));
|
||||
}
|
||||
|
||||
nsNSSShutDownList::~nsNSSShutDownList()
|
||||
{
|
||||
if (mObjects.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mObjects);
|
||||
}
|
||||
if (mPK11LogoutCancelObjects.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mPK11LogoutCancelObjects);
|
||||
}
|
||||
PR_ASSERT(this == singleton);
|
||||
singleton = nullptr;
|
||||
}
|
||||
|
@ -157,8 +157,8 @@ private:
|
||||
protected:
|
||||
mozilla::Mutex mListLock;
|
||||
static nsNSSShutDownList *singleton;
|
||||
uint32_t mActiveSSLSockets;
|
||||
PLDHashTable mObjects;
|
||||
uint32_t mActiveSSLSockets;
|
||||
PLDHashTable mPK11LogoutCancelObjects;
|
||||
nsNSSActivityState mActivityState;
|
||||
};
|
||||
|
@ -91,22 +91,12 @@ class nsDefaultComparator <nsDocLoader::nsListenerInfo, nsIWebProgressListener*>
|
||||
}
|
||||
};
|
||||
|
||||
/* static */ const PLDHashTableOps nsDocLoader::sRequestInfoHashOps =
|
||||
{
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PL_DHashMatchEntryStub,
|
||||
PL_DHashMoveEntryStub,
|
||||
nsDocLoader::RequestInfoHashClearEntry,
|
||||
nsDocLoader::RequestInfoHashInitEntry
|
||||
};
|
||||
|
||||
nsDocLoader::nsDocLoader()
|
||||
: mParent(nullptr),
|
||||
mCurrentSelfProgress(0),
|
||||
mMaxSelfProgress(0),
|
||||
mCurrentTotalProgress(0),
|
||||
mMaxTotalProgress(0),
|
||||
mRequestInfoHash(&sRequestInfoHashOps, sizeof(nsRequestInfo)),
|
||||
mCompletedTotalProgress(0),
|
||||
mIsLoadingDocument(false),
|
||||
mIsRestoringDocument(false),
|
||||
@ -117,6 +107,17 @@ nsDocLoader::nsDocLoader()
|
||||
gDocLoaderLog = PR_NewLogModule("DocLoader");
|
||||
}
|
||||
|
||||
static const PLDHashTableOps hash_table_ops =
|
||||
{
|
||||
PL_DHashVoidPtrKeyStub,
|
||||
PL_DHashMatchEntryStub,
|
||||
PL_DHashMoveEntryStub,
|
||||
RequestInfoHashClearEntry,
|
||||
RequestInfoHashInitEntry
|
||||
};
|
||||
|
||||
PL_DHashTableInit(&mRequestInfoHash, &hash_table_ops, sizeof(nsRequestInfo));
|
||||
|
||||
ClearInternalProgress();
|
||||
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
@ -133,6 +134,10 @@ nsDocLoader::SetDocLoaderParent(nsDocLoader *aParent)
|
||||
nsresult
|
||||
nsDocLoader::Init()
|
||||
{
|
||||
if (!mRequestInfoHash.IsInitialized()) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult rv = NS_NewLoadGroup(getter_AddRefs(mLoadGroup), this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@ -161,6 +166,10 @@ nsDocLoader::~nsDocLoader()
|
||||
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
("DocLoader:%p: deleted.\n", this));
|
||||
|
||||
if (mRequestInfoHash.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mRequestInfoHash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1352,6 +1361,12 @@ RemoveInfoCallback(PLDHashTable *table, PLDHashEntryHdr *hdr, uint32_t number,
|
||||
|
||||
void nsDocLoader::ClearRequestInfoHash(void)
|
||||
{
|
||||
if (!mRequestInfoHash.IsInitialized() || !mRequestInfoHash.EntryCount()) {
|
||||
// No hash, or the hash is empty, nothing to do here then...
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PL_DHashTableEnumerate(&mRequestInfoHash, RemoveInfoCallback, nullptr);
|
||||
}
|
||||
|
||||
|
@ -302,8 +302,6 @@ protected:
|
||||
bool mIsFlushingLayout;
|
||||
|
||||
private:
|
||||
static const PLDHashTableOps sRequestInfoHashOps;
|
||||
|
||||
// A list of kids that are in the middle of their onload calls and will let
|
||||
// us know once they're done. We don't want to fire onload for "normal"
|
||||
// DocLoaderIsEmpty calls (those coming from requests finishing in our
|
||||
|
@ -41,7 +41,7 @@ using namespace mozilla;
|
||||
* sure it's only manipulated from the main thread. Probably the latter
|
||||
* is better, since the former would hurt performance.
|
||||
*/
|
||||
static PLDHashTable* gAtomTable;
|
||||
static PLDHashTable gAtomTable;
|
||||
|
||||
class StaticAtomEntry : public PLDHashEntryHdr
|
||||
{
|
||||
@ -336,21 +336,19 @@ void
|
||||
NS_PurgeAtomTable()
|
||||
{
|
||||
delete gStaticAtomTable;
|
||||
gStaticAtomTable = nullptr;
|
||||
|
||||
if (gAtomTable) {
|
||||
if (gAtomTable.IsInitialized()) {
|
||||
#ifdef DEBUG
|
||||
const char* dumpAtomLeaks = PR_GetEnv("MOZ_DUMP_ATOM_LEAKS");
|
||||
if (dumpAtomLeaks && *dumpAtomLeaks) {
|
||||
uint32_t leaked = 0;
|
||||
printf("*** %d atoms still exist (including permanent):\n",
|
||||
gAtomTable->EntryCount());
|
||||
PL_DHashTableEnumerate(gAtomTable, DumpAtomLeaks, &leaked);
|
||||
gAtomTable.EntryCount());
|
||||
PL_DHashTableEnumerate(&gAtomTable, DumpAtomLeaks, &leaked);
|
||||
printf("*** %u non-permanent atoms leaked\n", leaked);
|
||||
}
|
||||
#endif
|
||||
delete gAtomTable;
|
||||
gAtomTable = nullptr;
|
||||
PL_DHashTableFinish(&gAtomTable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -399,16 +397,17 @@ AtomImpl::AtomImpl(nsStringBuffer* aStringBuffer, uint32_t aLength,
|
||||
|
||||
AtomImpl::~AtomImpl()
|
||||
{
|
||||
MOZ_ASSERT(gAtomTable, "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->EntryCount() == 0) {
|
||||
delete gAtomTable;
|
||||
gAtomTable = nullptr;
|
||||
PL_DHashTableRemove(&gAtomTable, &key);
|
||||
if (gAtomTable.IsInitialized() && gAtomTable.EntryCount() == 0) {
|
||||
PL_DHashTableFinish(&gAtomTable);
|
||||
NS_ASSERTION(gAtomTable.EntryCount() == 0,
|
||||
"PL_DHashTableFinish changed the entry count");
|
||||
}
|
||||
}
|
||||
|
||||
@ -524,8 +523,8 @@ void
|
||||
NS_SizeOfAtomTablesIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
size_t* aMain, size_t* aStatic)
|
||||
{
|
||||
*aMain = gAtomTable
|
||||
? PL_DHashTableSizeOfExcludingThis(gAtomTable,
|
||||
*aMain = gAtomTable.IsInitialized()
|
||||
? PL_DHashTableSizeOfExcludingThis(&gAtomTable,
|
||||
SizeOfAtomTableEntryExcludingThis,
|
||||
aMallocSizeOf)
|
||||
: 0;
|
||||
@ -542,9 +541,9 @@ NS_SizeOfAtomTablesIncludingThis(MallocSizeOf aMallocSizeOf,
|
||||
static inline void
|
||||
EnsureTableExists()
|
||||
{
|
||||
if (!gAtomTable) {
|
||||
gAtomTable = new PLDHashTable(&AtomTableOps, sizeof(AtomTableEntry),
|
||||
ATOM_HASHTABLE_INITIAL_LENGTH);
|
||||
if (!gAtomTable.IsInitialized()) {
|
||||
PL_DHashTableInit(&gAtomTable, &AtomTableOps,
|
||||
sizeof(AtomTableEntry), ATOM_HASHTABLE_INITIAL_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
@ -555,7 +554,7 @@ GetAtomHashEntry(const char* aString, uint32_t aLength, uint32_t* aHashOut)
|
||||
EnsureTableExists();
|
||||
AtomTableKey key(aString, aLength, aHashOut);
|
||||
// This is an infallible add.
|
||||
return static_cast<AtomTableEntry*>(PL_DHashTableAdd(gAtomTable, &key));
|
||||
return static_cast<AtomTableEntry*>(PL_DHashTableAdd(&gAtomTable, &key));
|
||||
}
|
||||
|
||||
static inline AtomTableEntry*
|
||||
@ -565,7 +564,7 @@ GetAtomHashEntry(const char16_t* aString, uint32_t aLength, uint32_t* aHashOut)
|
||||
EnsureTableExists();
|
||||
AtomTableKey key(aString, aLength, aHashOut);
|
||||
// This is an infallible add.
|
||||
return static_cast<AtomTableEntry*>(PL_DHashTableAdd(gAtomTable, &key));
|
||||
return static_cast<AtomTableEntry*>(PL_DHashTableAdd(&gAtomTable, &key));
|
||||
}
|
||||
|
||||
class CheckStaticAtomSizes
|
||||
@ -710,8 +709,7 @@ NS_NewPermanentAtom(const nsAString& aUTF16String)
|
||||
nsrefcnt
|
||||
NS_GetNumberOfAtoms(void)
|
||||
{
|
||||
MOZ_ASSERT(gAtomTable);
|
||||
return gAtomTable->EntryCount();
|
||||
return gAtomTable.EntryCount();
|
||||
}
|
||||
|
||||
nsIAtom*
|
||||
|
@ -460,14 +460,19 @@ nsPropertiesParser::ParseBuffer(const char16_t* aBuffer,
|
||||
|
||||
nsPersistentProperties::nsPersistentProperties()
|
||||
: mIn(nullptr)
|
||||
, mTable(&property_HashTableOps, sizeof(PropertyTableEntry), 16)
|
||||
{
|
||||
PL_DHashTableInit(&mTable, &property_HashTableOps,
|
||||
sizeof(PropertyTableEntry), 16);
|
||||
|
||||
PL_INIT_ARENA_POOL(&mArena, "PersistentPropertyArena", 2048);
|
||||
}
|
||||
|
||||
nsPersistentProperties::~nsPersistentProperties()
|
||||
{
|
||||
PL_FinishArenaPool(&mArena);
|
||||
if (mTable.IsInitialized()) {
|
||||
PL_DHashTableFinish(&mTable);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -406,6 +406,10 @@ nsTHashtable<EntryType>::nsTHashtable(nsTHashtable<EntryType>&& aOther)
|
||||
// aOther shouldn't touch mTable after this, because we've stolen the table's
|
||||
// pointers but not overwitten them.
|
||||
MOZ_MAKE_MEM_UNDEFINED(&aOther.mTable, sizeof(aOther.mTable));
|
||||
|
||||
// Indicate that aOther is not initialized. This will make its destructor a
|
||||
// nop, which is what we want.
|
||||
aOther.mTable.SetOps(nullptr);
|
||||
}
|
||||
|
||||
template<class EntryType>
|
||||
|
@ -169,6 +169,22 @@ SizeOfEntryStore(uint32_t aCapacity, uint32_t aEntrySize, uint32_t* aNbytes)
|
||||
return uint64_t(*aNbytes) == nbytes64; // returns false on overflow
|
||||
}
|
||||
|
||||
PLDHashTable*
|
||||
PL_NewDHashTable(const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength)
|
||||
{
|
||||
PLDHashTable* table = new PLDHashTable();
|
||||
PL_DHashTableInit(table, aOps, aEntrySize, aLength);
|
||||
return table;
|
||||
}
|
||||
|
||||
void
|
||||
PL_DHashTableDestroy(PLDHashTable* aTable)
|
||||
{
|
||||
PL_DHashTableFinish(aTable);
|
||||
delete aTable;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute max and min load numbers (entry counts). We have a secondary max
|
||||
* that allows us to overload a table reasonably if it cannot be grown further
|
||||
@ -202,7 +218,6 @@ MOZ_ALWAYS_INLINE void
|
||||
PLDHashTable::Init(const PLDHashTableOps* aOps,
|
||||
uint32_t aEntrySize, uint32_t aLength)
|
||||
{
|
||||
MOZ_ASSERT(!mAutoFinish);
|
||||
MOZ_ASSERT(!IsInitialized());
|
||||
|
||||
// Check that the important fields have been set by the constructor.
|
||||
@ -251,19 +266,6 @@ PL_DHashTableInit(PLDHashTable* aTable, const PLDHashTableOps* aOps,
|
||||
aTable->Init(aOps, aEntrySize, aLength);
|
||||
}
|
||||
|
||||
PLDHashTable::PLDHashTable(const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength)
|
||||
: mOps(nullptr)
|
||||
, mAutoFinish(0)
|
||||
, mEntryStore(nullptr)
|
||||
#ifdef DEBUG
|
||||
, mRecursionLevel()
|
||||
#endif
|
||||
{
|
||||
Init(aOps, aEntrySize, aLength);
|
||||
mAutoFinish = 1;
|
||||
}
|
||||
|
||||
PLDHashTable& PLDHashTable::operator=(PLDHashTable&& aOther)
|
||||
{
|
||||
if (this == &aOther) {
|
||||
@ -271,7 +273,6 @@ PLDHashTable& PLDHashTable::operator=(PLDHashTable&& aOther)
|
||||
}
|
||||
|
||||
// Destruct |this|.
|
||||
mAutoFinish = 0;
|
||||
Finish();
|
||||
|
||||
// Move pieces over.
|
||||
@ -280,9 +281,7 @@ PLDHashTable& PLDHashTable::operator=(PLDHashTable&& aOther)
|
||||
mEntrySize = Move(aOther.mEntrySize);
|
||||
mEntryCount = Move(aOther.mEntryCount);
|
||||
mRemovedCount = Move(aOther.mRemovedCount);
|
||||
// We can't use Move() on bitfields. Fortunately, '=' suffices.
|
||||
mGeneration = aOther.mGeneration;
|
||||
mAutoFinish = aOther.mAutoFinish;
|
||||
mGeneration = Move(aOther.mGeneration);
|
||||
mEntryStore = Move(aOther.mEntryStore);
|
||||
#ifdef PL_DHASHMETER
|
||||
mStats = Move(aOther.mStats);
|
||||
@ -341,8 +340,6 @@ PLDHashTable::EntryIsFree(PLDHashEntryHdr* aEntry)
|
||||
MOZ_ALWAYS_INLINE void
|
||||
PLDHashTable::Finish()
|
||||
{
|
||||
MOZ_ASSERT(!mAutoFinish);
|
||||
|
||||
if (!IsInitialized()) {
|
||||
MOZ_ASSERT(!mEntryStore);
|
||||
return;
|
||||
@ -378,20 +375,6 @@ PL_DHashTableFinish(PLDHashTable* aTable)
|
||||
aTable->Finish();
|
||||
}
|
||||
|
||||
PLDHashTable::~PLDHashTable()
|
||||
{
|
||||
// If we used automatic initialization, then finalize the table here.
|
||||
// Otherwise, Finish() should have already been called manually.
|
||||
if (mAutoFinish) {
|
||||
mAutoFinish = 0;
|
||||
Finish();
|
||||
} else {
|
||||
// XXX: actually, we can't assert this here because some tables never get
|
||||
// finalized.
|
||||
//MOZ_ASSERT(!IsInitialized());
|
||||
}
|
||||
}
|
||||
|
||||
// If |IsAdd| is true, the return value is always non-null and it may be a
|
||||
// previously-removed entry. If |IsAdd| is false, the return value is null on a
|
||||
// miss, and will never be a previously-removed entry on a hit. This
|
||||
|
@ -145,21 +145,12 @@ typedef size_t (*PLDHashSizeOfEntryExcludingThisFun)(
|
||||
PLDHashEntryHdr* aHdr, mozilla::MallocSizeOf aMallocSizeOf, void* aArg);
|
||||
|
||||
/*
|
||||
* A PLDHashTable may be allocated on the stack or within another structure or
|
||||
* class. No entry storage is allocated until the first element is added. This
|
||||
* means that empty hash tables are cheap, which is good because they are
|
||||
* common.
|
||||
* A PLDHashTable is currently 8 words (without the PL_DHASHMETER overhead)
|
||||
* on most architectures, and may be allocated on the stack or within another
|
||||
* structure or class (see below for the Init and Finish functions to use).
|
||||
*
|
||||
* Due to historical reasons, there are two ways to manage the initialization
|
||||
* and finalization of a PLDHashTable. There are assertions that will trigger
|
||||
* if the two styles are mixed for a single table.
|
||||
*
|
||||
* - Automatic, C++ style: via the multi-arg constructor and the destructor.
|
||||
* This is the preferred style.
|
||||
*
|
||||
* - Manual, C style: via the Init() and Finish() methods. If Init() is
|
||||
* called on a table, then the Finish() must be called to finalize the
|
||||
* table, and the destructor will be a no-op.
|
||||
* No entry storage is allocated until the first element is added. This means
|
||||
* that empty hash tables are cheap, which is good because they are common.
|
||||
*
|
||||
* There used to be a long, math-heavy comment here about the merits of
|
||||
* double hashing vs. chaining; it was removed in bug 1058335. In short, double
|
||||
@ -178,8 +169,7 @@ private:
|
||||
uint32_t mEntrySize; /* number of bytes in an entry */
|
||||
uint32_t mEntryCount; /* number of entries in table */
|
||||
uint32_t mRemovedCount; /* removed entry sentinels in table */
|
||||
uint32_t mGeneration:31; /* entry storage generation number */
|
||||
uint32_t mAutoFinish:1; /* should the destructor call Finish()? */
|
||||
uint32_t mGeneration; /* entry storage generation number */
|
||||
char* mEntryStore; /* entry storage; allocated lazily */
|
||||
#ifdef PL_DHASHMETER
|
||||
struct PLDHashStats
|
||||
@ -224,7 +214,6 @@ public:
|
||||
, mEntryCount(0)
|
||||
, mRemovedCount(0)
|
||||
, mGeneration(0)
|
||||
, mAutoFinish(0)
|
||||
, mEntryStore(nullptr)
|
||||
#ifdef PL_DHASHMETER
|
||||
, mStats()
|
||||
@ -234,21 +223,8 @@ public:
|
||||
#endif
|
||||
{}
|
||||
|
||||
// Initialize the table with aOps and aEntrySize. The table's initial
|
||||
// capacity will be chosen such that |aLength| elements can be inserted
|
||||
// without rehashing; if |aLength| is a power-of-two, this capacity will be
|
||||
// |2*length|. However, because entry storage is allocated lazily, this
|
||||
// initial capacity won't be relevant until the first element is added; prior
|
||||
// to that the capacity will be zero.
|
||||
//
|
||||
// This function will crash if |aEntrySize| and/or |aLength| are too large.
|
||||
//
|
||||
PLDHashTable(const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
|
||||
PLDHashTable(PLDHashTable&& aOther)
|
||||
: mOps(nullptr)
|
||||
, mAutoFinish(0)
|
||||
, mEntryStore(nullptr)
|
||||
#ifdef DEBUG
|
||||
, mRecursionLevel(0)
|
||||
@ -259,8 +235,6 @@ public:
|
||||
|
||||
PLDHashTable& operator=(PLDHashTable&& aOther);
|
||||
|
||||
~PLDHashTable();
|
||||
|
||||
bool IsInitialized() const { return !!mOps; }
|
||||
|
||||
// These should be used rarely.
|
||||
@ -477,20 +451,38 @@ void PL_DHashFreeStringKey(PLDHashTable* aTable, PLDHashEntryHdr* aEntry);
|
||||
const PLDHashTableOps* PL_DHashGetStubOps(void);
|
||||
|
||||
/*
|
||||
* This function works similarly to the multi-arg constructor.
|
||||
* Dynamically allocate a new PLDHashTable, initialize it using
|
||||
* PL_DHashTableInit, and return its address. Never returns null.
|
||||
*/
|
||||
PLDHashTable* PL_NewDHashTable(
|
||||
const PLDHashTableOps* aOps, uint32_t aEntrySize,
|
||||
uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
|
||||
/*
|
||||
* Free |aTable|'s entry storage and |aTable| itself (both via
|
||||
* aTable->mOps->freeTable). Use this function to destroy a PLDHashTable that
|
||||
* was allocated on the heap via PL_NewDHashTable().
|
||||
*/
|
||||
void PL_DHashTableDestroy(PLDHashTable* aTable);
|
||||
|
||||
/*
|
||||
* Initialize aTable with aOps and aEntrySize. The table's initial capacity
|
||||
* will be chosen such that |aLength| elements can be inserted without
|
||||
* rehashing; if |aLength| is a power-of-two, this capacity will be |2*length|.
|
||||
* However, because entry storage is allocated lazily, this initial capacity
|
||||
* won't be relevant until the first element is added; prior to that the
|
||||
* capacity will be zero.
|
||||
*
|
||||
* Any table initialized with this function must be finalized via
|
||||
* PL_DHashTableFinish(). The alternative (and preferred) way to
|
||||
* initialize a PLDHashTable is via the multi-arg constructor; any such table
|
||||
* will be auto-finalized by the destructor.
|
||||
* This function will crash if |aEntrySize| and/or |aLength| are too large.
|
||||
*/
|
||||
void PL_DHashTableInit(
|
||||
PLDHashTable* aTable, const PLDHashTableOps* aOps,
|
||||
uint32_t aEntrySize, uint32_t aLength = PL_DHASH_DEFAULT_INITIAL_LENGTH);
|
||||
|
||||
/*
|
||||
* Free |aTable|'s entry storage. Use this function to finalize a PLDHashTable
|
||||
* that was initialized with PL_DHashTableInit().
|
||||
* Free |aTable|'s entry storage (via aTable->mOps->freeTable). Use this
|
||||
* function to destroy a PLDHashTable that is allocated on the stack or in
|
||||
* static memory and was created via PL_DHashTableInit().
|
||||
*/
|
||||
void PL_DHashTableFinish(PLDHashTable* aTable);
|
||||
|
||||
|
@ -53,7 +53,8 @@ static bool test_pldhash_Init_capacity_ok()
|
||||
|
||||
static bool test_pldhash_lazy_storage()
|
||||
{
|
||||
PLDHashTable t(PL_DHashGetStubOps(), sizeof(PLDHashEntryStub));
|
||||
PLDHashTable t;
|
||||
PL_DHashTableInit(&t, PL_DHashGetStubOps(), sizeof(PLDHashEntryStub));
|
||||
|
||||
// PLDHashTable allocates entry storage lazily. Check that all the non-add
|
||||
// operations work appropriately when the table is empty and the storage
|
||||
@ -106,6 +107,8 @@ static bool test_pldhash_lazy_storage()
|
||||
return false; // size is non-zero?
|
||||
}
|
||||
|
||||
PL_DHashTableFinish(&t);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -128,15 +131,19 @@ static bool test_pldhash_move_semantics()
|
||||
nullptr
|
||||
};
|
||||
|
||||
PLDHashTable t1(&ops, sizeof(PLDHashEntryStub));
|
||||
PLDHashTable t1, t2;
|
||||
PL_DHashTableInit(&t1, &ops, sizeof(PLDHashEntryStub));
|
||||
PL_DHashTableAdd(&t1, (const void*)88);
|
||||
PLDHashTable t2(&ops, sizeof(PLDHashEntryStub));
|
||||
PL_DHashTableInit(&t2, &ops, sizeof(PLDHashEntryStub));
|
||||
PL_DHashTableAdd(&t2, (const void*)99);
|
||||
|
||||
t1 = mozilla::Move(t1); // self-move
|
||||
|
||||
t1 = mozilla::Move(t2); // inited overwritten with inited
|
||||
|
||||
PL_DHashTableFinish(&t1);
|
||||
PL_DHashTableFinish(&t2);
|
||||
|
||||
PLDHashTable t3, t4;
|
||||
PL_DHashTableInit(&t3, &ops, sizeof(PLDHashEntryStub));
|
||||
PL_DHashTableAdd(&t3, (const void*)88);
|
||||
@ -158,7 +165,8 @@ static bool test_pldhash_move_semantics()
|
||||
PLDHashTable t7;
|
||||
PLDHashTable t8(mozilla::Move(t7)); // new table constructed with uninited
|
||||
|
||||
PLDHashTable t9(&ops, sizeof(PLDHashEntryStub));
|
||||
PLDHashTable t9;
|
||||
PL_DHashTableInit(&t9, &ops, sizeof(PLDHashEntryStub));
|
||||
PL_DHashTableAdd(&t9, (const void*)88);
|
||||
PLDHashTable t10(mozilla::Move(t9)); // new table constructed with inited
|
||||
|
||||
@ -178,11 +186,11 @@ static bool test_pldhash_grow_to_max_capacity()
|
||||
};
|
||||
|
||||
// This is infallible.
|
||||
PLDHashTable* t = new PLDHashTable(&ops, sizeof(PLDHashEntryStub), 128);
|
||||
PLDHashTable* t = PL_NewDHashTable(&ops, sizeof(PLDHashEntryStub), 128);
|
||||
|
||||
// Check that New() sets |t->ops|.
|
||||
if (!t->IsInitialized()) {
|
||||
delete t;
|
||||
PL_DHashTableDestroy(t);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -201,7 +209,7 @@ static bool test_pldhash_grow_to_max_capacity()
|
||||
return false;
|
||||
}
|
||||
|
||||
delete t;
|
||||
PL_DHashTableDestroy(t);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user