You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2003/05/15 20:48:28 UTC
cvs commit: xml-xerces/c/src/xercesc/validators/common AllContentModel.cpp AllContentModel.hpp CMAny.cpp CMAny.hpp CMBinaryOp.cpp CMBinaryOp.hpp CMLeaf.hpp CMNode.hpp CMStateSet.hpp CMUnaryOp.cpp CMUnaryOp.hpp ContentLeafNameTypeVector.cpp ContentLeafNameTypeVector.hpp ContentSpecNode.cpp ContentSpecNode.hpp DFAContentModel.cpp DFAContentModel.hpp Grammar.hpp GrammarResolver.cpp GrammarResolver.hpp MixedContentModel.cpp MixedContentModel.hpp SimpleContentModel.hpp
knoaman 2003/05/15 11:48:28
Modified: c/src/xercesc/validators/common AllContentModel.cpp
AllContentModel.hpp CMAny.cpp CMAny.hpp
CMBinaryOp.cpp CMBinaryOp.hpp CMLeaf.hpp CMNode.hpp
CMStateSet.hpp CMUnaryOp.cpp CMUnaryOp.hpp
ContentLeafNameTypeVector.cpp
ContentLeafNameTypeVector.hpp ContentSpecNode.cpp
ContentSpecNode.hpp DFAContentModel.cpp
DFAContentModel.hpp Grammar.hpp GrammarResolver.cpp
GrammarResolver.hpp MixedContentModel.cpp
MixedContentModel.hpp SimpleContentModel.hpp
Log:
Partial implementation of the configurable memory manager.
Revision Changes Path
1.4 +20 -15 xml-xerces/c/src/xercesc/validators/common/AllContentModel.cpp
Index: AllContentModel.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/AllContentModel.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AllContentModel.cpp 4 Nov 2002 14:54:58 -0000 1.3
+++ AllContentModel.cpp 15 May 2003 18:48:27 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.3 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -93,9 +96,11 @@
// ---------------------------------------------------------------------------
// AllContentModel: Constructors and Destructor
// ---------------------------------------------------------------------------
-AllContentModel::AllContentModel(ContentSpecNode* const parentContentSpec
- , const bool isMixed) :
- fCount(0)
+AllContentModel::AllContentModel( ContentSpecNode* const parentContentSpec
+ , const bool isMixed
+ , MemoryManager* const manager) :
+ fMemoryManager(manager)
+ , fCount(0)
, fChildren(0)
, fChildOptional(0)
, fNumRequired(0)
@@ -128,8 +133,8 @@
// fill them in.
//
fCount = children.size();
- fChildren = new QName*[fCount];
- fChildOptional = new bool[fCount];
+ fChildren = (QName**) fMemoryManager->allocate(fCount * sizeof(QName*)); //new QName*[fCount];
+ fChildOptional = (bool*) fMemoryManager->allocate(fCount * sizeof(bool)); //new bool[fCount];
for (unsigned int index = 0; index < fCount; index++) {
fChildren[index] = children.elementAt(index);
fChildOptional[index] = childOptional.elementAt(index);
@@ -138,8 +143,8 @@
AllContentModel::~AllContentModel()
{
- delete [] fChildren;
- delete [] fChildOptional;
+ fMemoryManager->deallocate(fChildren); //delete [] fChildren;
+ fMemoryManager->deallocate(fChildOptional); //delete [] fChildOptional;
}
// ---------------------------------------------------------------------------
@@ -162,7 +167,7 @@
return -1;
// Check for duplicate element
- bool* elementSeen = new bool[fCount];
+ bool* elementSeen = (bool*) fMemoryManager->allocate(fCount*sizeof(bool)); //new bool[fCount];
// initialize the array
for (unsigned int i = 0; i < fCount; i++)
@@ -190,7 +195,7 @@
// If this element was seen already, indicate an error was
// found at the duplicate index.
if (elementSeen[inIndex]) {
- delete [] elementSeen;
+ fMemoryManager->deallocate(elementSeen); //delete [] elementSeen;
return outIndex;
}
else
@@ -205,13 +210,13 @@
// We did not find this one, so the validation failed
if (inIndex == fCount) {
- delete [] elementSeen;
+ fMemoryManager->deallocate(elementSeen); //delete [] elementSeen;
return outIndex;
}
}
- delete [] elementSeen;
+ fMemoryManager->deallocate(elementSeen); //delete [] elementSeen;
// Were all the required elements of the <all> encountered?
if (numRequiredSeen != fNumRequired) {
@@ -239,7 +244,7 @@
return -1;
// Check for duplicate element
- bool* elementSeen = new bool[fCount];
+ bool* elementSeen = (bool*) fMemoryManager->allocate(fCount*sizeof(bool)); //new bool[fCount];
// initialize the array
for (unsigned int i = 0; i < fCount; i++)
@@ -266,7 +271,7 @@
// If this element was seen already, indicate an error was
// found at the duplicate index.
if (elementSeen[inIndex]) {
- delete [] elementSeen;
+ fMemoryManager->deallocate(elementSeen); //delete [] elementSeen;
return outIndex;
}
else
@@ -281,13 +286,13 @@
// We did not find this one, so the validation failed
if (inIndex == fCount) {
- delete [] elementSeen;
+ fMemoryManager->deallocate(elementSeen); //delete [] elementSeen;
return outIndex;
}
}
- delete [] elementSeen;
+ fMemoryManager->deallocate(elementSeen); //delete [] elementSeen;
// Were all the required elements of the <all> encountered?
if (numRequiredSeen != fNumRequired) {
1.4 +8 -3 xml-xerces/c/src/xercesc/validators/common/AllContentModel.hpp
Index: AllContentModel.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/AllContentModel.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AllContentModel.hpp 7 Mar 2003 18:16:57 -0000 1.3
+++ AllContentModel.hpp 15 May 2003 18:48:27 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.3 2003/03/07 18:16:57 tng
* Return a reference instead of void for operator=
*
@@ -77,8 +80,8 @@
#if !defined(ALLCONTENTMODEL_HPP)
#define ALLCONTENTMODEL_HPP
-#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/framework/XMLContentModel.hpp>
+#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -102,8 +105,9 @@
// -----------------------------------------------------------------------
AllContentModel
(
- ContentSpecNode* const parentContentSpec
- , const bool isMixed
+ ContentSpecNode* const parentContentSpec
+ , const bool isMixed
+ , MemoryManager* const manager
);
~AllContentModel();
@@ -180,6 +184,7 @@
// fIsMixed
// AllContentModel with mixed PCDATA.
// -----------------------------------------------------------------------
+ MemoryManager* fMemoryManager;
unsigned int fCount;
QName** fChildren;
bool* fChildOptional;
1.3 +8 -4 xml-xerces/c/src/xercesc/validators/common/CMAny.cpp
Index: CMAny.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/CMAny.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CMAny.cpp 4 Nov 2002 14:54:58 -0000 1.2
+++ CMAny.cpp 15 May 2003 18:48:27 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.2 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -95,10 +98,11 @@
// ---------------------------------------------------------------------------
// CMUnaryOp: Constructors and Destructor
// ---------------------------------------------------------------------------
-CMAny::CMAny( const ContentSpecNode::NodeTypes type
- , const unsigned int URI
- , const unsigned int position ) :
- CMNode(type)
+CMAny::CMAny( const ContentSpecNode::NodeTypes type
+ , const unsigned int URI
+ , const unsigned int position
+ , MemoryManager* const manager) :
+ CMNode(type, manager)
, fURI(URI)
, fPosition(position)
{
1.3 +7 -4 xml-xerces/c/src/xercesc/validators/common/CMAny.hpp
Index: CMAny.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/CMAny.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CMAny.hpp 4 Nov 2002 14:54:58 -0000 1.2
+++ CMAny.hpp 15 May 2003 18:48:27 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.2 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -73,7 +76,6 @@
#if !defined(CMANY_HPP)
#define CMANY_HPP
-#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/validators/common/CMNode.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -88,9 +90,10 @@
// -----------------------------------------------------------------------
CMAny
(
- const ContentSpecNode::NodeTypes type
- , const unsigned int URI
- , const unsigned int position
+ const ContentSpecNode::NodeTypes type
+ , const unsigned int URI
+ , const unsigned int position
+ , MemoryManager* const manager
);
~CMAny();
1.3 +8 -4 xml-xerces/c/src/xercesc/validators/common/CMBinaryOp.cpp
Index: CMBinaryOp.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/CMBinaryOp.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CMBinaryOp.cpp 4 Nov 2002 14:54:58 -0000 1.2
+++ CMBinaryOp.cpp 15 May 2003 18:48:27 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.2 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -104,10 +107,11 @@
// ---------------------------------------------------------------------------
// CMBinaryOp: Constructors
// ---------------------------------------------------------------------------
-CMBinaryOp::CMBinaryOp( const ContentSpecNode::NodeTypes type
- , CMNode* const leftToAdopt
- , CMNode* const rightToAdopt) :
- CMNode(type)
+CMBinaryOp::CMBinaryOp( const ContentSpecNode::NodeTypes type
+ , CMNode* const leftToAdopt
+ , CMNode* const rightToAdopt
+ , MemoryManager* const manager) :
+ CMNode(type, manager)
, fLeftChild(leftToAdopt)
, fRightChild(rightToAdopt)
{
1.3 +7 -4 xml-xerces/c/src/xercesc/validators/common/CMBinaryOp.hpp
Index: CMBinaryOp.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/CMBinaryOp.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CMBinaryOp.hpp 4 Nov 2002 14:54:58 -0000 1.2
+++ CMBinaryOp.hpp 15 May 2003 18:48:27 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.2 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -95,7 +98,6 @@
#if !defined(CMBINARYOP_HPP)
#define CMBINARYOP_HPP
-#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/validators/common/CMNode.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -110,9 +112,10 @@
// -----------------------------------------------------------------------
CMBinaryOp
(
- const ContentSpecNode::NodeTypes type
- , CMNode* const leftToAdopt
- , CMNode* const rightToAdopt
+ const ContentSpecNode::NodeTypes type
+ , CMNode* const leftToAdopt
+ , CMNode* const rightToAdopt
+ , MemoryManager* const manager
);
~CMBinaryOp();
1.3 +32 -22 xml-xerces/c/src/xercesc/validators/common/CMLeaf.hpp
Index: CMLeaf.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/CMLeaf.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CMLeaf.hpp 4 Nov 2002 14:54:58 -0000 1.2
+++ CMLeaf.hpp 15 May 2003 18:48:27 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.2 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -114,11 +117,8 @@
#if !defined(CMLEAF_HPP)
#define CMLEAF_HPP
-#include <xercesc/util/XercesDefs.hpp>
-#include <xercesc/util/RuntimeException.hpp>
-#include <xercesc/validators/common/ContentSpecNode.hpp>
#include <xercesc/validators/common/CMNode.hpp>
-#include <xercesc/validators/common/CMStateSet.hpp>
+
XERCES_CPP_NAMESPACE_BEGIN
@@ -135,14 +135,16 @@
// -----------------------------------------------------------------------
CMLeaf
(
- QName* const element
- , const unsigned int position = ~0
+ QName* const element
+ , const unsigned int position = ~0
+ , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
CMLeaf
(
- QName* const element
- , const unsigned int position
- , const bool adopt
+ QName* const element
+ , const unsigned int position
+ , const bool adopt
+ , MemoryManager* const manager
);
~CMLeaf();
@@ -199,18 +201,22 @@
// -----------------------------------------------------------------------
// Constructors
// -----------------------------------------------------------------------
-inline CMLeaf::CMLeaf( QName* const element
- , const unsigned int position) :
- CMNode(ContentSpecNode::Leaf)
+inline CMLeaf::CMLeaf( QName* const element
+ , const unsigned int position
+ , MemoryManager* const manager) :
+ CMNode(ContentSpecNode::Leaf, manager)
, fElement(0)
, fPosition(position)
, fAdopt(false)
{
if (!element)
{
- fElement = new QName(XMLUni::fgZeroLenString
- , XMLUni::fgZeroLenString
- , XMLElementDecl::fgInvalidElemId);
+ fElement = new (fMemoryManager) QName
+ (
+ XMLUni::fgZeroLenString
+ , XMLUni::fgZeroLenString
+ , XMLElementDecl::fgInvalidElemId
+ );
// We have to be responsible for this QName - override default fAdopt
fAdopt = true;
}
@@ -220,19 +226,23 @@
}
}
-inline CMLeaf::CMLeaf( QName* const element
- , const unsigned int position
- , const bool adopt) :
- CMNode(ContentSpecNode::Leaf)
+inline CMLeaf::CMLeaf( QName* const element
+ , const unsigned int position
+ , const bool adopt
+ , MemoryManager* const manager) :
+ CMNode(ContentSpecNode::Leaf, manager)
, fElement(0)
, fPosition(position)
, fAdopt(adopt)
{
if (!element)
{
- fElement = new QName(XMLUni::fgZeroLenString
- , XMLUni::fgZeroLenString
- , XMLElementDecl::fgInvalidElemId);
+ fElement = new (fMemoryManager) QName
+ (
+ XMLUni::fgZeroLenString
+ , XMLUni::fgZeroLenString
+ , XMLElementDecl::fgInvalidElemId
+ );
// We have to be responsible for this QName - override adopt parameter
fAdopt = true;
}
1.4 +27 -11 xml-xerces/c/src/xercesc/validators/common/CMNode.hpp
Index: CMNode.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/CMNode.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CMNode.hpp 7 Mar 2003 18:16:57 -0000 1.3
+++ CMNode.hpp 15 May 2003 18:48:27 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.3 2003/03/07 18:16:57 tng
* Return a reference instead of void for operator=
*
@@ -102,19 +105,22 @@
#if !defined(CMNODE_HPP)
#define CMNODE_HPP
-#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/validators/common/ContentSpecNode.hpp>
#include <xercesc/validators/common/CMStateSet.hpp>
XERCES_CPP_NAMESPACE_BEGIN
-class CMNode
+class CMNode : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructors
// -----------------------------------------------------------------------
- CMNode(const ContentSpecNode::NodeTypes type);
+ CMNode
+ (
+ const ContentSpecNode::NodeTypes type
+ , MemoryManager* const manager
+ );
virtual ~CMNode();
@@ -145,6 +151,14 @@
virtual void calcFirstPos(CMStateSet& toUpdate) const = 0;
virtual void calcLastPos(CMStateSet& toUpdate) const = 0;
+ // -----------------------------------------------------------------------
+ // Protected data members
+ //
+ // fMemoryManager
+ // Pluggable memory manager for dynamic allocation/deallocation.
+ // -----------------------------------------------------------------------
+ MemoryManager* fMemoryManager;
+
private :
// -----------------------------------------------------------------------
@@ -177,10 +191,10 @@
// has to be stored redundantly, but we need to fault in the
// state set members and they have to be sized to this size.
// -----------------------------------------------------------------------
- ContentSpecNode::NodeTypes fType;
- CMStateSet* fFirstPos;
- CMStateSet* fLastPos;
- unsigned int fMaxStates;
+ ContentSpecNode::NodeTypes fType;
+ CMStateSet* fFirstPos;
+ CMStateSet* fLastPos;
+ unsigned int fMaxStates;
};
@@ -188,9 +202,11 @@
// ---------------------------------------------------------------------------
// CMNode: Constructors and Destructors
// ---------------------------------------------------------------------------
-inline CMNode::CMNode(const ContentSpecNode::NodeTypes type) :
+inline CMNode::CMNode(const ContentSpecNode::NodeTypes type,
+ MemoryManager* const manager) :
- fType(type)
+ fMemoryManager(manager)
+ , fType(type)
, fFirstPos(0)
, fLastPos(0)
, fMaxStates(~0)
@@ -222,7 +238,7 @@
if (!fFirstPos)
{
CMNode* unconstThis = (CMNode*)this;
- unconstThis->fFirstPos = new CMStateSet(fMaxStates);
+ unconstThis->fFirstPos = new (fMemoryManager) CMStateSet(fMaxStates, fMemoryManager);
unconstThis->calcFirstPos(*fFirstPos);
}
return *fFirstPos;
@@ -237,7 +253,7 @@
if (!fLastPos)
{
CMNode* unconstThis = (CMNode*)this;
- unconstThis->fLastPos = new CMStateSet(fMaxStates);
+ unconstThis->fLastPos = new (fMemoryManager) CMStateSet(fMaxStates, fMemoryManager);
unconstThis->calcLastPos(*fLastPos);
}
return *fLastPos;
1.4 +14 -7 xml-xerces/c/src/xercesc/validators/common/CMStateSet.hpp
Index: CMStateSet.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/CMStateSet.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CMStateSet.hpp 4 Nov 2002 14:54:58 -0000 1.3
+++ CMStateSet.hpp 15 May 2003 18:48:27 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.3 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -112,23 +115,25 @@
#if !defined(CMSTATESET_HPP)
#define CMSTATESET_HPP
-#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/ArrayIndexOutOfBoundsException.hpp>
-#include <xercesc/framework/XMLValidityCodes.hpp>
+#include <xercesc/util/RuntimeException.hpp>
+#include <xercesc/framework/MemoryManager.hpp>
#include <string.h>
XERCES_CPP_NAMESPACE_BEGIN
-class CMStateSet
+class CMStateSet : public XMemory
{
public :
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
- CMStateSet(const unsigned int bitCount) :
+ CMStateSet( const unsigned int bitCount
+ , MemoryManager* const manager) :
fBitCount(bitCount)
, fByteArray(0)
+ , fMemoryManager(manager)
{
//
// See if we need to allocate the byte array or whether we can live
@@ -139,7 +144,7 @@
fByteCount = fBitCount / 8;
if (fBitCount % 8)
fByteCount++;
- fByteArray = new XMLByte[fByteCount];
+ fByteArray = (XMLByte*) fMemoryManager->allocate(fByteCount*sizeof(XMLByte)); //new XMLByte[fByteCount];
}
// Init all the bits to zero
@@ -157,6 +162,7 @@
CMStateSet(const CMStateSet& toCopy) :
fBitCount(toCopy.fBitCount)
, fByteArray(0)
+ , fMemoryManager(toCopy.fMemoryManager)
{
//
// See if we need to allocate the byte array or whether we can live
@@ -167,7 +173,7 @@
fByteCount = fBitCount / 8;
if (fBitCount % 8)
fByteCount++;
- fByteArray = new XMLByte[fByteCount];
+ fByteArray = (XMLByte*) fMemoryManager->allocate(fByteCount*sizeof(XMLByte)); //new XMLByte[fByteCount];
memcpy((void *) fByteArray,
(const void *) toCopy.fByteArray,
@@ -186,7 +192,7 @@
~CMStateSet()
{
if (fByteArray)
- delete [] fByteArray;
+ fMemoryManager->deallocate(fByteArray); //delete [] fByteArray;
}
@@ -392,6 +398,7 @@
unsigned int fBits1;
unsigned int fBits2;
XMLByte* fByteArray;
+ MemoryManager* fMemoryManager;
};
XERCES_CPP_NAMESPACE_END
1.3 +7 -4 xml-xerces/c/src/xercesc/validators/common/CMUnaryOp.cpp
Index: CMUnaryOp.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/CMUnaryOp.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CMUnaryOp.cpp 4 Nov 2002 14:54:58 -0000 1.2
+++ CMUnaryOp.cpp 15 May 2003 18:48:27 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.2 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -96,7 +99,6 @@
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
-#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/RuntimeException.hpp>
#include <xercesc/validators/common/CMStateSet.hpp>
#include <xercesc/validators/common/CMUnaryOp.hpp>
@@ -106,9 +108,10 @@
// ---------------------------------------------------------------------------
// CMUnaryOp: Constructors and Destructor
// ---------------------------------------------------------------------------
-CMUnaryOp::CMUnaryOp( const ContentSpecNode::NodeTypes type
- , CMNode* const nodeToAdopt) :
- CMNode(type)
+CMUnaryOp::CMUnaryOp( const ContentSpecNode::NodeTypes type
+ , CMNode* const nodeToAdopt
+ , MemoryManager* const manager) :
+ CMNode(type, manager)
, fChild(nodeToAdopt)
{
// Insure that its one of the types we require
1.3 +7 -4 xml-xerces/c/src/xercesc/validators/common/CMUnaryOp.hpp
Index: CMUnaryOp.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/CMUnaryOp.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CMUnaryOp.hpp 4 Nov 2002 14:54:58 -0000 1.2
+++ CMUnaryOp.hpp 15 May 2003 18:48:27 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.2 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -96,9 +99,8 @@
#if !defined(CMUNARYOP_HPP)
#define CMUNARYOP_HPP
-#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/validators/common/CMNode.hpp>
-#include <xercesc/validators/common/ContentSpecNode.hpp>
+
XERCES_CPP_NAMESPACE_BEGIN
@@ -112,8 +114,9 @@
// -----------------------------------------------------------------------
CMUnaryOp
(
- const ContentSpecNode::NodeTypes type
- , CMNode* const nodeToAdopt
+ const ContentSpecNode::NodeTypes type
+ , CMNode* const nodeToAdopt
+ , MemoryManager* const manager
);
~CMUnaryOp();
1.3 +24 -12 xml-xerces/c/src/xercesc/validators/common/ContentLeafNameTypeVector.cpp
Index: ContentLeafNameTypeVector.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/ContentLeafNameTypeVector.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ContentLeafNameTypeVector.cpp 4 Nov 2002 14:54:58 -0000 1.2
+++ ContentLeafNameTypeVector.cpp 15 May 2003 18:48:27 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.2 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -77,7 +80,6 @@
// ---------------------------------------------------------------------------
// Includes
// ---------------------------------------------------------------------------
-#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -85,19 +87,26 @@
// ---------------------------------------------------------------------------
// ContentLeafNameTypeVector: Constructors and Destructor
// ---------------------------------------------------------------------------
-ContentLeafNameTypeVector::ContentLeafNameTypeVector()
-: fLeafNames(0)
+ContentLeafNameTypeVector::ContentLeafNameTypeVector
+(
+ MemoryManager* const manager
+)
+: fMemoryManager(manager)
+, fLeafNames(0)
, fLeafTypes(0)
, fLeafCount(0)
{
}
ContentLeafNameTypeVector::ContentLeafNameTypeVector
- ( QName** const names
- , ContentSpecNode::NodeTypes* const types
- , const unsigned int count
- )
-: fLeafNames(0)
+(
+ QName** const names
+ , ContentSpecNode::NodeTypes* const types
+ , const unsigned int count
+ , MemoryManager* const manager
+)
+: fMemoryManager(manager)
+, fLeafNames(0)
, fLeafTypes(0)
, fLeafCount(0)
{
@@ -108,10 +117,13 @@
copy ctor
***/
ContentLeafNameTypeVector::ContentLeafNameTypeVector
- (const ContentLeafNameTypeVector& toCopy)
- :fLeafNames(0)
- ,fLeafTypes(0)
- ,fLeafCount(0)
+(
+ const ContentLeafNameTypeVector& toCopy
+)
+: fMemoryManager(toCopy.fMemoryManager)
+, fLeafNames(0)
+, fLeafTypes(0)
+, fLeafCount(0)
{
fLeafCount=toCopy.getLeafCount();
init(fLeafCount);
1.4 +19 -12 xml-xerces/c/src/xercesc/validators/common/ContentLeafNameTypeVector.hpp
Index: ContentLeafNameTypeVector.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/ContentLeafNameTypeVector.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ContentLeafNameTypeVector.hpp 7 Mar 2003 18:16:57 -0000 1.3
+++ ContentLeafNameTypeVector.hpp 15 May 2003 18:48:27 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.3 2003/03/07 18:16:57 tng
* Return a reference instead of void for operator=
*
@@ -83,13 +86,12 @@
#if !defined(CONTENTLEAFNAMETYPEVECTOR_HPP)
#define CONTENTLEAFNAMETYPEVECTOR_HPP
-#include <xercesc/util/XercesDefs.hpp>
-#include <xercesc/util/ValueVectorOf.hpp>
#include <xercesc/validators/common/ContentSpecNode.hpp>
+#include <xercesc/framework/MemoryManager.hpp>
XERCES_CPP_NAMESPACE_BEGIN
-class ContentLeafNameTypeVector
+class ContentLeafNameTypeVector : public XMemory
{
public :
// -----------------------------------------------------------------------
@@ -100,12 +102,13 @@
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
- ContentLeafNameTypeVector();
+ ContentLeafNameTypeVector(MemoryManager* const manager);
ContentLeafNameTypeVector
(
- QName** const qName
- , ContentSpecNode::NodeTypes* const types
- , const unsigned int count
+ QName** const qName
+ , ContentSpecNode::NodeTypes* const types
+ , const unsigned int count
+ , MemoryManager* const manager
);
~ContentLeafNameTypeVector();
@@ -150,6 +153,7 @@
// Private Data Members
//
// -----------------------------------------------------------------------
+ MemoryManager* fMemoryManager;
QName** fLeafNames;
ContentSpecNode::NodeTypes *fLeafTypes;
unsigned int fLeafCount;
@@ -157,15 +161,18 @@
inline void ContentLeafNameTypeVector::cleanUp()
{
- delete [] fLeafNames;
- delete [] fLeafTypes;
+ fMemoryManager->deallocate(fLeafNames); //delete [] fLeafNames;
+ fMemoryManager->deallocate(fLeafTypes); //delete [] fLeafTypes;
}
inline void ContentLeafNameTypeVector::init(const unsigned int size)
{
- fLeafNames = new QName*[size];
- fLeafTypes = new ContentSpecNode::NodeTypes [size];
- fLeafCount = size;
+ fLeafNames = (QName**) fMemoryManager->allocate(size * sizeof(QName*));//new QName*[size];
+ fLeafTypes = (ContentSpecNode::NodeTypes *) fMemoryManager->allocate
+ (
+ size * sizeof(ContentSpecNode::NodeTypes)
+ ); //new ContentSpecNode::NodeTypes [size];
+ fLeafCount = size;
}
XERCES_CPP_NAMESPACE_END
1.7 +6 -5 xml-xerces/c/src/xercesc/validators/common/ContentSpecNode.cpp
Index: ContentSpecNode.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/ContentSpecNode.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ContentSpecNode.cpp 13 Jan 2003 20:16:51 -0000 1.6
+++ ContentSpecNode.cpp 15 May 2003 18:48:27 -0000 1.7
@@ -81,23 +81,24 @@
// aka inline function compilation error on AIX 4.2, xlC 3 r ev.1
// ---------------------------------------------------------------------------
-ContentSpecNode::ContentSpecNode(const ContentSpecNode& toCopy)
+ContentSpecNode::ContentSpecNode(const ContentSpecNode& toCopy) :
+ fMemoryManager(XMLPlatformUtils::fgMemoryManager)
{
const QName* tempElement = toCopy.getElement();
if (tempElement)
- fElement = new QName(*tempElement);
+ fElement = new (fMemoryManager) QName(*tempElement);
else
fElement = 0;
const ContentSpecNode *tmp = toCopy.getFirst();
if (tmp)
- fFirst = new ContentSpecNode(*tmp);
+ fFirst = new (fMemoryManager) ContentSpecNode(*tmp);
else
fFirst = 0;
tmp = toCopy.getSecond();
if (tmp)
- fSecond = new ContentSpecNode(*tmp);
+ fSecond = new (fMemoryManager) ContentSpecNode(*tmp);
else
fSecond = 0;
1.6 +17 -9 xml-xerces/c/src/xercesc/validators/common/ContentSpecNode.hpp
Index: ContentSpecNode.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/ContentSpecNode.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ContentSpecNode.hpp 4 Nov 2002 14:54:58 -0000 1.5
+++ ContentSpecNode.hpp 15 May 2003 18:48:27 -0000 1.6
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.6 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.5 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -158,8 +161,8 @@
#if !defined(CONTENTSPECNODE_HPP)
#define CONTENTSPECNODE_HPP
-#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/framework/XMLElementDecl.hpp>
+#include <xercesc/framework/MemoryManager.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -167,7 +170,7 @@
class Grammar;
-class ContentSpecNode
+class ContentSpecNode : public XMemory
{
public :
// -----------------------------------------------------------------------
@@ -296,6 +299,7 @@
// Indicate the maximum times that this node can occur
// -1 (Unbounded), default (1)
// -----------------------------------------------------------------------
+ MemoryManager* fMemoryManager;
QName* fElement;
ContentSpecNode* fFirst;
ContentSpecNode* fSecond;
@@ -311,7 +315,8 @@
// ---------------------------------------------------------------------------
inline ContentSpecNode::ContentSpecNode() :
- fElement(0)
+ fMemoryManager(XMLPlatformUtils::fgMemoryManager)
+ , fElement(0)
, fFirst(0)
, fSecond(0)
, fType(ContentSpecNode::Leaf)
@@ -325,7 +330,8 @@
inline
ContentSpecNode::ContentSpecNode(QName* const element) :
- fElement(0)
+ fMemoryManager(XMLPlatformUtils::fgMemoryManager)
+ , fElement(0)
, fFirst(0)
, fSecond(0)
, fType(ContentSpecNode::Leaf)
@@ -335,14 +341,15 @@
, fMaxOccurs(1)
{
if (element)
- fElement = new QName(*element);
+ fElement = new (fMemoryManager) QName(*element);
}
inline
ContentSpecNode::ContentSpecNode(QName* const element
, const bool copyQName) :
- fElement(0)
+ fMemoryManager(XMLPlatformUtils::fgMemoryManager)
+ , fElement(0)
, fFirst(0)
, fSecond(0)
, fType(ContentSpecNode::Leaf)
@@ -354,7 +361,7 @@
if (copyQName)
{
if (element)
- fElement = new QName(*element);
+ fElement = new (fMemoryManager) QName(*element);
}
else
{
@@ -369,7 +376,8 @@
, const bool adoptFirst
, const bool adoptSecond) :
- fElement(0)
+ fMemoryManager(XMLPlatformUtils::fgMemoryManager)
+ , fElement(0)
, fFirst(firstAdopt)
, fSecond(secondAdopt)
, fType(type)
@@ -476,7 +484,7 @@
delete fElement;
fElement = 0;
if (element)
- fElement = new QName(*element);
+ fElement = new (fMemoryManager) QName(*element);
}
inline void ContentSpecNode::setFirst(ContentSpecNode* const toAdopt)
1.5 +167 -60 xml-xerces/c/src/xercesc/validators/common/DFAContentModel.cpp
Index: DFAContentModel.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/DFAContentModel.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DFAContentModel.cpp 4 Nov 2002 14:54:58 -0000 1.4
+++ DFAContentModel.cpp 15 May 2003 18:48:27 -0000 1.5
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.5 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.4 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -222,8 +225,9 @@
// ---------------------------------------------------------------------------
// DFAContentModel: Constructors and Destructor
// ---------------------------------------------------------------------------
-DFAContentModel::DFAContentModel(const bool dtd
- , ContentSpecNode* const elemContentSpec) :
+DFAContentModel::DFAContentModel( const bool dtd
+ , ContentSpecNode* const elemContentSpec
+ , MemoryManager* const manager) :
fElemMap(0)
, fElemMapType(0)
@@ -240,14 +244,16 @@
, fDTD(dtd)
, fIsMixed(false)
, fLeafNameTypeVector(0)
+ , fMemoryManager(manager)
{
// And build the DFA data structures
buildDFA(elemContentSpec);
}
-DFAContentModel::DFAContentModel(const bool dtd
- , ContentSpecNode* const elemContentSpec
- , const bool isMixed ):
+DFAContentModel::DFAContentModel( const bool dtd
+ , ContentSpecNode* const elemContentSpec
+ , const bool isMixed
+ , MemoryManager* const manager):
fElemMap(0)
, fElemMapType(0)
@@ -264,6 +270,7 @@
, fDTD(dtd)
, fIsMixed(isMixed)
, fLeafNameTypeVector(0)
+ , fMemoryManager(manager)
{
// And build the DFA data structures
buildDFA(elemContentSpec);
@@ -275,19 +282,19 @@
// Clean up all the stuff that is not just temporary representation
// data that was cleaned up after building the DFA.
//
- delete [] fFinalStateFlags;
+ fMemoryManager->deallocate(fFinalStateFlags); //delete [] fFinalStateFlags;
unsigned index;
for (index = 0; index < fTransTableSize; index++)
- delete [] fTransTable[index];
- delete [] fTransTable;
+ fMemoryManager->deallocate(fTransTable[index]); //delete [] fTransTable[index];
+ fMemoryManager->deallocate(fTransTable); //delete [] fTransTable;
for (index = 0; index < fLeafCount; index++)
delete fElemMap[index];
- delete [] fElemMap;
+ fMemoryManager->deallocate(fElemMap); //delete [] fElemMap;
- delete [] fElemMapType;
- delete [] fLeafListType;
+ fMemoryManager->deallocate(fElemMapType); //delete [] fElemMapType;
+ fMemoryManager->deallocate(fLeafListType); //delete [] fLeafListType;
delete fLeafNameTypeVector;
}
@@ -536,17 +543,25 @@
// DFA state position and count the number of such leafs, which is left
// in the fLeafCount member.
//
- CMLeaf* nodeEOC = new CMLeaf(new QName(XMLUni::fgZeroLenString,
- XMLUni::fgZeroLenString,
- XMLContentModel::gEOCFakeId)
- , ~0
- , true);
+ CMLeaf* nodeEOC = new (fMemoryManager) CMLeaf
+ (
+ new (fMemoryManager) QName
+ (
+ XMLUni::fgZeroLenString
+ , XMLUni::fgZeroLenString
+ , XMLContentModel::gEOCFakeId
+ )
+ , ~0
+ , true
+ , fMemoryManager
+ );
CMNode* nodeOrgContent = buildSyntaxTree(curNode);
- fHeadNode = new CMBinaryOp
+ fHeadNode = new (fMemoryManager) CMBinaryOp
(
ContentSpecNode::Sequence
, nodeOrgContent
, nodeEOC
+ , fMemoryManager
);
//
@@ -573,8 +588,11 @@
// initial tree build (which built their position numbers, we will put
// them in the array according to their position values.
//
- fLeafList = new CMLeaf*[fLeafCount];
- fLeafListType = new ContentSpecNode::NodeTypes[fLeafCount];
+ fLeafList = (CMLeaf**) fMemoryManager->allocate(fLeafCount*sizeof(CMLeaf*)); //new CMLeaf*[fLeafCount];
+ fLeafListType = (ContentSpecNode::NodeTypes*) fMemoryManager->allocate
+ (
+ fLeafCount * sizeof(ContentSpecNode::NodeTypes)
+ ); //new ContentSpecNode::NodeTypes[fLeafCount];
postTreeBuildInit(fHeadNode, 0);
//
@@ -582,9 +600,12 @@
// for all the nodes. So we allocate an array of pointers to state sets,
// one for each leaf node (i.e. each significant DFA position.)
//
- fFollowList = new CMStateSet*[fLeafCount];
+ fFollowList = (CMStateSet**) fMemoryManager->allocate
+ (
+ fLeafCount * sizeof(CMStateSet*)
+ ); //new CMStateSet*[fLeafCount];
for (index = 0; index < fLeafCount; index++)
- fFollowList[index] = new CMStateSet(fLeafCount);
+ fFollowList[index] = new (fMemoryManager) CMStateSet(fLeafCount, fMemoryManager);
calcFollowList(fHeadNode);
//
@@ -608,18 +629,24 @@
// So we need to a zero based range of indexes that map to element types.
// This element map provides that mapping.
//
- fElemMap = new QName*[fLeafCount];
- fElemMapType = new ContentSpecNode::NodeTypes[fLeafCount];
+ fElemMap = (QName**) fMemoryManager->allocate
+ (
+ fLeafCount * sizeof(QName*)
+ ); //new QName*[fLeafCount];
+ fElemMapType = (ContentSpecNode::NodeTypes*) fMemoryManager->allocate
+ (
+ fLeafCount * sizeof(ContentSpecNode::NodeTypes)
+ ); //new ContentSpecNode::NodeTypes[fLeafCount];
fElemMapSize = 0;
for (unsigned int outIndex = 0; outIndex < fLeafCount; outIndex++)
{
- fElemMap[outIndex] = new QName();
+ fElemMap[outIndex] = new (fMemoryManager) QName();
if ( (fLeafListType[outIndex] & 0x0f) != ContentSpecNode::Leaf )
if (!fLeafNameTypeVector)
- fLeafNameTypeVector = new ContentLeafNameTypeVector();
+ fLeafNameTypeVector = new (fMemoryManager) ContentLeafNameTypeVector(fMemoryManager);
// Get the current leaf's element index
const QName* element = fLeafList[outIndex]->getElement();
@@ -668,7 +695,10 @@
**/
// don't forget to delete it
- int *fLeafSorter = new int[fLeafCount + fElemMapSize];
+ int *fLeafSorter = (int*) fMemoryManager->allocate
+ (
+ (fLeafCount + fElemMapSize) * sizeof(int)
+ ); //new int[fLeafCount + fElemMapSize];
unsigned int fSortCount = 0;
for (unsigned int elemIndex = 0; elemIndex < fElemMapSize; elemIndex++)
@@ -710,15 +740,25 @@
// have to expand though, it if does, the overhead will be somewhat ugly.
//
unsigned int curArraySize = fLeafCount * 4;
- const CMStateSet** statesToDo = new const CMStateSet*[curArraySize];
- fFinalStateFlags = new bool[curArraySize];
- fTransTable = new unsigned int*[curArraySize];
+ const CMStateSet** statesToDo = (const CMStateSet**)
+ fMemoryManager->allocate
+ (
+ curArraySize * sizeof(const CMStateSet*)
+ ); //new const CMStateSet*[curArraySize];
+ fFinalStateFlags = (bool*) fMemoryManager->allocate
+ (
+ curArraySize * sizeof(bool)
+ ); //new bool[curArraySize];
+ fTransTable = (unsigned int**) fMemoryManager->allocate
+ (
+ curArraySize * sizeof(unsigned int*)
+ ); //new unsigned int*[curArraySize];
//
// Ok we start with the initial set as the first pos set of the head node
// (which is the seq node that holds the content model and the EOC node.)
//
- const CMStateSet* setT = new CMStateSet(fHeadNode->getFirstPos());
+ const CMStateSet* setT = new (fMemoryManager) CMStateSet(fHeadNode->getFirstPos());
//
// Init our two state flags. Basically the unmarked state counter is
@@ -747,8 +787,14 @@
//
// TODO: in the future, we may change the 29 to something
// derived from curArraySize.
- RefHashTableOf<XMLInteger> *stateTable = new RefHashTableOf<XMLInteger>(curArraySize, true, new HashCMStateSet());
- //stateTable->put((CMStateSet*)setT, new XMLInteger(0));
+ RefHashTableOf<XMLInteger> *stateTable =
+ new (fMemoryManager) RefHashTableOf<XMLInteger>
+ (
+ curArraySize
+ , true
+ , new (fMemoryManager) HashCMStateSet()
+ );
+ //stateTable->put((CMStateSet*)setT, new (fMemoryManager) XMLInteger(0));
//
// Ok, almost done with the algorithm from hell... We now enter the
@@ -785,7 +831,11 @@
// one. Otherwise, zero out the existing one.
//
if (!newSet)
- newSet = new CMStateSet(fLeafCount);
+ newSet = new (fMemoryManager) CMStateSet
+ (
+ fLeafCount
+ , fMemoryManager
+ );
else
newSet->zeroBits();
@@ -868,7 +918,11 @@
//
statesToDo[curState] = newSet;
fTransTable[curState] = makeDefStateList();
- stateTable->put(newSet, new XMLInteger(curState));
+ stateTable->put
+ (
+ newSet
+ , new (fMemoryManager) XMLInteger(curState)
+ );
// We now have a new state to do so bump the count
curState++;
@@ -897,9 +951,20 @@
// size by 50% and allocate new arrays.
//
const unsigned int newSize = (unsigned int)(curArraySize * 1.5);
- const CMStateSet** newToDo = new const CMStateSet*[newSize];
- bool* newFinalFlags = new bool[newSize];
- unsigned int** newTransTable = new unsigned int*[newSize];
+ const CMStateSet** newToDo = (const CMStateSet**)
+ fMemoryManager->allocate
+ (
+ newSize * sizeof(const CMStateSet*)
+ ); //new const CMStateSet*[newSize];
+ bool* newFinalFlags = (bool*) fMemoryManager->allocate
+ (
+ newSize * sizeof(bool)
+ ); //new bool[newSize];
+ unsigned int** newTransTable = (unsigned int**)
+ fMemoryManager->allocate
+ (
+ newSize * sizeof(unsigned int*)
+ ); //new unsigned int*[newSize];
// Copy over all of the existing content
for (unsigned int expIndex = 0; expIndex < curArraySize; expIndex++)
@@ -910,9 +975,9 @@
}
// Clean up the old stuff
- delete [] statesToDo;
- delete [] fFinalStateFlags;
- delete [] fTransTable;
+ fMemoryManager->deallocate(statesToDo); //delete [] statesToDo;
+ fMemoryManager->deallocate(fFinalStateFlags); //delete [] fFinalStateFlags;
+ fMemoryManager->deallocate(fTransTable); //delete [] fTransTable;
// Store the new array size and pointers
curArraySize = newSize;
@@ -951,7 +1016,7 @@
for (index = 0; index < fLeafCount; index++)
delete fFollowList[index];
- delete [] fFollowList;
+ fMemoryManager->deallocate(fFollowList); //delete [] fFollowList;
//
// removeAll() will delete all data, XMLInteger,
@@ -962,13 +1027,13 @@
for (index = 0; index < curState; index++)
delete (CMStateSet*)statesToDo[index];
- delete [] statesToDo;
+ fMemoryManager->deallocate(statesToDo); //delete [] statesToDo;
for (index = 0; index < fLeafCount; index++)
delete fLeafList[index];
- delete [] fLeafList;
+ fMemoryManager->deallocate(fLeafList); //delete [] fLeafList;
- delete [] fLeafSorter;
+ fMemoryManager->deallocate(fLeafSorter); //delete [] fLeafSorter;
}
@@ -985,7 +1050,13 @@
|| (curType & 0x0f) == ContentSpecNode::Any_Other
|| (curType & 0x0f) == ContentSpecNode::Any_NS)
{
- retNode = new CMAny(curType, curNode->getElement()->getURI(), fLeafCount++);
+ retNode = new (fMemoryManager) CMAny
+ (
+ curType
+ , curNode->getElement()->getURI()
+ , fLeafCount++
+ , fMemoryManager
+ );
}
else if (curType == ContentSpecNode::Leaf)
{
@@ -995,7 +1066,12 @@
// This makes the positions zero based since we store first and then
// increment.
//
- retNode = new CMLeaf(curNode->getElement(), fLeafCount++);
+ retNode = new (fMemoryManager) CMLeaf
+ (
+ curNode->getElement()
+ , fLeafCount++
+ , fMemoryManager
+ );
}
else
{
@@ -1016,14 +1092,25 @@
//
CMNode* newLeft = buildSyntaxTree(leftNode);
CMNode* newRight = buildSyntaxTree(rightNode);
- retNode = new CMBinaryOp(curType, newLeft, newRight);
+ retNode = new (fMemoryManager) CMBinaryOp
+ (
+ curType
+ , newLeft
+ , newRight
+ , fMemoryManager
+ );
}
else if (curType == ContentSpecNode::ZeroOrMore
|| curType == ContentSpecNode::ZeroOrOne
|| curType == ContentSpecNode::OneOrMore)
{
// This one is fine as is, just change to our form
- retNode = new CMUnaryOp(curType, buildSyntaxTree(leftNode));
+ retNode = new (fMemoryManager) CMUnaryOp
+ (
+ curType
+ , buildSyntaxTree(leftNode)
+ , fMemoryManager
+ );
}
else
{
@@ -1108,7 +1195,10 @@
//
unsigned int* DFAContentModel::makeDefStateList() const
{
- unsigned int* retArray = new unsigned int[fElemMapSize];
+ unsigned int* retArray = (unsigned int*) fMemoryManager->allocate
+ (
+ fElemMapSize * sizeof(unsigned int)
+ ); //new unsigned int[fElemMapSize];
for (unsigned int index = 0; index < fElemMapSize; index++)
retArray[index] = XMLContentModel::gInvalidTrans;
return retArray;
@@ -1132,11 +1222,18 @@
((curType & 0x0f) == ContentSpecNode::Any_NS) ||
((curType & 0x0f) == ContentSpecNode::Any_Other) )
{
- fLeafList[newIndex] = new CMLeaf(new QName(XMLUni::fgZeroLenString
- , XMLUni::fgZeroLenString
- , ((CMAny*) nodeCur)->getURI())
- , ((CMAny*)nodeCur)->getPosition()
- , true);
+ fLeafList[newIndex] = new (fMemoryManager) CMLeaf
+ (
+ new (fMemoryManager) QName
+ (
+ XMLUni::fgZeroLenString
+ , XMLUni::fgZeroLenString
+ , ((CMAny*) nodeCur)->getURI()
+ )
+ , ((CMAny*)nodeCur)->getPosition()
+ , true
+ , fMemoryManager
+ );
fLeafListType[newIndex] = curType;
++newIndex;
}
@@ -1166,8 +1263,12 @@
// will NOT delete the nodeCur --twice--,
// thuse to make delete the owner of the nodeCur possible.
//
- fLeafList[newIndex] = new CMLeaf(((CMLeaf*)nodeCur)->getElement(),
- ((CMLeaf*)nodeCur)->getPosition());
+ fLeafList[newIndex] = new (fMemoryManager) CMLeaf
+ (
+ ((CMLeaf*)nodeCur)->getElement()
+ , ((CMLeaf*)nodeCur)->getPosition()
+ , fMemoryManager
+ );
fLeafListType[newIndex] = ContentSpecNode::Leaf;
++newIndex;
}
@@ -1214,11 +1315,17 @@
// Unique Particle Attribution
// store the conflict results between any two elements in fElemMap
// XMLContentModel::gInvalidTrans: not compared; 0: no conflict; 1: conflict
- unsigned int** fConflictTable = new unsigned int*[fElemMapSize];
+ unsigned int** fConflictTable = (unsigned int**) fMemoryManager->allocate
+ (
+ fElemMapSize * sizeof(unsigned int*)
+ ); //new unsigned int*[fElemMapSize];
// initialize the conflict table
for (j = 0; j < fElemMapSize; j++) {
- fConflictTable[j] = new unsigned int[fElemMapSize];
+ fConflictTable[j] = (unsigned int*) fMemoryManager->allocate
+ (
+ fElemMapSize * sizeof(unsigned int)
+ ); //new unsigned int[fElemMapSize];
for (k = j+1; k < fElemMapSize; k++)
fConflictTable[j][k] = XMLContentModel::gInvalidTrans;
}
@@ -1275,8 +1382,8 @@
}
for (i = 0; i < fElemMapSize; i++)
- delete [] fConflictTable[i];
- delete [] fConflictTable;
+ fMemoryManager->deallocate(fConflictTable[i]); //delete [] fConflictTable[i];
+ fMemoryManager->deallocate(fConflictTable); //delete [] fConflictTable;
}
XERCES_CPP_NAMESPACE_END
1.4 +17 -6 xml-xerces/c/src/xercesc/validators/common/DFAContentModel.hpp
Index: DFAContentModel.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/DFAContentModel.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DFAContentModel.hpp 7 Mar 2003 18:16:57 -0000 1.3
+++ DFAContentModel.hpp 15 May 2003 18:48:27 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.3 2003/03/07 18:16:57 tng
* Return a reference instead of void for operator=
*
@@ -157,12 +160,19 @@
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
- DFAContentModel(const bool dtd
- , ContentSpecNode* const elemContentSpec);
-
- DFAContentModel(const bool dtd
- , ContentSpecNode* const elemContentSpec
- , const bool isMixed);
+ DFAContentModel
+ (
+ const bool dtd
+ , ContentSpecNode* const elemContentSpec
+ , MemoryManager* const manager
+ );
+ DFAContentModel
+ (
+ const bool dtd
+ , ContentSpecNode* const elemContentSpec
+ , const bool isMixed
+ , MemoryManager* const manager
+ );
virtual ~DFAContentModel();
@@ -316,6 +326,7 @@
bool fDTD;
bool fIsMixed;
ContentLeafNameTypeVector *fLeafNameTypeVector;
+ MemoryManager* fMemoryManager;
};
1.5 +4 -1 xml-xerces/c/src/xercesc/validators/common/Grammar.hpp
Index: Grammar.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/Grammar.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Grammar.hpp 4 Nov 2002 14:54:58 -0000 1.4
+++ Grammar.hpp 15 May 2003 18:48:27 -0000 1.5
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.5 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.4 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -103,7 +106,7 @@
// This abstract class specifies the interface for a Grammar
//
-class VALIDATORS_EXPORT Grammar
+class VALIDATORS_EXPORT Grammar : public XMemory
{
public:
1.6 +9 -5 xml-xerces/c/src/xercesc/validators/common/GrammarResolver.cpp
Index: GrammarResolver.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/GrammarResolver.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- GrammarResolver.cpp 4 Nov 2002 14:54:58 -0000 1.5
+++ GrammarResolver.cpp 15 May 2003 18:48:27 -0000 1.6
@@ -57,6 +57,9 @@
/*
* $Log$
+ * Revision 1.6 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.5 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -99,14 +102,15 @@
// ---------------------------------------------------------------------------
// GrammarResolver: Constructor and Destructor
// ---------------------------------------------------------------------------
-GrammarResolver::GrammarResolver() :
+GrammarResolver::GrammarResolver(MemoryManager* const manager) :
fCacheGrammar(false)
, fUseCachedGrammar(false)
, fGrammarRegistry(0)
, fCachedGrammarRegistry(0)
, fDataTypeReg(0)
+ , fMemoryManager(manager)
{
- fGrammarRegistry = new RefHashTableOf<Grammar>(29, true);
+ fGrammarRegistry = new (manager) RefHashTableOf<Grammar>(29, true);
}
GrammarResolver::~GrammarResolver()
@@ -130,7 +134,7 @@
if (!fDataTypeReg) {
- fDataTypeReg = new DatatypeValidatorFactory();
+ fDataTypeReg = new (fMemoryManager) DatatypeValidatorFactory(fMemoryManager);
fDataTypeReg->expandRegistryToFullSchemaSet();
}
@@ -222,7 +226,7 @@
}
if (!fCachedGrammarRegistry)
- fCachedGrammarRegistry = new RefHashTableOf<Grammar>(29, true);
+ fCachedGrammarRegistry = new (fMemoryManager) RefHashTableOf<Grammar>(29, true);
// Cache
for (unsigned int i=0; i<keyCount; i++) {
@@ -240,7 +244,7 @@
void GrammarResolver::cacheGrammarFromParse(const bool aValue) {
if (aValue && !fCachedGrammarRegistry) {
- fCachedGrammarRegistry = new RefHashTableOf<Grammar>(29, true);
+ fCachedGrammarRegistry = new (fMemoryManager) RefHashTableOf<Grammar>(29, true);
}
fCacheGrammar = aValue;
1.5 +7 -3 xml-xerces/c/src/xercesc/validators/common/GrammarResolver.hpp
Index: GrammarResolver.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/GrammarResolver.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- GrammarResolver.hpp 6 Dec 2002 13:11:36 -0000 1.4
+++ GrammarResolver.hpp 15 May 2003 18:48:27 -0000 1.5
@@ -79,7 +79,8 @@
*
*/
-class VALIDATORS_EXPORT GrammarResolver {
+class VALIDATORS_EXPORT GrammarResolver : public XMemory
+{
public:
/** @name Constructor and Destructor */
@@ -88,7 +89,7 @@
*
* Default Constructor
*/
- GrammarResolver();
+ GrammarResolver(MemoryManager* const manager);
/**
* Destructor
@@ -208,6 +209,8 @@
//
// fDataTypeReg DatatypeValidatorFactory registery
//
+ // fMemoryManager Pluggable memory manager for dynamic memory
+ // allocation/deallocation
// -----------------------------------------------------------------------
bool fCacheGrammar;
bool fUseCachedGrammar;
@@ -215,6 +218,7 @@
RefHashTableOf<Grammar>* fGrammarRegistry;
RefHashTableOf<Grammar>* fCachedGrammarRegistry;
DatatypeValidatorFactory* fDataTypeReg;
+ MemoryManager* fMemoryManager;
};
inline XMLStringPool* GrammarResolver::getStringPool() {
1.4 +11 -5 xml-xerces/c/src/xercesc/validators/common/MixedContentModel.cpp
Index: MixedContentModel.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/MixedContentModel.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MixedContentModel.cpp 4 Nov 2002 14:54:58 -0000 1.3
+++ MixedContentModel.cpp 15 May 2003 18:48:27 -0000 1.4
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.4 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.3 2002/11/04 14:54:58 tng
* C++ Namespace Support.
*
@@ -154,6 +157,7 @@
, fChildTypes(0)
, fOrdered(ordered)
, fDTD(dtd)
+ , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
{
//
// Create a vector of unsigned ints that will be filled in with the
@@ -161,7 +165,6 @@
// it an initial capacity of 64 which should be more than enough for
// 99% of the scenarios.
//
-
ValueVectorOf<QName*> children(64);
ValueVectorOf<ContentSpecNode::NodeTypes> childTypes(64);
@@ -182,8 +185,11 @@
// fill them in.
//
fCount = children.size();
- fChildren = new QName*[fCount];
- fChildTypes = new ContentSpecNode::NodeTypes[fCount];
+ fChildren = (QName**) fMemoryManager->allocate(fCount * sizeof(QName*)); //new QName*[fCount];
+ fChildTypes = (ContentSpecNode::NodeTypes*) fMemoryManager->allocate
+ (
+ fCount * sizeof(ContentSpecNode::NodeTypes)
+ ); //new ContentSpecNode::NodeTypes[fCount];
for (unsigned int index = 0; index < fCount; index++) {
fChildren[index] = children.elementAt(index);
fChildTypes[index] = childTypes.elementAt(index);
@@ -192,8 +198,8 @@
MixedContentModel::~MixedContentModel()
{
- delete [] fChildren;
- delete [] fChildTypes;
+ fMemoryManager->deallocate(fChildren); //delete [] fChildren;
+ fMemoryManager->deallocate(fChildTypes); //delete [] fChildTypes;
}
1.5 +9 -6 xml-xerces/c/src/xercesc/validators/common/MixedContentModel.hpp
Index: MixedContentModel.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/MixedContentModel.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MixedContentModel.hpp 7 Mar 2003 18:16:57 -0000 1.4
+++ MixedContentModel.hpp 15 May 2003 18:48:27 -0000 1.5
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.5 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.4 2003/03/07 18:16:57 tng
* Return a reference instead of void for operator=
*
@@ -238,12 +241,12 @@
// Boolean to allow DTDs to validate even with namespace support.
//
// -----------------------------------------------------------------------
- unsigned int fCount;
- QName** fChildren;
- ContentSpecNode::NodeTypes* fChildTypes;
- bool fOrdered;
- bool fDTD;
-
+ unsigned int fCount;
+ QName** fChildren;
+ ContentSpecNode::NodeTypes* fChildTypes;
+ bool fOrdered;
+ bool fDTD;
+ MemoryManager* fMemoryManager;
};
inline ContentLeafNameTypeVector* MixedContentModel::getContentLeafNameTypeVector() const
1.5 +15 -11 xml-xerces/c/src/xercesc/validators/common/SimpleContentModel.hpp
Index: SimpleContentModel.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/common/SimpleContentModel.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SimpleContentModel.hpp 7 Mar 2003 18:16:57 -0000 1.4
+++ SimpleContentModel.hpp 15 May 2003 18:48:27 -0000 1.5
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.5 2003/05/15 18:48:27 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.4 2003/03/07 18:16:57 tng
* Return a reference instead of void for operator=
*
@@ -240,26 +243,27 @@
// ---------------------------------------------------------------------------
// SimpleContentModel: Constructors and Destructor
// ---------------------------------------------------------------------------
-inline
-SimpleContentModel::SimpleContentModel( const bool dtd
- , QName* const firstChild
- , QName* const secondChild
- , const ContentSpecNode::NodeTypes cmOp) :
-
- fFirstChild(0)
+inline SimpleContentModel::SimpleContentModel
+(
+ const bool dtd
+ , QName* const firstChild
+ , QName* const secondChild
+ , const ContentSpecNode::NodeTypes cmOp
+)
+ : fFirstChild(0)
, fSecondChild(0)
, fOp(cmOp)
, fDTD(dtd)
{
if (firstChild)
- fFirstChild = new QName(*firstChild);
+ fFirstChild = new (XMLPlatformUtils::fgMemoryManager) QName(*firstChild);
else
- fFirstChild = new QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId);
+ fFirstChild = new (XMLPlatformUtils::fgMemoryManager) QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId);
if (secondChild)
- fSecondChild = new QName(*secondChild);
+ fSecondChild = new (XMLPlatformUtils::fgMemoryManager) QName(*secondChild);
else
- fSecondChild = new QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId);
+ fSecondChild = new (XMLPlatformUtils::fgMemoryManager) QName(XMLUni::fgZeroLenString, XMLUni::fgZeroLenString, XMLElementDecl::fgInvalidElemId);
}
inline SimpleContentModel::~SimpleContentModel()
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org