mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 847248 (part 6) - Remove nsFixedSizeAllocator from MemoryElement. r=enndeakin.
--HG-- extra : rebase_source : 60f6154a274b5553e09580566a9c7c9e862f658d
This commit is contained in:
parent
69c24c4508
commit
aa14a67f5f
@ -211,7 +211,7 @@ nsRDFConInstanceTestNode::FilterInstantiations(InstantiationSet& aInstantiations
|
||||
((mContainer == eDontCare) && (mEmpty == empty)))
|
||||
{
|
||||
Element* element =
|
||||
nsRDFConInstanceTestNode::Element::Create(valueres, container, empty);
|
||||
new nsRDFConInstanceTestNode::Element(valueres, container, empty);
|
||||
|
||||
if (! element)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -43,12 +43,6 @@ public:
|
||||
|
||||
|
||||
class Element : public MemoryElement {
|
||||
protected:
|
||||
// Hide so that only Create() and Destroy() can be used to
|
||||
// allocate and deallocate from the heap
|
||||
static void* operator new(size_t) CPP_THROW_NEW { return 0; }
|
||||
static void operator delete(void*, size_t) {}
|
||||
|
||||
public:
|
||||
Element(nsIRDFResource* aContainer,
|
||||
Test aContainerTest,
|
||||
@ -60,17 +54,6 @@ public:
|
||||
|
||||
virtual ~Element() { MOZ_COUNT_DTOR(nsRDFConInstanceTestNode::Element); }
|
||||
|
||||
static Element*
|
||||
Create(nsIRDFResource* aContainer,
|
||||
Test aContainerTest, Test aEmptyTest) {
|
||||
void* place = MemoryElement::gPool.Alloc(sizeof(Element));
|
||||
return place ? ::new (place) Element(aContainer, aContainerTest, aEmptyTest) : nullptr; }
|
||||
|
||||
void Destroy() {
|
||||
this->~Element();
|
||||
MemoryElement::gPool.Free(this, sizeof(Element));
|
||||
}
|
||||
|
||||
virtual const char* Type() const {
|
||||
return "nsRDFConInstanceTestNode::Element"; }
|
||||
|
||||
|
@ -180,8 +180,8 @@ nsRDFConMemberTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
if (isconsistent) {
|
||||
// Add a memory element to our set-of-support.
|
||||
Element* element =
|
||||
nsRDFConMemberTestNode::Element::Create(containerRes,
|
||||
memberValue);
|
||||
new nsRDFConMemberTestNode::Element(containerRes,
|
||||
memberValue);
|
||||
|
||||
if (! element)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -235,7 +235,7 @@ nsRDFConMemberTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
newinst.AddAssignment(mMemberVariable, node);
|
||||
|
||||
Element* element =
|
||||
nsRDFConMemberTestNode::Element::Create(containerRes, node);
|
||||
new nsRDFConMemberTestNode::Element(containerRes, node);
|
||||
|
||||
if (! element)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -325,8 +325,8 @@ nsRDFConMemberTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
newinst.AddAssignment(mContainerVariable, source);
|
||||
|
||||
Element* element =
|
||||
nsRDFConMemberTestNode::Element::Create(source,
|
||||
memberValue);
|
||||
new nsRDFConMemberTestNode::Element(source,
|
||||
memberValue);
|
||||
|
||||
if (! element)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -421,11 +421,11 @@ nsRDFConMemberTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
Element* element;
|
||||
if (hasContainerBinding) {
|
||||
element =
|
||||
nsRDFConMemberTestNode::Element::Create(containerRes, value);
|
||||
new nsRDFConMemberTestNode::Element(containerRes, value);
|
||||
}
|
||||
else {
|
||||
element =
|
||||
nsRDFConMemberTestNode::Element::Create(valueRes, memberValue);
|
||||
new nsRDFConMemberTestNode::Element(valueRes, memberValue);
|
||||
}
|
||||
|
||||
if (! element)
|
||||
|
@ -39,12 +39,6 @@ public:
|
||||
nsIRDFNode* aTarget) const;
|
||||
|
||||
class Element : public MemoryElement {
|
||||
protected:
|
||||
// Hide so that only Create() and Destroy() can be used to
|
||||
// allocate and deallocate from the heap
|
||||
static void* operator new(size_t) CPP_THROW_NEW { return 0; }
|
||||
static void operator delete(void*, size_t) {}
|
||||
|
||||
public:
|
||||
Element(nsIRDFResource* aContainer,
|
||||
nsIRDFNode* aMember)
|
||||
@ -54,16 +48,6 @@ public:
|
||||
|
||||
virtual ~Element() { MOZ_COUNT_DTOR(nsRDFConMemberTestNode::Element); }
|
||||
|
||||
static Element*
|
||||
Create(nsIRDFResource* aContainer, nsIRDFNode* aMember) {
|
||||
void* place = MemoryElement::gPool.Alloc(sizeof(Element));
|
||||
return place ? ::new (place) Element(aContainer, aMember) : nullptr; }
|
||||
|
||||
void Destroy() {
|
||||
this->~Element();
|
||||
MemoryElement::gPool.Free(this, sizeof(Element));
|
||||
}
|
||||
|
||||
virtual const char* Type() const {
|
||||
return "nsRDFConMemberTestNode::Element"; }
|
||||
|
||||
|
@ -187,9 +187,8 @@ nsRDFPropertyTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
if (hasAssertion) {
|
||||
// it's consistent.
|
||||
Element* element =
|
||||
nsRDFPropertyTestNode::Element::Create(sourceRes,
|
||||
mProperty,
|
||||
targetValue);
|
||||
new nsRDFPropertyTestNode::Element(sourceRes, mProperty,
|
||||
targetValue);
|
||||
|
||||
if (! element)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -286,9 +285,8 @@ nsRDFPropertyTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
|
||||
newinst.AddAssignment(variable, value);
|
||||
|
||||
Element* element =
|
||||
nsRDFPropertyTestNode::Element::Create(sourceRes,
|
||||
mProperty,
|
||||
targetValue);
|
||||
new nsRDFPropertyTestNode::Element(sourceRes, mProperty,
|
||||
targetValue);
|
||||
|
||||
if (! element)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -58,12 +58,6 @@ public:
|
||||
|
||||
|
||||
class Element : public MemoryElement {
|
||||
protected:
|
||||
// Hide so that only Create() and Destroy() can be used to
|
||||
// allocate and deallocate from the heap
|
||||
static void* operator new(size_t) CPP_THROW_NEW { return 0; }
|
||||
static void operator delete(void*, size_t) {}
|
||||
|
||||
public:
|
||||
Element(nsIRDFResource* aSource,
|
||||
nsIRDFResource* aProperty,
|
||||
@ -75,18 +69,6 @@ public:
|
||||
|
||||
virtual ~Element() { MOZ_COUNT_DTOR(nsRDFPropertyTestNode::Element); }
|
||||
|
||||
static Element*
|
||||
Create(nsIRDFResource* aSource,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aTarget) {
|
||||
void* place = MemoryElement::gPool.Alloc(sizeof(Element));
|
||||
return place ? ::new (place) Element(aSource, aProperty, aTarget) : nullptr; }
|
||||
|
||||
void Destroy() {
|
||||
this->~Element();
|
||||
MemoryElement::gPool.Free(this, sizeof(Element));
|
||||
}
|
||||
|
||||
virtual const char* Type() const {
|
||||
return "nsRDFPropertyTestNode::Element"; }
|
||||
|
||||
|
@ -39,29 +39,6 @@ extern PRLogModuleInfo* gXULTemplateLog;
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
bool MemoryElement::gPoolInited;
|
||||
nsFixedSizeAllocator MemoryElement::gPool;
|
||||
|
||||
// static
|
||||
bool
|
||||
MemoryElement::Init()
|
||||
{
|
||||
if (!gPoolInited) {
|
||||
const size_t bucketsizes[] = {
|
||||
sizeof (nsRDFConMemberTestNode::Element),
|
||||
sizeof (nsRDFPropertyTestNode::Element)
|
||||
};
|
||||
|
||||
if (NS_FAILED(gPool.Init("MemoryElement", bucketsizes,
|
||||
ArrayLength(bucketsizes), 256)))
|
||||
return false;
|
||||
|
||||
gPoolInited = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsRuleNetwork
|
||||
@ -75,7 +52,7 @@ MemoryElementSet::Add(MemoryElement* aElement)
|
||||
// We've already got this element covered. Since Add()
|
||||
// assumes ownership, and we aren't going to need this,
|
||||
// just nuke it.
|
||||
aElement->Destroy();
|
||||
delete aElement;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsFixedSizeAllocator.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "plhash.h"
|
||||
@ -54,15 +53,10 @@ class nsXULTemplateQueryProcessorRDF;
|
||||
class MemoryElement {
|
||||
protected:
|
||||
MemoryElement() { MOZ_COUNT_CTOR(MemoryElement); }
|
||||
virtual ~MemoryElement() { MOZ_COUNT_DTOR(MemoryElement); }
|
||||
|
||||
public:
|
||||
virtual ~MemoryElement() { MOZ_COUNT_DTOR(MemoryElement); }
|
||||
|
||||
static bool Init();
|
||||
|
||||
static bool gPoolInited;
|
||||
static nsFixedSizeAllocator gPool;
|
||||
|
||||
virtual void Destroy() = 0;
|
||||
virtual const char* Type() const = 0;
|
||||
virtual PLHashNumber Hash() const = 0;
|
||||
virtual bool Equals(const MemoryElement& aElement) const = 0;
|
||||
@ -93,7 +87,7 @@ protected:
|
||||
|
||||
~List() {
|
||||
MOZ_COUNT_DTOR(MemoryElementSet::List);
|
||||
mElement->Destroy();
|
||||
delete mElement;
|
||||
NS_IF_RELEASE(mNext); }
|
||||
|
||||
int32_t AddRef() { return ++mRefCnt; }
|
||||
|
@ -169,7 +169,7 @@ nsXULTemplateQueryProcessorRDF::InitGlobals()
|
||||
&kRDF_type);
|
||||
}
|
||||
|
||||
return MemoryElement::Init() ? NS_OK : NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user