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:25:55 UTC
cvs commit: xml-xerces/c/src/xercesc/dom/impl DOMAttrNSImpl.cpp DOMCharacterDataImpl.cpp DOMDeepNodeListPool.c DOMDeepNodeListPool.hpp DOMDocumentImpl.cpp DOMDocumentImpl.hpp DOMElementNSImpl.cpp DOMImplementationImpl.cpp DOMImplementationImpl.hpp DOMRangeImpl.cpp DOMWriterImpl.cpp DOMWriterImpl.hpp
knoaman 2003/05/15 11:25:55
Modified: c/src/xercesc/dom DOMImplementation.hpp
DOMImplementationLS.hpp
c/src/xercesc/dom/deprecated DOMParser.cpp DOMParser.hpp
DOMString.hpp DStringPool.hpp DocumentImpl.cpp
DocumentImpl.hpp ElementImpl.cpp
NamedNodeMapImpl.hpp NodeImpl.hpp
NodeIteratorImpl.hpp RefCountedImpl.hpp
TreeWalkerImpl.hpp
c/src/xercesc/dom/impl DOMAttrNSImpl.cpp
DOMCharacterDataImpl.cpp DOMDeepNodeListPool.c
DOMDeepNodeListPool.hpp DOMDocumentImpl.cpp
DOMDocumentImpl.hpp DOMElementNSImpl.cpp
DOMImplementationImpl.cpp DOMImplementationImpl.hpp
DOMRangeImpl.cpp DOMWriterImpl.cpp
DOMWriterImpl.hpp
Log:
Partial implementation of the configurable memory manager.
Revision Changes Path
1.12 +5 -3 xml-xerces/c/src/xercesc/dom/DOMImplementation.hpp
Index: DOMImplementation.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/DOMImplementation.hpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DOMImplementation.hpp 7 Mar 2003 19:59:05 -0000 1.11
+++ DOMImplementation.hpp 15 May 2003 18:25:53 -0000 1.12
@@ -64,6 +64,7 @@
#include <xercesc/dom/DOMImplementationLS.hpp>
#include <xercesc/dom/DOMException.hpp>
#include <xercesc/dom/DOMRangeException.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -208,7 +209,8 @@
virtual DOMDocument *createDocument(const XMLCh *namespaceURI,
const XMLCh *qualifiedName,
- DOMDocumentType *doctype) = 0;
+ DOMDocumentType *doctype,
+ MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0;
//@}
// -----------------------------------------------------------------------
@@ -248,7 +250,7 @@
*
* Create a completely empty document that has neither a root element or a doctype node.
*/
- virtual DOMDocument *createDocument() = 0;
+ virtual DOMDocument *createDocument(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0;
/**
* Non-standard extension
1.8 +8 -4 xml-xerces/c/src/xercesc/dom/DOMImplementationLS.hpp
Index: DOMImplementationLS.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/DOMImplementationLS.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DOMImplementationLS.hpp 7 Mar 2003 19:59:05 -0000 1.7
+++ DOMImplementationLS.hpp 15 May 2003 18:25:53 -0000 1.8
@@ -59,6 +59,9 @@
/*
* $Log$
+ * Revision 1.8 2003/05/15 18:25:53 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.7 2003/03/07 19:59:05 tng
* [Bug 11692] Unimplement the hidden constructors and assignment operator to remove warnings from gcc.
*
@@ -83,7 +86,7 @@
*/
-#include <xercesc/util/XercesDefs.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -91,7 +94,7 @@
class DOMBuilder;
class DOMWriter;
class DOMInputSource;
-
+class MemoryManager;
/**
* <p><code>DOMImplementationLS</code> contains the factory methods for
@@ -195,7 +198,8 @@
* @since DOM Level 3
*/
virtual DOMBuilder* createDOMBuilder(const short mode,
- const XMLCh* const schemaType) = 0;
+ const XMLCh* const schemaType,
+ MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0;
/**
@@ -209,7 +213,7 @@
* @see DOMWriter
* @since DOM Level 3
*/
- virtual DOMWriter* createDOMWriter() = 0;
+ virtual DOMWriter* createDOMWriter(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0;
/**
* Create a new "empty" DOMInputSource.
1.15 +14 -7 xml-xerces/c/src/xercesc/dom/deprecated/DOMParser.cpp
Index: DOMParser.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/DOMParser.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DOMParser.cpp 9 Jan 2003 19:07:44 -0000 1.14
+++ DOMParser.cpp 15 May 2003 18:25:53 -0000 1.15
@@ -99,7 +99,8 @@
// ---------------------------------------------------------------------------
// DOMParser: Constructors and Destructor
// ---------------------------------------------------------------------------
-DOMParser::DOMParser(XMLValidator* const valToAdopt) :
+DOMParser::DOMParser( XMLValidator* const valToAdopt
+ , MemoryManager* const manager) :
fToCreateXMLDeclTypeNode(false)
, fCreateEntityReferenceNodes(true)
@@ -114,6 +115,7 @@
, fGrammarResolver(0)
, fURIStringPool(0)
, fValidator(valToAdopt)
+ , fMemoryManager(manager)
{
try
{
@@ -138,18 +140,18 @@
void DOMParser::initialize()
{
// Create grammar resolver and URI string pool to pass to the scanner
- fGrammarResolver = new GrammarResolver();
- fURIStringPool = new XMLStringPool();
+ fGrammarResolver = new (fMemoryManager) GrammarResolver(fMemoryManager);
+ fURIStringPool = new (fMemoryManager) XMLStringPool();
// Create a scanner and tell it what validator to use. Then set us
// as the document event handler so we can fill the DOM document.
- fScanner = XMLScannerResolver::getDefaultScanner(fValidator);
+ fScanner = XMLScannerResolver::getDefaultScanner(fValidator, fMemoryManager);
fScanner->setDocHandler(this);
fScanner->setDocTypeHandler(this);
fScanner->setGrammarResolver(fGrammarResolver);
fScanner->setURIStringPool(fURIStringPool);
- fNodeStack = new ValueStackOf<DOM_Node>(64);
+ fNodeStack = new (fMemoryManager) ValueStackOf<DOM_Node>(64);
this->reset();
}
@@ -389,7 +391,12 @@
void DOMParser::useScanner(const XMLCh* const scannerName)
{
- XMLScanner* tempScanner = XMLScannerResolver::resolveScanner(scannerName, fValidator);
+ XMLScanner* tempScanner = XMLScannerResolver::resolveScanner
+ (
+ scannerName
+ , fValidator
+ , fMemoryManager
+ );
if (tempScanner) {
1.17 +7 -2 xml-xerces/c/src/xercesc/dom/deprecated/DOMParser.hpp
Index: DOMParser.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/DOMParser.hpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- DOMParser.hpp 9 Jan 2003 19:07:44 -0000 1.16
+++ DOMParser.hpp 15 May 2003 18:25:53 -0000 1.17
@@ -127,7 +127,11 @@
* @param valToAdopt Pointer to the validator instance to use. The
* parser is responsible for freeing the memory.
*/
- DOMParser(XMLValidator* const valToAdopt = 0);
+ DOMParser
+ (
+ XMLValidator* const valToAdopt = 0
+ , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
+ );
/**
* Destructor
@@ -1749,6 +1753,7 @@
GrammarResolver* fGrammarResolver;
XMLStringPool* fURIStringPool;
XMLValidator* fValidator;
+ MemoryManager* fMemoryManager;
};
1.4 +3 -3 xml-xerces/c/src/xercesc/dom/deprecated/DOMString.hpp
Index: DOMString.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/DOMString.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DOMString.hpp 4 Nov 2002 15:04:44 -0000 1.3
+++ DOMString.hpp 15 May 2003 18:25:53 -0000 1.4
@@ -61,7 +61,7 @@
#ifndef DOMString_HEADER_GUARD_
#define DOMString_HEADER_GUARD_
-#include <xercesc/util/XercesDefs.hpp>
+#include <xercesc/util/XMemory.hpp>
#ifdef XML_DEBUG
#include "DOMStringImpl.hpp"
@@ -81,7 +81,7 @@
* strings, it is not meant to be a comphrehensive string class.
*/
-class CDOM_EXPORT DOMString {
+class CDOM_EXPORT DOMString : public XMemory{
public:
/** @name Constructors and assignment operator */
//@{
1.5 +1 -2 xml-xerces/c/src/xercesc/dom/deprecated/DStringPool.hpp
Index: DStringPool.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/DStringPool.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DStringPool.hpp 7 Mar 2003 18:06:55 -0000 1.4
+++ DStringPool.hpp 15 May 2003 18:25:53 -0000 1.5
@@ -71,7 +71,6 @@
#ifndef DStringPool_HEADER_GUARD_
#define DStringPool_HEADER_GUARD_
-#include <xercesc/util/XercesDefs.hpp>
#include "DOMString.hpp"
#include <xercesc/util/XMLRegisterCleanup.hpp>
@@ -88,7 +87,7 @@
// if the name has been seen before, the already existing string
// will be reused.
//
-class DStringPool
+class DStringPool : public XMemory
{
public:
DStringPool(int hashTableSize);
1.6 +48 -46 xml-xerces/c/src/xercesc/dom/deprecated/DocumentImpl.cpp
Index: DocumentImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/DocumentImpl.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DocumentImpl.cpp 20 Dec 2002 22:10:57 -0000 1.5
+++ DocumentImpl.cpp 15 May 2003 18:25:53 -0000 1.6
@@ -100,17 +100,19 @@
DocumentImpl::DocumentImpl()
: ParentNode(this)
+ , docType(0)
+ , docElement(0)
+ , namePool(0)
+ , fNodeIDMap(0)
+ , iterators(0)
+ , treeWalkers(0)
+ , userData(0)
+ , ranges(0)
+ , fChanges(0)
+ , errorChecking(true)
+ , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
{
- docType = null;
- docElement = null;
- namePool = new DStringPool(257);
- iterators = 0L;
- treeWalkers = 0L;
- fNodeIDMap = 0;
- userData = 0;
- ranges = 0;
- fChanges = 0;
- errorChecking = true;
+ namePool = new (fMemoryManager) DStringPool(257);
};
@@ -119,20 +121,20 @@
const DOMString &qualifiedName,
DocumentTypeImpl *doctype)
: ParentNode(this)
+ , docType(0)
+ , docElement(0)
+ , namePool(0)
+ , fNodeIDMap(0)
+ , iterators(0)
+ , treeWalkers(0)
+ , userData(0)
+ , ranges(0)
+ , fChanges(0)
+ , errorChecking(true)
+ , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
{
- docType=null;
-
setDocumentType(doctype);
-
- docElement=null;
- namePool = new DStringPool(257);
- iterators = 0;
- treeWalkers = 0;
- fNodeIDMap = 0;
- userData = 0;
- ranges = 0;
- fChanges = 0;
- errorChecking = true;
+ namePool = new (fMemoryManager) DStringPool(257);
appendChild(createElementNS(fNamespaceURI, qualifiedName)); //root element
}
@@ -238,27 +240,27 @@
if (errorChecking && !isXMLName(nam)) {
throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR,null);
}
- return new AttrImpl(this,nam);
+ return new (fMemoryManager) AttrImpl(this,nam);
};
CDATASectionImpl *DocumentImpl::createCDATASection(const DOMString &data) {
- return new CDATASectionImpl(this,data);
+ return new (fMemoryManager) CDATASectionImpl(this,data);
};
CommentImpl *DocumentImpl::createComment(const DOMString &data)
{
- return new CommentImpl(this,data);
+ return new (fMemoryManager) CommentImpl(this,data);
};
DocumentFragmentImpl *DocumentImpl::createDocumentFragment()
{
- return new DocumentFragmentImpl(this);
+ return new (fMemoryManager) DocumentFragmentImpl(this);
};
@@ -268,7 +270,7 @@
if (errorChecking && !isXMLName(nam)) {
throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR, null);
}
- return new DocumentTypeImpl(this, nam);
+ return new (fMemoryManager) DocumentTypeImpl(this, nam);
};
@@ -281,7 +283,7 @@
if (errorChecking && !isXMLName(qualifiedName)) {
throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR, null);
}
- return new DocumentTypeImpl(this, qualifiedName, publicId, systemId);
+ return new (fMemoryManager) DocumentTypeImpl(this, qualifiedName, publicId, systemId);
};
@@ -292,14 +294,14 @@
throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR,null);
}
DOMString pooledTagName = this->namePool->getPooledString(tagName);
- return new ElementImpl(this,pooledTagName);
+ return new (fMemoryManager) ElementImpl(this,pooledTagName);
};
ElementImpl *DocumentImpl::createElement(const XMLCh *tagName)
{
DOMString pooledTagName = this->namePool->getPooledString(tagName);
- return new ElementImpl(this,pooledTagName);
+ return new (fMemoryManager) ElementImpl(this,pooledTagName);
};
@@ -310,7 +312,7 @@
if (errorChecking && !isXMLName(nam)) {
throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR, null);
}
- return new EntityImpl(this, nam);
+ return new (fMemoryManager) EntityImpl(this, nam);
};
@@ -320,7 +322,7 @@
if (errorChecking && !isXMLName(nam)) {
throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR, null);
}
- return new EntityReferenceImpl(this, nam);
+ return new (fMemoryManager) EntityReferenceImpl(this, nam);
};
@@ -330,7 +332,7 @@
if (errorChecking && !isXMLName(nam)) {
throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR, null);
}
- return new NotationImpl(this, nam);
+ return new (fMemoryManager) NotationImpl(this, nam);
};
@@ -341,7 +343,7 @@
if (errorChecking && !isXMLName(target)) {
throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR,null);
}
- return new ProcessingInstructionImpl(this,target,data);
+ return new (fMemoryManager) ProcessingInstructionImpl(this,target,data);
};
@@ -349,7 +351,7 @@
TextImpl *DocumentImpl::createTextNode(const DOMString &data)
{
- return new TextImpl(this,data);
+ return new (fMemoryManager) TextImpl(this,data);
};
@@ -360,7 +362,7 @@
// The vector of iterators is kept in the "owner document" if there is one. If there isn't one, I assume that root is the
// owner document.
- NodeIteratorImpl* iter = new NodeIteratorImpl(root, whatToShow, filter, entityReferenceExpansion);
+ NodeIteratorImpl* iter = new (XMLPlatformUtils::fgMemoryManager) NodeIteratorImpl(root, whatToShow, filter, entityReferenceExpansion);
DOM_Document doc = root.getOwnerDocument();
DocumentImpl* impl;
@@ -371,7 +373,7 @@
impl = (DocumentImpl *) root.fImpl;
if (impl->iterators == 0L) {
- impl->iterators = new NodeIterators(1, false);
+ impl->iterators = new (XMLPlatformUtils::fgMemoryManager) NodeIterators(1, false);
impl->iterators->addElement(iter);
}
@@ -383,7 +385,7 @@
{
// See notes for createNodeIterator...
- TreeWalkerImpl* twi = new TreeWalkerImpl(root, whatToShow, filter, entityReferenceExpansion);
+ TreeWalkerImpl* twi = new (XMLPlatformUtils::fgMemoryManager) TreeWalkerImpl(root, whatToShow, filter, entityReferenceExpansion);
DOM_Document doc = root.getOwnerDocument();
DocumentImpl* impl;
@@ -394,7 +396,7 @@
impl = (DocumentImpl *) root.fImpl;
if (impl->treeWalkers == 0L) {
- impl->treeWalkers = new TreeWalkers(1, false);
+ impl->treeWalkers = new (XMLPlatformUtils::fgMemoryManager) TreeWalkers(1, false);
impl->treeWalkers->addElement(twi);
}
@@ -669,7 +671,7 @@
throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR,null);
}
//DOMString pooledTagName = this->namePool->getPooledString(qualifiedName);
- return new ElementNSImpl(this, fNamespaceURI, qualifiedName);
+ return new (fMemoryManager) ElementNSImpl(this, fNamespaceURI, qualifiedName);
}
@@ -679,7 +681,7 @@
if (!isXMLName(qualifiedName)) {
throw DOM_DOMException(DOM_DOMException::INVALID_CHARACTER_ERR,null);
}
- return new AttrNSImpl(this, fNamespaceURI, qualifiedName);
+ return new (fMemoryManager) AttrNSImpl(this, fNamespaceURI, qualifiedName);
}
@@ -724,16 +726,16 @@
XMLDeclImpl* DocumentImpl::createXMLDecl(const DOMString& version, const DOMString& encoding, const DOMString& standalone)
{
- return new XMLDeclImpl(this, version, encoding, standalone);
+ return new (fMemoryManager) XMLDeclImpl(this, version, encoding, standalone);
}
RangeImpl* DocumentImpl::createRange()
{
- RangeImpl* range = new RangeImpl(DOM_Document(this));
+ RangeImpl* range = new (fMemoryManager) RangeImpl(DOM_Document(this));
if (ranges == 0L) {
- ranges = new RangeImpls(1, false);
+ ranges = new (fMemoryManager) RangeImpls(1, false);
}
ranges->addElement(range);
return range;
@@ -810,7 +812,7 @@
void DocumentImpl::setUserData(NodeImpl* n, void* data)
{
if (!userData && data)
- userData = new RefHashTableOf<void>(29, false, new HashPtr());
+ userData = new (fMemoryManager) RefHashTableOf<void>(29, false, new (fMemoryManager) HashPtr());
if (!data && userData)
userData->removeKey((void*)n);
else
1.5 +7 -1 xml-xerces/c/src/xercesc/dom/deprecated/DocumentImpl.hpp
Index: DocumentImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/DocumentImpl.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DocumentImpl.hpp 20 Dec 2002 22:10:57 -0000 1.4
+++ DocumentImpl.hpp 15 May 2003 18:25:53 -0000 1.5
@@ -166,6 +166,8 @@
/** Bypass error checking. */
bool errorChecking;
+ MemoryManager *fMemoryManager;
+
friend class NodeIteratorImpl;
friend class TreeWalkerImpl;
friend class RangeImpl;
@@ -266,6 +268,10 @@
*/
inline bool getErrorChecking() {
return errorChecking;
+ }
+
+ inline MemoryManager* getMemoryManager() const {
+ return fMemoryManager;
}
// -----------------------------------------------------------------------
1.4 +42 -14 xml-xerces/c/src/xercesc/dom/deprecated/ElementImpl.cpp
Index: ElementImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/ElementImpl.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ElementImpl.cpp 4 Nov 2002 15:04:44 -0000 1.3
+++ ElementImpl.cpp 15 May 2003 18:25:53 -0000 1.4
@@ -241,8 +241,12 @@
AttrImpl* newAttr = (AttrImpl*)getAttributeNode(nam);
if (!newAttr)
{
- if (attributes == 0)
- attributes = new AttrMapImpl(this, null);
+ if (attributes == 0) {
+ if (getOwnerDocument())
+ attributes = new (getOwnerDocument()->getMemoryManager()) AttrMapImpl(this, null);
+ else
+ attributes = new AttrMapImpl(this, null);
+ }
newAttr = (AttrImpl*)ownerDocument->createAttribute(nam);
attributes->setNamedItem(newAttr);
}
@@ -263,8 +267,12 @@
}
if (!(newAttr->isAttrImpl()))
throw DOM_DOMException(DOM_DOMException::WRONG_DOCUMENT_ERR, null);
- if (attributes == 0)
- attributes = new AttrMapImpl(this, null);
+ if (attributes == 0) {
+ if (getOwnerDocument())
+ attributes = new (getOwnerDocument()->getMemoryManager()) AttrMapImpl(this, null);
+ else
+ attributes = new AttrMapImpl(this, null);
+ }
AttrImpl *oldAttr =
(AttrImpl *) attributes->getNamedItem(newAttr->getName());
// This will throw INUSE if necessary
@@ -313,8 +321,12 @@
(AttrImpl *) ownerDocument->createAttributeNS(fNamespaceURI,
qualifiedName);
newAttr->setNodeValue(fValue);
- if (attributes == 0)
- attributes = new AttrMapImpl(this, null);
+ if (attributes == 0) {
+ if (getOwnerDocument())
+ attributes = new (getOwnerDocument()->getMemoryManager()) AttrMapImpl(this, null);
+ else
+ attributes = new AttrMapImpl(this, null);
+ }
AttrImpl *oldAttr = (AttrImpl *)attributes->setNamedItem(newAttr);
if (oldAttr) {
@@ -366,7 +378,10 @@
}
}
if (attributes == 0) {
- attributes = new AttrMapImpl(this, null);
+ if (getOwnerDocument())
+ attributes = new (getOwnerDocument()->getMemoryManager()) AttrMapImpl(this, null);
+ else
+ attributes = new AttrMapImpl(this, null);
}
AttrImpl *oldAttr = (AttrImpl *) attributes->getNamedItemNS(newAttr->getNamespaceURI(), newAttr->getLocalName());
@@ -452,8 +467,12 @@
NodeImpl *ElementImpl::NNM_setNamedItem(NodeImpl *nnm_arg)
{
- if (getAttributes() == null)
- attributes = new AttrMapImpl(this);
+ if (getAttributes() == null) {
+ if (getOwnerDocument())
+ attributes = new (getOwnerDocument()->getMemoryManager()) AttrMapImpl(this);
+ else
+ attributes = new AttrMapImpl(this);
+ }
return attributes->setNamedItem(nnm_arg);
}
@@ -475,8 +494,12 @@
NodeImpl *ElementImpl::NNM_setNamedItemNS(NodeImpl *nnm_arg)
{
- if (getAttributes() == null)
- attributes = new AttrMapImpl(this);
+ if (getAttributes() == null) {
+ if (getOwnerDocument())
+ attributes = new (getOwnerDocument()->getMemoryManager()) AttrMapImpl(this);
+ else
+ attributes = new AttrMapImpl(this);
+ }
return getAttributes()->setNamedItemNS(nnm_arg);
}
@@ -521,8 +544,13 @@
delete attributes;
AttrMapImpl* defAttrs = getDefaultAttributes();
- if (defAttrs)
- attributes = new AttrMapImpl(this, defAttrs);
+ if (defAttrs) {
+
+ if (getOwnerDocument())
+ attributes = new (getOwnerDocument()->getMemoryManager()) AttrMapImpl(this, defAttrs);
+ else
+ attributes = new AttrMapImpl(this, defAttrs);
+ }
}
// -----------------------------------------------------------------------
1.4 +3 -3 xml-xerces/c/src/xercesc/dom/deprecated/NamedNodeMapImpl.hpp
Index: NamedNodeMapImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/NamedNodeMapImpl.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NamedNodeMapImpl.hpp 4 Nov 2002 15:04:44 -0000 1.3
+++ NamedNodeMapImpl.hpp 15 May 2003 18:25:53 -0000 1.4
@@ -70,7 +70,7 @@
// name is substituded for the *.
//
-#include <xercesc/util/XercesDefs.hpp>
+#include <xercesc/util/XMemory.hpp>
#include "NodeImpl.hpp"
XERCES_CPP_NAMESPACE_BEGIN
@@ -80,7 +80,7 @@
class DocumentImpl;
class NodeImpl;
-class CDOM_EXPORT NamedNodeMapImpl {
+class CDOM_EXPORT NamedNodeMapImpl: public XMemory {
protected:
NodeVector *nodes;
NodeImpl *ownerNode; // the node this map belongs to
1.4 +2 -2 xml-xerces/c/src/xercesc/dom/deprecated/NodeImpl.hpp
Index: NodeImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/NodeImpl.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NodeImpl.hpp 4 Nov 2002 15:04:44 -0000 1.3
+++ NodeImpl.hpp 15 May 2003 18:25:53 -0000 1.4
@@ -88,7 +88,7 @@
* ownerDocument.
**/
-#include <xercesc/util/XercesDefs.hpp>
+#include <xercesc/util/XMemory.hpp>
#include "NodeListImpl.hpp"
#include "DOMString.hpp"
1.4 +2 -2 xml-xerces/c/src/xercesc/dom/deprecated/NodeIteratorImpl.hpp
Index: NodeIteratorImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/NodeIteratorImpl.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- NodeIteratorImpl.hpp 4 Nov 2002 15:04:44 -0000 1.3
+++ NodeIteratorImpl.hpp 15 May 2003 18:25:53 -0000 1.4
@@ -70,7 +70,7 @@
// name is substituded for the *.
//
-
+#include <xercesc/util/XMemory.hpp>
#include "DOM_Node.hpp"
#include "DOM_NodeIterator.hpp"
#include "RefCountedImpl.hpp"
1.4 +3 -3 xml-xerces/c/src/xercesc/dom/deprecated/RefCountedImpl.hpp
Index: RefCountedImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/RefCountedImpl.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RefCountedImpl.hpp 4 Nov 2002 15:04:44 -0000 1.3
+++ RefCountedImpl.hpp 15 May 2003 18:25:53 -0000 1.4
@@ -71,12 +71,12 @@
-#include <xercesc/util/XercesDefs.hpp>
+#include <xercesc/util/XMemory.hpp>
XERCES_CPP_NAMESPACE_BEGIN
-class CDOM_EXPORT RefCountedImpl
+class CDOM_EXPORT RefCountedImpl : public XMemory
{
public:
int nodeRefCount;
1.4 +2 -2 xml-xerces/c/src/xercesc/dom/deprecated/TreeWalkerImpl.hpp
Index: TreeWalkerImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/deprecated/TreeWalkerImpl.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TreeWalkerImpl.hpp 4 Nov 2002 15:04:44 -0000 1.3
+++ TreeWalkerImpl.hpp 15 May 2003 18:25:53 -0000 1.4
@@ -70,7 +70,7 @@
#ifndef TreeWalkerImpl_HEADER_GUARD_
#define TreeWalkerImpl_HEADER_GUARD_
-
+#include <xercesc/util/XMemory.hpp>
#include "DOM_TreeWalker.hpp"
#include "RefCountedImpl.hpp"
1.11 +11 -5 xml-xerces/c/src/xercesc/dom/impl/DOMAttrNSImpl.cpp
Index: DOMAttrNSImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMAttrNSImpl.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DOMAttrNSImpl.cpp 20 Dec 2002 22:10:58 -0000 1.10
+++ DOMAttrNSImpl.cpp 15 May 2003 18:25:54 -0000 1.11
@@ -155,7 +155,10 @@
XMLCh* newName;
XMLCh temp[4000];
if (newQualifiedNameLen >= 3999)
- newName = new XMLCh[newQualifiedNameLen];
+ newName = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ newQualifiedNameLen * sizeof(XMLCh)
+ );//new XMLCh[newQualifiedNameLen];
else
newName = temp;
@@ -168,7 +171,7 @@
getPooledString(newName);
if (newQualifiedNameLen >= 3999)
- delete[] newName;
+ XMLPlatformUtils::fgMemoryManager->deallocate(newName);//delete[] newName;
}
@@ -228,7 +231,10 @@
XMLCh* newName;
XMLCh temp[4000];
if (index >= 3999)
- newName = new XMLCh[XMLString::stringLen(qualifiedName)+1];
+ newName = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ (XMLString::stringLen(qualifiedName) + 1) * sizeof(XMLCh)
+ );//new XMLCh[XMLString::stringLen(qualifiedName)+1];
else
newName = temp;
@@ -238,7 +244,7 @@
this -> fLocalName = ownerDoc->getPooledString(fName+index+1);
if (index >= 3999)
- delete[] newName;
+ XMLPlatformUtils::fgMemoryManager->deallocate(newName);//delete[] newName;
// Before we carry on, we should check if the prefix or localName are valid XMLName
if (!((DOMDocumentImpl *)this->getOwnerDocument())->isXMLName(fPrefix) || !((DOMDocumentImpl *)this->getOwnerDocument())->isXMLName(fLocalName))
1.6 +16 -7 xml-xerces/c/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp
Index: DOMCharacterDataImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DOMCharacterDataImpl.cpp 16 Jan 2003 20:12:19 -0000 1.5
+++ DOMCharacterDataImpl.cpp 15 May 2003 18:25:54 -0000 1.6
@@ -171,7 +171,10 @@
XMLCh* newString;
XMLCh temp[4000];
if (newLen >= 3999)
- newString = new XMLCh[newLen+1];
+ newString = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ (newLen+1) * sizeof(XMLCh)
+ );//new XMLCh[newLen+1];
else
newString = temp;
@@ -181,7 +184,7 @@
fDataBuf->set(newString);
if (newLen >= 3999)
- delete[] newString;
+ XMLPlatformUtils::fgMemoryManager->deallocate(newString);//delete[] newString;
// We don't delete the old string (doesn't work), or alter
// the old string (may be shared)
@@ -239,7 +242,10 @@
XMLCh* newString;
XMLCh temp[4000];
if (newLen >= 3999)
- newString = new XMLCh[newLen+1];
+ newString = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ (newLen + 1) * sizeof(XMLCh)
+ );//new XMLCh[newLen+1];
else
newString = temp;
@@ -250,7 +256,7 @@
fDataBuf->set(newString);
if (newLen >= 3999)
- delete[] newString;
+ XMLPlatformUtils::fgMemoryManager->deallocate(newString);//delete[] newString;
if (node->getOwnerDocument() != 0) {
Ranges* ranges = ((DOMDocumentImpl *)node->getOwnerDocument())->getRanges();
@@ -308,7 +314,10 @@
XMLCh* newString;
XMLCh temp[4000];
if (len >= 3999)
- newString = new XMLCh[len+1];
+ newString = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ (len + 1) * sizeof(XMLCh)
+ );//new XMLCh[len+1];
else
newString = temp;
@@ -318,7 +327,7 @@
const XMLCh* retString = ((DOMDocumentImpl *)node->getOwnerDocument())->getPooledString(newString);
if (len >= 3999)
- delete[] newString;
+ XMLPlatformUtils::fgMemoryManager->deallocate(newString);//delete[] newString;
return retString;
1.6 +67 -37 xml-xerces/c/src/xercesc/dom/impl/DOMDeepNodeListPool.c
Index: DOMDeepNodeListPool.c
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMDeepNodeListPool.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DOMDeepNodeListPool.c 25 Apr 2003 15:29:05 -0000 1.5
+++ DOMDeepNodeListPool.c 15 May 2003 18:25:54 -0000 1.6
@@ -74,21 +74,23 @@
// ---------------------------------------------------------------------------
// DOMDeepNodeListPool: Constructors and Destructor
// ---------------------------------------------------------------------------
-template <class TVal> DOMDeepNodeListPool<TVal>::DOMDeepNodeListPool(
- const XMLSize_t modulus
- , const bool adoptElems
- , const XMLSize_t initSize) :
+template <class TVal>
+DOMDeepNodeListPool<TVal>::DOMDeepNodeListPool( const XMLSize_t modulus
+ , const bool adoptElems
+ , const XMLSize_t initSize) :
fAdoptedElems(adoptElems)
, fBucketList(0)
, fHashModulus(modulus)
+ , fHash(0)
, fIdPtrs(0)
, fIdPtrsCount(initSize)
, fIdCounter(0)
+ , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
{
initialize(modulus);
// create default hasher
- fHash = new HashPtr();
+ fHash = new (fMemoryManager) HashPtr();
//
// Allocate the initial id pointers array. We don't have to zero them
@@ -97,21 +99,24 @@
//
if (!fIdPtrsCount)
fIdPtrsCount = 256;
- fIdPtrs = new TVal*[fIdPtrsCount];
+
+ fIdPtrs = (TVal**) fMemoryManager->allocate(fIdPtrsCount * sizeof(TVal*));//new TVal*[fIdPtrsCount];
fIdPtrs[0] = 0;
}
-template <class TVal> DOMDeepNodeListPool<TVal>::DOMDeepNodeListPool(
- const XMLSize_t modulus
- , const bool adoptElems
- , HashBase* hash
- , const XMLSize_t initSize) :
+template <class TVal>
+DOMDeepNodeListPool<TVal>::DOMDeepNodeListPool( const XMLSize_t modulus
+ , const bool adoptElems
+ , HashBase* hash
+ , const XMLSize_t initSize) :
fAdoptedElems(adoptElems)
, fBucketList(0)
, fHashModulus(modulus)
+ , fHash(0)
, fIdPtrs(0)
, fIdPtrsCount(initSize)
, fIdCounter(0)
+ , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
{
initialize(modulus);
// set hasher
@@ -124,23 +129,27 @@
//
if (!fIdPtrsCount)
fIdPtrsCount = 256;
- fIdPtrs = new TVal*[fIdPtrsCount];
+
+ fIdPtrs = (TVal**) fMemoryManager->allocate(fIdPtrsCount * sizeof(TVal*));//new TVal*[fIdPtrsCount];
fIdPtrs[0] = 0;
}
-template <class TVal> DOMDeepNodeListPool<TVal>::DOMDeepNodeListPool(const XMLSize_t modulus
- , const XMLSize_t initSize) :
+template <class TVal>
+DOMDeepNodeListPool<TVal>::DOMDeepNodeListPool( const XMLSize_t modulus
+ , const XMLSize_t initSize) :
fAdoptedElems(true)
, fBucketList(0)
, fHashModulus(modulus)
+ , fHash(0)
, fIdPtrs(0)
, fIdPtrsCount(initSize)
, fIdCounter(0)
+ , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
{
initialize(modulus);
// create default hasher
- fHash = new HashPtr();
+ fHash = new (fMemoryManager) HashPtr();
//
// Allocate the initial id pointers array. We don't have to zero them
@@ -149,17 +158,23 @@
//
if (!fIdPtrsCount)
fIdPtrsCount = 256;
- fIdPtrs = new TVal*[fIdPtrsCount];
+
+ fIdPtrs = (TVal**) fMemoryManager->allocate(fIdPtrsCount * sizeof(TVal*));//new TVal*[fIdPtrsCount];
fIdPtrs[0] = 0;
}
-template <class TVal> void DOMDeepNodeListPool<TVal>::initialize(const XMLSize_t modulus)
+template <class TVal>
+void DOMDeepNodeListPool<TVal>::initialize(const XMLSize_t modulus)
{
if (modulus == 0)
ThrowXML(IllegalArgumentException, XMLExcepts::HshTbl_ZeroModulus);
// Allocate the bucket list and zero them
- fBucketList = new DOMDeepNodeListPoolTableBucketElem<TVal>*[fHashModulus];
+ fBucketList = (DOMDeepNodeListPoolTableBucketElem<TVal>**)
+ fMemoryManager->allocate
+ (
+ fHashModulus * sizeof(DOMDeepNodeListPoolTableBucketElem<TVal>*)
+ );//new DOMDeepNodeListPoolTableBucketElem<TVal>*[fHashModulus];
for (XMLSize_t index = 0; index < fHashModulus; index++)
fBucketList[index] = 0;
}
@@ -169,8 +184,8 @@
removeAll();
// Then delete the bucket list & hasher & id pointers list
- delete [] fIdPtrs;
- delete [] fBucketList;
+ fMemoryManager->deallocate(fIdPtrs);//delete [] fIdPtrs;
+ fMemoryManager->deallocate(fBucketList);//delete [] fBucketList;
delete fHash;
}
@@ -178,7 +193,8 @@
// ---------------------------------------------------------------------------
// DOMDeepNodeListPool: Element management
// ---------------------------------------------------------------------------
-template <class TVal> bool DOMDeepNodeListPool<TVal>::isEmpty() const
+template <class TVal>
+bool DOMDeepNodeListPool<TVal>::isEmpty() const
{
// Just check the bucket list for non-empty elements
for (XMLSize_t buckInd = 0; buckInd < fHashModulus; buckInd++)
@@ -189,15 +205,18 @@
return true;
}
-template <class TVal> bool DOMDeepNodeListPool<TVal>::
-containsKey(const void* const key1, const XMLCh* const key2, const XMLCh* const key3) const
+template <class TVal>
+bool DOMDeepNodeListPool<TVal>::containsKey( const void* const key1
+ , const XMLCh* const key2
+ , const XMLCh* const key3) const
{
XMLSize_t hashVal;
const DOMDeepNodeListPoolTableBucketElem<TVal>* findIt = findBucketElem(key1, key2, key3, hashVal);
return (findIt != 0);
}
-template <class TVal> void DOMDeepNodeListPool<TVal>::removeAll()
+template <class TVal>
+void DOMDeepNodeListPool<TVal>::removeAll()
{
// Clean up the buckets first
for (XMLSize_t buckInd = 0; buckInd < fHashModulus; buckInd++)
@@ -218,8 +237,8 @@
delete curElem->fData;
// Then delete the current element and move forward
- delete [] curElem->fKey2;
- delete [] curElem->fKey3;
+ fMemoryManager->deallocate(curElem->fKey2);//delete [] curElem->fKey2;
+ fMemoryManager->deallocate(curElem->fKey3);//delete [] curElem->fKey3;
delete curElem;
curElem = nextElem;
@@ -238,8 +257,8 @@
removeAll();
// Then delete the bucket list & hasher & id pointers list
- delete [] fIdPtrs;
- delete [] fBucketList;
+ fMemoryManager->deallocate(fIdPtrs);//delete [] fIdPtrs;
+ fMemoryManager->deallocate(fBucketList);//delete [] fBucketList;
delete fHash;
}
@@ -307,17 +326,25 @@
if (fAdoptedElems)
delete newBucket->fData;
- delete[] newBucket->fKey2;
- delete[] newBucket->fKey3;
+ fMemoryManager->deallocate(newBucket->fKey2);//delete[] newBucket->fKey2;
+ fMemoryManager->deallocate(newBucket->fKey3);//delete[] newBucket->fKey3;
newBucket->fData = valueToAdopt;
newBucket->fKey1 = key1;
- newBucket->fKey2 = XMLString::replicate(key2);
- newBucket->fKey3 = XMLString::replicate(key3);
+ newBucket->fKey2 = XMLString::replicate(key2, fMemoryManager);
+ newBucket->fKey3 = XMLString::replicate(key3, fMemoryManager);
}
- else
+ else
{
- newBucket = new DOMDeepNodeListPoolTableBucketElem<TVal>(key1, key2, key3, valueToAdopt, fBucketList[hashVal]);
+ newBucket = new (fMemoryManager) DOMDeepNodeListPoolTableBucketElem<TVal>
+ (
+ key1
+ , key2
+ , key3
+ , valueToAdopt
+ , fBucketList[hashVal]
+ , fMemoryManager
+ );
fBucketList[hashVal] = newBucket;
}
@@ -329,13 +356,16 @@
{
// Create a new count 1.5 times larger and allocate a new array
XMLSize_t newCount = (XMLSize_t)(fIdPtrsCount * 1.5);
- TVal** newArray = new TVal*[newCount];
+ TVal** newArray = (TVal**) fMemoryManager->allocate
+ (
+ newCount * sizeof(TVal*)
+ );//new TVal*[newCount];
// Copy over the old contents to the new array
memcpy(newArray, fIdPtrs, fIdPtrsCount * sizeof(TVal*));
// Ok, toss the old array and store the new data
- delete [] fIdPtrs;
+ fMemoryManager->deallocate(fIdPtrs); //delete [] fIdPtrs;
fIdPtrs = newArray;
fIdPtrsCount = newCount;
}
1.5 +29 -25 xml-xerces/c/src/xercesc/dom/impl/DOMDeepNodeListPool.hpp
Index: DOMDeepNodeListPool.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMDeepNodeListPool.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DOMDeepNodeListPool.hpp 4 Nov 2002 15:07:34 -0000 1.4
+++ DOMDeepNodeListPool.hpp 15 May 2003 18:25:54 -0000 1.5
@@ -71,7 +71,6 @@
#define DOMDeepNODELISTPOOL_HPP
-#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/HashBase.hpp>
#include <xercesc/util/IllegalArgumentException.hpp>
#include <xercesc/util/NoSuchElementException.hpp>
@@ -79,7 +78,6 @@
#include <xercesc/util/XMLExceptMsgs.hpp>
#include <xercesc/util/XMLEnumerator.hpp>
#include <xercesc/util/XMLString.hpp>
-#include <xercesc/util/HashBase.hpp>
#include <xercesc/util/HashXMLCh.hpp>
#include <xercesc/util/HashPtr.hpp>
@@ -96,32 +94,36 @@
// This should really be a nested class, but some of the compilers we
// have to support cannot deal with that!
//
-template <class TVal> struct DOMDeepNodeListPoolTableBucketElem
+template <class TVal>
+struct DOMDeepNodeListPoolTableBucketElem : public XMemory
{
- DOMDeepNodeListPoolTableBucketElem(
- void* key1
- , XMLCh* key2
- , XMLCh* key3
- , TVal* const value
- , DOMDeepNodeListPoolTableBucketElem<TVal>* next) :
- fData(value)
+ DOMDeepNodeListPoolTableBucketElem
+ (
+ void* key1
+ , XMLCh* key2
+ , XMLCh* key3
+ , TVal* const value
+ , DOMDeepNodeListPoolTableBucketElem<TVal>* next
+ , MemoryManager* const manager
+ ) :
+ fData(value)
, fNext(next)
, fKey1(key1)
, fKey2(0)
, fKey3(0)
{
if (key2)
- fKey2 = XMLString::replicate(key2);
+ fKey2 = XMLString::replicate(key2, manager);
if (key3)
- fKey3 = XMLString::replicate(key3);
+ fKey3 = XMLString::replicate(key3, manager);
}
- TVal* fData;
- DOMDeepNodeListPoolTableBucketElem<TVal>* fNext;
- void* fKey1;
- XMLCh* fKey2;
- XMLCh* fKey3;
+ TVal* fData;
+ DOMDeepNodeListPoolTableBucketElem<TVal>* fNext;
+ void* fKey1;
+ XMLCh* fKey2;
+ XMLCh* fKey3;
};
@@ -152,7 +154,8 @@
DOMDeepNodeListPool
(
const XMLSize_t modulus
- , const bool adoptElems, HashBase* hash
+ , const bool adoptElems
+ , HashBase* hash
, const XMLSize_t initSize = 128
);
@@ -224,13 +227,14 @@
// element. So the first element is 1, the next is 2, etc... This
// means that this value is set to the top index of the fIdPtrs array.
// -----------------------------------------------------------------------
- bool fAdoptedElems;
+ bool fAdoptedElems;
DOMDeepNodeListPoolTableBucketElem<TVal>** fBucketList;
- XMLSize_t fHashModulus;
- HashBase* fHash;
- TVal** fIdPtrs;
- XMLSize_t fIdPtrsCount;
- XMLSize_t fIdCounter;
+ XMLSize_t fHashModulus;
+ HashBase* fHash;
+ TVal** fIdPtrs;
+ XMLSize_t fIdPtrsCount;
+ XMLSize_t fIdCounter;
+ MemoryManager* fMemoryManager;
};
XERCES_CPP_NAMESPACE_END
1.36 +28 -32 xml-xerces/c/src/xercesc/dom/impl/DOMDocumentImpl.cpp
Index: DOMDocumentImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMDocumentImpl.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- DOMDocumentImpl.cpp 14 May 2003 19:23:20 -0000 1.35
+++ DOMDocumentImpl.cpp 15 May 2003 18:25:54 -0000 1.36
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -57,17 +57,6 @@
/*
* $Id$
*/
-
-#include <xercesc/util/XMLUniDefs.hpp>
-
-#include <xercesc/dom/DOMDocument.hpp>
-#include <xercesc/dom/DOMConfiguration.hpp>
-#include <xercesc/dom/DOMDocumentType.hpp>
-#include <xercesc/dom/DOMException.hpp>
-#include <xercesc/dom/DOMImplementation.hpp>
-#include <xercesc/dom/DOMNamedNodeMap.hpp>
-#include <xercesc/dom/DOMNode.hpp>
-
#include "DOMDocumentImpl.hpp"
#include "DOMCasts.hpp"
#include "DOMConfigurationImpl.hpp"
@@ -87,15 +76,16 @@
#include "DOMNotationImpl.hpp"
#include "DOMProcessingInstructionImpl.hpp"
#include "DOMTextImpl.hpp"
-
#include "DOMStringPool.hpp"
#include "DOMTreeWalkerImpl.hpp"
#include "DOMNodeIteratorImpl.hpp"
#include "DOMNodeIDMap.hpp"
#include "DOMRangeImpl.hpp"
-#include <xercesc/internal/XMLReader.hpp>
-#include <xercesc/util/HashPtr.hpp>
+#include <xercesc/dom/DOMImplementation.hpp>
+#include <xercesc/util/XMLChar.hpp>
+#include <xercesc/framework/MemoryManager.hpp>
+
XERCES_CPP_NAMESPACE_BEGIN
@@ -110,7 +100,7 @@
// fNode and fParent constructors used here can not
// allocate.
//
-DOMDocumentImpl::DOMDocumentImpl()
+DOMDocumentImpl::DOMDocumentImpl(MemoryManager* const manager)
: fNode(this),
fParent(this),
fCurrentBlock(0),
@@ -134,6 +124,7 @@
fUserDataTable(0),
fRecycleNodePtr(0),
fRecycleBufferPtr(0),
+ fMemoryManager(manager),
errorChecking(true)
{
fNamePool = new (this) DOMStringPool(257, this);
@@ -143,7 +134,8 @@
//DOM Level 2
DOMDocumentImpl::DOMDocumentImpl(const XMLCh *fNamespaceURI,
const XMLCh *qualifiedName,
- DOMDocumentType *doctype)
+ DOMDocumentType *doctype,
+ MemoryManager* const manager)
: fNode(this),
fParent(this),
fCurrentBlock(0),
@@ -167,6 +159,7 @@
fUserDataTable(0),
fRecycleNodePtr(0),
fRecycleBufferPtr(0),
+ fMemoryManager(manager),
errorChecking(true)
{
fNamePool = new (this) DOMStringPool(257, this);
@@ -214,13 +207,13 @@
fNodeListPool->cleanup();
if (fRanges)
- fRanges->cleanup();
+ delete fRanges; //fRanges->cleanup();
if (fNodeIterators)
- fNodeIterators->cleanup();
+ delete fNodeIterators;//fNodeIterators->cleanup();
if (fUserDataTable)
- fUserDataTable->cleanup();
+ delete fUserDataTable;//fUserDataTable->cleanup();
if (fRecycleNodePtr) {
fRecycleNodePtr->deleteAllElements();
@@ -244,7 +237,7 @@
// Note: the cloned document node goes on the system heap. All other
// nodes added to the new document will go on that document's heap,
// but we need to construct the document first, before its heap exists.
- DOMDocumentImpl *newdoc = new DOMDocumentImpl();
+ DOMDocumentImpl *newdoc = new DOMDocumentImpl(fMemoryManager);
// then the children by _importing_ them
if (deep)
@@ -415,7 +408,8 @@
DOMNodeIteratorImpl* nodeIterator = new (this) DOMNodeIteratorImpl(this, root, whatToShow, filter, entityReferenceExpansion);
if (fNodeIterators == 0L) {
- fNodeIterators = new (this) NodeIterators(1, false);
+ //fNodeIterators = new (this) NodeIterators(1, false);
+ fNodeIterators = new NodeIterators(1, false);
}
fNodeIterators->addElement(nodeIterator);
@@ -655,7 +649,8 @@
DOMRangeImpl* range = new (this) DOMRangeImpl(this);
if (fRanges == 0L) {
- fRanges = new (this) Ranges(1, false);
+ //fRanges = new (this) Ranges(1, false);
+ fRanges = new (fMemoryManager) Ranges(1, false); // XMemory
}
fRanges->addElement(range);
return range;
@@ -828,7 +823,7 @@
{
void* newBlock = 0;
try {
- newBlock = new char[amount + sizeOfPointer];
+ newBlock = fMemoryManager->allocate(amount + sizeOfPointer); //new char[amount + sizeOfPointer];
}
catch (...) {
ThrowXML(RuntimeException, XMLExcepts::Out_Of_Memory);
@@ -859,7 +854,7 @@
// Get a new one from the system allocator.
void* newBlock = 0;
try {
- newBlock = new char[kHeapAllocSize];
+ newBlock = fMemoryManager->allocate(kHeapAllocSize); //new char[kHeapAllocSize];
}
catch (...) {
ThrowXML(RuntimeException, XMLExcepts::Out_Of_Memory);
@@ -886,7 +881,7 @@
while (fCurrentBlock != 0)
{
void *nextBlock = *(void **)fCurrentBlock;
- delete [] (char*) fCurrentBlock;
+ fMemoryManager->deallocate(fCurrentBlock); //delete [] (char*) fCurrentBlock;
fCurrentBlock = nextBlock;
}
@@ -1181,7 +1176,8 @@
if (!fUserDataTable) {
// create the table on heap so that it can be cleaned in destructor
- fUserDataTable = new (this) RefHashTableOf<DOMNodeUserDataTable>(29, true, new HashPtr());
+ //fUserDataTable = new (this) RefHashTableOf<DOMNodeUserDataTable>(29, true, new HashPtr());
+ fUserDataTable = new (fMemoryManager) RefHashTableOf<DOMNodeUserDataTable>(29, true, new HashPtr());
}
else {
node_userDataTable = fUserDataTable->get((void*)n);
@@ -1202,7 +1198,7 @@
// create the DOMNodeUserDataTable if not exists
// create on the heap and adopted by the hashtable which will delete it upon removal.
if (!node_userDataTable) {
- node_userDataTable = new RefHashTableOf<DOMUserDataRecord>(29, true);
+ node_userDataTable = new (fMemoryManager) RefHashTableOf<DOMUserDataRecord>(29, true);
fUserDataTable->put(n, node_userDataTable);
}
@@ -1333,10 +1329,10 @@
void DOMDocumentImpl::release(DOMNode* object, NodeObjectType type)
{
if (!fRecycleNodePtr)
- fRecycleNodePtr = new RefArrayOf<DOMNodePtr> (15);
+ fRecycleNodePtr = new (fMemoryManager) RefArrayOf<DOMNodePtr> (15);
if (!fRecycleNodePtr->operator[](type))
- fRecycleNodePtr->operator[](type) = new RefStackOf<DOMNode> (15, false);
+ fRecycleNodePtr->operator[](type) = new (fMemoryManager) RefStackOf<DOMNode> (15, false);
fRecycleNodePtr->operator[](type)->push(object);
}
@@ -1344,7 +1340,7 @@
void DOMDocumentImpl::releaseBuffer(DOMBuffer* buffer)
{
if (!fRecycleBufferPtr)
- fRecycleBufferPtr = new RefStackOf<DOMBuffer> (15, false);
+ fRecycleBufferPtr = new (fMemoryManager) RefStackOf<DOMBuffer> (15, false);
fRecycleBufferPtr->push(buffer);
}
1.18 +8 -11 xml-xerces/c/src/xercesc/dom/impl/DOMDocumentImpl.hpp
Index: DOMDocumentImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMDocumentImpl.hpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- DOMDocumentImpl.hpp 14 May 2003 19:23:20 -0000 1.17
+++ DOMDocumentImpl.hpp 15 May 2003 18:25:54 -0000 1.18
@@ -4,7 +4,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -70,14 +70,10 @@
// name is substituded for the *.
//
-#include <string.h>
-#include <xercesc/util/XercesDefs.hpp>
#include <xercesc/util/RefArrayOf.hpp>
-#include <xercesc/util/RefVectorOf.hpp>
#include <xercesc/util/RefStackOf.hpp>
#include <xercesc/util/RefHashTableOf.hpp>
#include <xercesc/util/KeyRefPair.hpp>
-
#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMUserDataHandler.hpp>
#include "DOMNodeImpl.hpp"
@@ -97,7 +93,6 @@
class DOMElementImpl;
class DOMEntityImpl;
class DOMEntityReferenceImpl;
-class DOMNodeImpl;
class DOMNotationImpl;
class DOMProcessingInstructionImpl;
class DOMTextImpl;
@@ -109,9 +104,9 @@
class DOMImplementation;
class DOMNodeIDMap;
class DOMRangeImpl;
-class DOMParentNode;
class DOMStringPool;
class DOMBuffer;
+class MemoryManager;
typedef RefVectorOf<DOMRangeImpl> Ranges;
typedef RefVectorOf<DOMNodeIteratorImpl> NodeIterators;
@@ -119,7 +114,7 @@
typedef RefHashTableOf<DOMUserDataRecord> DOMNodeUserDataTable;
typedef RefStackOf<DOMNode> DOMNodePtr;
-class CDOM_EXPORT DOMDocumentImpl: public DOMDocument {
+class CDOM_EXPORT DOMDocumentImpl: public DOMDocument , public XMemory{
public:
// -----------------------------------------------------------------------
// data types
@@ -149,10 +144,11 @@
DOMNodeIDMap* fNodeIDMap; // for use by GetElementsById().
public:
- DOMDocumentImpl();
+ DOMDocumentImpl(MemoryManager* const manager);
DOMDocumentImpl(const XMLCh* namespaceURI, //DOM Level 2
const XMLCh* qualifiedName,
- DOMDocumentType* doctype);
+ DOMDocumentType* doctype,
+ MemoryManager* const manager);
virtual ~DOMDocumentImpl();
void setDocumentType(DOMDocumentType *doctype);
@@ -374,6 +370,7 @@
DOMNormalizer* fNormalizer;
Ranges* fRanges;
NodeIterators* fNodeIterators;
+ MemoryManager* fMemoryManager; // configurable memory manager
int fChanges;
bool errorChecking; // Bypass error checking.
1.12 +11 -5 xml-xerces/c/src/xercesc/dom/impl/DOMElementNSImpl.cpp
Index: DOMElementNSImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMElementNSImpl.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DOMElementNSImpl.cpp 20 Dec 2002 22:10:58 -0000 1.11
+++ DOMElementNSImpl.cpp 15 May 2003 18:25:54 -0000 1.12
@@ -179,7 +179,10 @@
XMLCh *newName;
XMLCh temp[4000];
if (newQualifiedNameLen >= 3999)
- newName = new XMLCh[newQualifiedNameLen];
+ newName = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ newQualifiedNameLen * sizeof(XMLCh)
+ );//new XMLCh[newQualifiedNameLen];
else
newName = temp;
@@ -192,7 +195,7 @@
getPooledString(newName);
if (newQualifiedNameLen >= 3999)
- delete[] newName;
+ XMLPlatformUtils::fgMemoryManager->deallocate(newName);//delete[] newName;
}
@@ -237,7 +240,10 @@
XMLCh* newName;
XMLCh temp[4000];
if (index >= 3999)
- newName = new XMLCh[XMLString::stringLen(qualifiedName)+1];
+ newName = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ (XMLString::stringLen(qualifiedName) + 1) * sizeof(XMLCh)
+ );//new XMLCh[XMLString::stringLen(qualifiedName)+1];
else
newName = temp;
@@ -247,7 +253,7 @@
this -> fLocalName = ownerDoc->getPooledString(fName+index+1);
if (index >= 3999)
- delete[] newName;
+ XMLPlatformUtils::fgMemoryManager->deallocate(newName);//delete[] newName;
// Before we carry on, we should check if the prefix or localName are valid XMLName
if (!((DOMDocumentImpl *)this->getOwnerDocument())->isXMLName(fPrefix) || !((DOMDocumentImpl *)this->getOwnerDocument())->isXMLName(fLocalName))
1.16 +11 -9 xml-xerces/c/src/xercesc/dom/impl/DOMImplementationImpl.cpp
Index: DOMImplementationImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMImplementationImpl.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- DOMImplementationImpl.cpp 9 Mar 2003 16:37:37 -0000 1.15
+++ DOMImplementationImpl.cpp 15 May 2003 18:25:54 -0000 1.16
@@ -227,9 +227,10 @@
}
DOMDocument *DOMImplementationImpl::createDocument(const XMLCh *namespaceURI,
- const XMLCh *qualifiedName, DOMDocumentType *doctype)
+ const XMLCh *qualifiedName, DOMDocumentType *doctype,
+ MemoryManager* const manager)
{
- return new DOMDocumentImpl(namespaceURI, qualifiedName, doctype);
+ return new (manager) DOMDocumentImpl(namespaceURI, qualifiedName, doctype, manager);
}
@@ -240,9 +241,9 @@
}
// Non-standard extension
-DOMDocument *DOMImplementationImpl::createDocument()
+DOMDocument *DOMImplementationImpl::createDocument(MemoryManager* const manager)
{
- return new DOMDocumentImpl();
+ return new (manager) DOMDocumentImpl(manager);
}
//
@@ -281,18 +282,19 @@
// ------------------------------------------------------------
//Introduced in DOM Level 3
DOMBuilder* DOMImplementationImpl::createDOMBuilder(const short mode,
- const XMLCh* const schemaType)
+ const XMLCh* const schemaType,
+ MemoryManager* const manager)
{
if (mode == DOMImplementationLS::MODE_ASYNCHRONOUS)
throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
- return new DOMBuilderImpl();
+ return new DOMBuilderImpl(0, manager);
}
-DOMWriter* DOMImplementationImpl::createDOMWriter()
+DOMWriter* DOMImplementationImpl::createDOMWriter(MemoryManager* const manager)
{
- return new DOMWriterImpl();
+ return new DOMWriterImpl(manager);
}
DOMInputSource* DOMImplementationImpl::createDOMInputSource()
1.10 +7 -5 xml-xerces/c/src/xercesc/dom/impl/DOMImplementationImpl.hpp
Index: DOMImplementationImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMImplementationImpl.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DOMImplementationImpl.hpp 10 Dec 2002 21:00:41 -0000 1.9
+++ DOMImplementationImpl.hpp 15 May 2003 18:25:54 -0000 1.10
@@ -100,13 +100,14 @@
const XMLCh *systemId);
virtual DOMDocument* createDocument(const XMLCh *namespaceURI,
const XMLCh *qualifiedName,
- DOMDocumentType *doctype);
+ DOMDocumentType *doctype,
+ MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
// DOM Level 3
virtual DOMImplementation* getInterface(const XMLCh* feature);
// Non-standard extension
- virtual DOMDocument* createDocument();
+ virtual DOMDocument* createDocument(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
// ------------------------------------------------------------
// DOMImplementationLS Virtual interface
@@ -114,8 +115,9 @@
// Introduced in DOM Level 3
// Experimental - subject to change
virtual DOMBuilder* createDOMBuilder(const short mode,
- const XMLCh* const schemaType);
- virtual DOMWriter* createDOMWriter();
+ const XMLCh* const schemaType,
+ MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
+ virtual DOMWriter* createDOMWriter(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
virtual DOMInputSource* createDOMInputSource();
// ------------------------------------------------------------
1.12 +41 -17 xml-xerces/c/src/xercesc/dom/impl/DOMRangeImpl.cpp
Index: DOMRangeImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMRangeImpl.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- DOMRangeImpl.cpp 25 Feb 2003 14:24:12 -0000 1.11
+++ DOMRangeImpl.cpp 15 May 2003 18:25:54 -0000 1.12
@@ -873,7 +873,10 @@
XMLCh* tempString;
XMLCh temp[4000];
if ((fEndOffset-fStartOffset) >= 3999)
- tempString = new XMLCh[fEndOffset-fStartOffset+1];
+ tempString = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ (fEndOffset - fStartOffset + 1) * sizeof(XMLCh)
+ );//new XMLCh[fEndOffset-fStartOffset+1];
else
tempString = temp;
@@ -881,7 +884,7 @@
const XMLCh* retString = ((DOMDocumentImpl *)fDocument)->getPooledString(tempString);
if ((fEndOffset-fStartOffset) >= 3999)
- delete[] tempString;
+ XMLPlatformUtils::fgMemoryManager->deallocate(tempString);//delete[] tempString;
return retString;
} else {
@@ -891,7 +894,10 @@
XMLCh* tempString;
XMLCh temp[4000];
if ((length - fStartOffset) >= 3999)
- tempString = new XMLCh[length - fStartOffset+1];
+ tempString = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ (length - fStartOffset + 1) * sizeof(XMLCh)
+ );//new XMLCh[length - fStartOffset+1];
else
tempString = temp;
@@ -899,7 +905,7 @@
retStringBuf.append(tempString);
if ((length - fStartOffset) >= 3999)
- delete[] tempString;
+ XMLPlatformUtils::fgMemoryManager->deallocate(tempString);//delete[] tempString;
}
node = nextNode(node, true);
@@ -957,7 +963,10 @@
XMLCh* tempString;
XMLCh temp[4000];
if (fEndOffset >= 3999)
- tempString = new XMLCh[fEndOffset+1];
+ tempString = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ (fEndOffset+1) * sizeof(XMLCh)
+ );//new XMLCh[fEndOffset+1];
else
tempString = temp;
@@ -965,7 +974,7 @@
retStringBuf.append(tempString);
if (fEndOffset >= 3999)
- delete[] tempString;
+ XMLPlatformUtils::fgMemoryManager->deallocate(tempString);//delete[] tempString;
}
}
return ((DOMDocumentImpl *)fDocument)->getPooledString(retStringBuf.getRawBuffer());
@@ -1284,7 +1293,10 @@
XMLCh* tempString;
XMLCh temp[4000];
if (fEndOffset >= 3999)
- tempString = new XMLCh[fEndOffset+1];
+ tempString = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ (fEndOffset+1) * sizeof(XMLCh)
+ );//new XMLCh[fEndOffset+1];
else
tempString = temp;
@@ -1292,7 +1304,7 @@
cloneCurrent->setNodeValue(((DOMDocumentImpl *)fDocument)->getPooledString(tempString));
if (fEndOffset >= 3999)
- delete[] tempString;
+ XMLPlatformUtils::fgMemoryManager->deallocate(tempString);//delete[] tempString;
}
// set the original text node to its new value
@@ -1705,7 +1717,10 @@
XMLCh oldTemp[4000];
if (offset >= 3999) {
- oldNodeValue = new XMLCh[offset+1];
+ oldNodeValue = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ (offset+1) * sizeof(XMLCh)
+ );//new XMLCh[offset+1];
}
else {
oldNodeValue = oldTemp;
@@ -1716,7 +1731,7 @@
n->setNodeValue( ((DOMDocumentImpl *)fDocument)->getPooledString(oldNodeValue) );
if (offset>= 3999)
- delete[] oldNodeValue;
+ XMLPlatformUtils::fgMemoryManager->deallocate(oldNodeValue);//delete[] oldNodeValue;
}
if ( how==DELETE_CONTENTS )
@@ -1732,7 +1747,10 @@
XMLCh newTemp[4000];
if (offset >= 3999) {
- newNodeValue = new XMLCh[offset+1];
+ newNodeValue = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ (offset+1) * sizeof(XMLCh)
+ );//new XMLCh[offset+1];
}
else {
newNodeValue = newTemp;
@@ -1741,7 +1759,7 @@
newNode->setNodeValue( ((DOMDocumentImpl *)fDocument)->getPooledString(newNodeValue) );
if (offset>= 3999)
- delete[] newNodeValue;
+ XMLPlatformUtils::fgMemoryManager->deallocate(newNodeValue);//delete[] newNodeValue;
}
return newNode;
@@ -1760,7 +1778,10 @@
XMLCh oldTemp[4000];
if (offset >= 3999) {
- oldNodeValue = new XMLCh[offset+1];
+ oldNodeValue = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ (offset+1) * sizeof(XMLCh)
+ );//new XMLCh[offset+1];
}
else {
oldNodeValue = oldTemp;
@@ -1771,7 +1792,7 @@
n->setNodeValue( ((DOMDocumentImpl *)fDocument)->getPooledString(oldNodeValue) );
if (offset>= 3999)
- delete[] oldNodeValue;
+ XMLPlatformUtils::fgMemoryManager->deallocate(oldNodeValue);//delete[] oldNodeValue;
}
if ( how==DELETE_CONTENTS )
@@ -1787,7 +1808,10 @@
XMLCh newTemp[4000];
if (offset >= 3999) {
- newNodeValue = new XMLCh[offset+1];
+ newNodeValue = (XMLCh*) XMLPlatformUtils::fgMemoryManager->allocate
+ (
+ (offset+1) * sizeof(XMLCh)
+ );//new XMLCh[offset+1];
}
else {
newNodeValue = newTemp;
@@ -1796,7 +1820,7 @@
newNode->setNodeValue( ((DOMDocumentImpl *)fDocument)->getPooledString(newNodeValue) );
if (offset>= 3999)
- delete[] newNodeValue;
+ XMLPlatformUtils::fgMemoryManager->deallocate(newNodeValue);//delete[] newNodeValue;
}
return newNode;
1.37 +23 -16 xml-xerces/c/src/xercesc/dom/impl/DOMWriterImpl.cpp
Index: DOMWriterImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMWriterImpl.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- DOMWriterImpl.cpp 14 May 2003 16:20:13 -0000 1.36
+++ DOMWriterImpl.cpp 15 May 2003 18:25:54 -0000 1.37
@@ -57,6 +57,9 @@
/*
* $Id$
* $Log$
+ * Revision 1.37 2003/05/15 18:25:54 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.36 2003/05/14 16:20:13 gareth
* Fix to problem with multiple default namespace attributes being serialized. Patch by Alberto Massari.
*
@@ -450,13 +453,13 @@
DOMWriterImpl::~DOMWriterImpl()
{
- delete [] fEncoding;
- delete [] fNewLine;
+ fMemoryManager->deallocate(fEncoding);//delete [] fEncoding;
+ fMemoryManager->deallocate(fNewLine);//delete [] fNewLine;
delete fNamespaceStack;
// we don't own/adopt error handler and filter
}
-DOMWriterImpl::DOMWriterImpl()
+DOMWriterImpl::DOMWriterImpl(MemoryManager* const manager)
:fFeatures(0)
,fEncoding(0)
,fNewLine(0)
@@ -469,8 +472,9 @@
,fErrorCount(0)
,fCurrentLine(0)
,fNamespaceStack(0)
+,fMemoryManager(manager)
{
- fNamespaceStack=new RefVectorOf< RefHashTableOf<XMLCh> >(0,true);
+ fNamespaceStack=new (fMemoryManager) RefVectorOf< RefHashTableOf<XMLCh> >(0,true);
//
// set features to default setting
@@ -535,8 +539,8 @@
// we don't check the validity of the encoding set
void DOMWriterImpl::setEncoding(const XMLCh* const encoding)
{
- delete [] fEncoding;
- fEncoding = XMLString::replicate(encoding);
+ fMemoryManager->deallocate(fEncoding);//delete [] fEncoding;
+ fEncoding = XMLString::replicate(encoding, fMemoryManager);
}
const XMLCh* DOMWriterImpl::getEncoding() const
@@ -546,8 +550,8 @@
void DOMWriterImpl::setNewLine(const XMLCh* const newLine)
{
- delete [] fNewLine;
- fNewLine = XMLString::replicate(newLine);
+ fMemoryManager->deallocate(fNewLine);//delete [] fNewLine;
+ fNewLine = XMLString::replicate(newLine, fMemoryManager);
}
const XMLCh* DOMWriterImpl::getNewLine() const
@@ -586,7 +590,7 @@
try
{
- fFormatter = new XMLFormatter(fEncodingUsed
+ fFormatter = new (fMemoryManager) XMLFormatter(fEncodingUsed
,fDocumentVersion
,destination
,XMLFormatter::NoEscapes
@@ -909,9 +913,9 @@
//track the line number the current node begins on
int nodeLine = fCurrentLine;
- // add an entry in the namespace stack
- RefHashTableOf<XMLCh>* namespaceMap=new RefHashTableOf<XMLCh>(12,false);
- fNamespaceStack->addElement(namespaceMap);
+ // add an entry in the namespace stack
+ RefHashTableOf<XMLCh>* namespaceMap=new (fMemoryManager) RefHashTableOf<XMLCh>(12,false);
+ fNamespaceStack->addElement(namespaceMap);
if ( filterAction == DOMNodeFilter::FILTER_ACCEPT)
{
@@ -968,7 +972,7 @@
bool discard = getFeature(DISCARD_DEFAULT_CONTENT_ID);
for (int i = 0; i < attrCount; i++)
{
- DOMAttrSPtr attribute = (DOMAttr*)attributes->item(i);
+ DOMAttrSPtr attribute = (DOMAttr*)attributes->item(i);
// Not to be shown to Filter
@@ -1459,10 +1463,13 @@
* Append a ']]>' at the end
*/
int len = XMLString::stringLen(nodeValue);
- XMLCh* repNodeValue = new XMLCh [len + offset + 1];
+ XMLCh* repNodeValue = (XMLCh*) fMemoryManager->allocate
+ (
+ (len + offset + 1) * sizeof(XMLCh)
+ );//new XMLCh [len + offset + 1];
XMLString::copyString(repNodeValue, nodeValue);
XMLString::catString(repNodeValue, gEndCDATA);
- ArrayJanitor<XMLCh> jName(repNodeValue);
+ ArrayJanitor<XMLCh> jName(repNodeValue, fMemoryManager);
XMLCh* curPtr = (XMLCh*) repNodeValue;
XMLCh* nextPtr = 0;
1.15 +6 -2 xml-xerces/c/src/xercesc/dom/impl/DOMWriterImpl.hpp
Index: DOMWriterImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMWriterImpl.hpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DOMWriterImpl.hpp 12 May 2003 16:08:11 -0000 1.14
+++ DOMWriterImpl.hpp 15 May 2003 18:25:54 -0000 1.15
@@ -57,6 +57,9 @@
/*
* $Id$
* $Log$
+ * Revision 1.15 2003/05/15 18:25:54 knoaman
+ * Partial implementation of the configurable memory manager.
+ *
* Revision 1.14 2003/05/12 16:08:11 gareth
* fix to #18832. Corrected serilization with regards to namespace nodes. Patch by Alby Massari.
*
@@ -343,7 +346,7 @@
/**
* Constructor.
*/
- DOMWriterImpl();
+ DOMWriterImpl(MemoryManager* const manager);
/**
* Destructor.
@@ -487,6 +490,7 @@
int fCurrentLine;
RefVectorOf< RefHashTableOf<XMLCh> >* fNamespaceStack;
+ MemoryManager* fMemoryManager;
};
inline void DOMWriterImpl::setFeature(const int featureId
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org