From b6bdddcf8adf8409dc57a5e0f5c33ac392bf158d Mon Sep 17 00:00:00 2001
From: Khaled Noaman <knoaman@apache.org>
Date: Thu, 15 May 2003 18:29:49 +0000
Subject: [PATCH] Partial implementation of the configurable memory manager.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174981 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/dom/DOMImplementation.hpp         |   6 +-
 src/xercesc/dom/DOMImplementationLS.hpp       |  12 +-
 src/xercesc/dom/deprecated/DOMParser.cpp      |  19 ++-
 src/xercesc/dom/deprecated/DOMParser.hpp      |   7 +-
 src/xercesc/dom/deprecated/DOMString.hpp      |   4 +-
 src/xercesc/dom/deprecated/DStringPool.hpp    |   3 +-
 src/xercesc/dom/deprecated/DocumentImpl.cpp   |  94 +++++++--------
 src/xercesc/dom/deprecated/DocumentImpl.hpp   |   6 +
 src/xercesc/dom/deprecated/ElementImpl.cpp    |  54 ++++++---
 .../dom/deprecated/NamedNodeMapImpl.hpp       |   4 +-
 src/xercesc/dom/deprecated/NodeImpl.hpp       |   2 +-
 .../dom/deprecated/NodeIteratorImpl.hpp       |   2 +-
 src/xercesc/dom/deprecated/RefCountedImpl.hpp |   4 +-
 src/xercesc/dom/deprecated/TreeWalkerImpl.hpp |   2 +-
 src/xercesc/dom/impl/DOMAttrNSImpl.cpp        |  14 ++-
 src/xercesc/dom/impl/DOMCharacterDataImpl.cpp |  21 +++-
 src/xercesc/dom/impl/DOMDeepNodeListPool.c    | 102 +++++++++++------
 src/xercesc/dom/impl/DOMDeepNodeListPool.hpp  |  52 +++++----
 src/xercesc/dom/impl/DOMDocumentImpl.cpp      |  58 +++++-----
 src/xercesc/dom/impl/DOMDocumentImpl.hpp      |  17 ++-
 src/xercesc/dom/impl/DOMElementNSImpl.cpp     |  14 ++-
 .../dom/impl/DOMImplementationImpl.cpp        |  18 +--
 .../dom/impl/DOMImplementationImpl.hpp        |  10 +-
 src/xercesc/dom/impl/DOMRangeImpl.cpp         |  56 ++++++---
 src/xercesc/dom/impl/DOMWriterImpl.cpp        |  37 +++---
 src/xercesc/dom/impl/DOMWriterImpl.hpp        |   6 +-
 .../framework/LocalFileFormatTarget.cpp       |  26 ++++-
 .../framework/LocalFileFormatTarget.hpp       |   5 +-
 .../framework/LocalFileInputSource.cpp        |  25 ++--
 src/xercesc/framework/MemBufFormatTarget.cpp  |  20 +++-
 src/xercesc/framework/MemBufFormatTarget.hpp  |   4 +
 src/xercesc/framework/MemBufInputSource.cpp   |   5 +-
 src/xercesc/framework/XMLAttDef.cpp           |  11 +-
 src/xercesc/framework/XMLAttDef.hpp           |  29 ++++-
 src/xercesc/framework/XMLAttDefList.hpp       |  11 +-
 src/xercesc/framework/XMLAttr.cpp             |  52 +++++----
 src/xercesc/framework/XMLAttr.hpp             |  35 ++++--
 src/xercesc/framework/XMLBuffer.cpp           |  17 +--
 src/xercesc/framework/XMLBuffer.hpp           |  28 +++--
 src/xercesc/framework/XMLBufferMgr.cpp        |  17 +--
 src/xercesc/framework/XMLBufferMgr.hpp        |  10 +-
 src/xercesc/framework/XMLContentModel.hpp     |  10 +-
 src/xercesc/framework/XMLElementDecl.cpp      |  15 +--
 src/xercesc/framework/XMLElementDecl.hpp      |  25 +++-
 src/xercesc/framework/XMLEntityDecl.cpp       |  33 +++---
 src/xercesc/framework/XMLEntityDecl.hpp       |  41 +++++--
 src/xercesc/framework/XMLFormatter.cpp        |  42 ++++---
 src/xercesc/framework/XMLFormatter.hpp        |  16 +--
 src/xercesc/framework/XMLNotationDecl.cpp     |  26 +++--
 src/xercesc/framework/XMLNotationDecl.hpp     |  25 ++--
 src/xercesc/framework/XMLPScanToken.hpp       |   7 +-
 src/xercesc/framework/XMLRecognizer.cpp       |   6 +-
 src/xercesc/framework/XMLRefInfo.hpp          |  14 ++-
 src/xercesc/framework/XMLValidator.cpp        |  10 +-
 src/xercesc/framework/XMLValidator.hpp        |  14 +--
 src/xercesc/internal/DGXMLScanner.cpp         |  93 ++++++++++-----
 src/xercesc/internal/DGXMLScanner.hpp         |  17 ++-
 src/xercesc/internal/ElemStack.cpp            |  84 +++++++++-----
 src/xercesc/internal/ElemStack.hpp            |  18 +--
 src/xercesc/internal/IGXMLScanner.cpp         | 108 ++++++++++++------
 src/xercesc/internal/IGXMLScanner.hpp         |  15 ++-
 src/xercesc/internal/IGXMLScanner2.cpp        |  53 ++++++---
 src/xercesc/internal/ReaderMgr.cpp            |  23 ++--
 src/xercesc/internal/ReaderMgr.hpp            |  14 ++-
 src/xercesc/internal/SGXMLScanner.cpp         | 105 +++++++++++------
 src/xercesc/internal/SGXMLScanner.hpp         |   5 +
 src/xercesc/internal/VecAttrListImpl.cpp      |   7 +-
 src/xercesc/internal/VecAttrListImpl.hpp      |   5 +-
 src/xercesc/internal/WFXMLScanner.cpp         |  50 +++++---
 src/xercesc/internal/WFXMLScanner.hpp         |   5 +
 src/xercesc/internal/XMLReader.cpp            |  10 +-
 src/xercesc/internal/XMLReader.hpp            |   8 +-
 src/xercesc/internal/XMLScanner.cpp           |  66 +++++++----
 src/xercesc/internal/XMLScanner.hpp           |  65 +++++++----
 src/xercesc/internal/XMLScannerResolver.cpp   |  39 ++++---
 src/xercesc/internal/XMLScannerResolver.hpp   |  24 ++--
 src/xercesc/parsers/AbstractDOMParser.cpp     |  22 ++--
 src/xercesc/parsers/AbstractDOMParser.hpp     |  12 +-
 src/xercesc/parsers/DOMBuilderImpl.cpp        |   5 +-
 src/xercesc/parsers/DOMBuilderImpl.hpp        |   6 +-
 src/xercesc/parsers/SAX2XMLReaderImpl.cpp     |  47 +++++---
 src/xercesc/parsers/SAX2XMLReaderImpl.hpp     |  11 +-
 src/xercesc/parsers/SAXParser.cpp             |  34 ++++--
 src/xercesc/parsers/SAXParser.hpp             |  15 ++-
 src/xercesc/parsers/XercesDOMParser.cpp       |   5 +-
 src/xercesc/parsers/XercesDOMParser.hpp       |   6 +-
 src/xercesc/sax/InputSource.cpp               |  56 +++++----
 src/xercesc/sax/InputSource.hpp               |  23 +++-
 src/xercesc/sax/SAXException.hpp              |   6 +-
 src/xercesc/sax/SAXParseException.hpp         |   5 +-
 src/xercesc/sax2/XMLReaderFactory.hpp         |  11 +-
 .../util/MsgLoaders/ICU/ICUMsgLoader.cpp      |  23 ++--
 .../util/MsgLoaders/ICU/ICUMsgLoader.hpp      |   4 +-
 .../MsgLoaders/InMemory/InMemMsgLoader.cpp    |  24 ++--
 .../MsgCatalog/MsgCatalogLoader.cpp           |  19 +--
 .../util/MsgLoaders/MsgFile/MsgLoader.cpp     |  20 ++--
 .../util/MsgLoaders/Win32/Win32MsgLoader.cpp  |  20 ++--
 97 files changed, 1546 insertions(+), 845 deletions(-)

diff --git a/src/xercesc/dom/DOMImplementation.hpp b/src/xercesc/dom/DOMImplementation.hpp
index 5aae3089b..3b8095333 100644
--- a/src/xercesc/dom/DOMImplementation.hpp
+++ b/src/xercesc/dom/DOMImplementation.hpp
@@ -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 @@ public:
 
     virtual DOMDocument *createDocument(const XMLCh *namespaceURI,
                                         const XMLCh *qualifiedName,
-                                        DOMDocumentType *doctype) = 0;
+                                        DOMDocumentType *doctype,
+                                        MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0;
 
     //@}
     // -----------------------------------------------------------------------
@@ -248,7 +250,7 @@ public:
      *
      * 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
diff --git a/src/xercesc/dom/DOMImplementationLS.hpp b/src/xercesc/dom/DOMImplementationLS.hpp
index 4da88af59..bd612c5cb 100644
--- a/src/xercesc/dom/DOMImplementationLS.hpp
+++ b/src/xercesc/dom/DOMImplementationLS.hpp
@@ -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 @@ XERCES_CPP_NAMESPACE_BEGIN
 class DOMBuilder;
 class DOMWriter;
 class DOMInputSource;
-
+class MemoryManager;
 
 /**
   * <p><code>DOMImplementationLS</code> contains the factory methods for
@@ -195,7 +198,8 @@ public:
      * @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 @@ public:
      * @see DOMWriter
      * @since DOM Level 3
      */
-    virtual DOMWriter* createDOMWriter() = 0;
+    virtual DOMWriter* createDOMWriter(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) = 0;
 
     /**
      * Create a new "empty" DOMInputSource.
diff --git a/src/xercesc/dom/deprecated/DOMParser.cpp b/src/xercesc/dom/deprecated/DOMParser.cpp
index a8476d834..dca308692 100644
--- a/src/xercesc/dom/deprecated/DOMParser.cpp
+++ b/src/xercesc/dom/deprecated/DOMParser.cpp
@@ -99,7 +99,8 @@ XERCES_CPP_NAMESPACE_BEGIN
 // ---------------------------------------------------------------------------
 //  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 @@ DOMParser::DOMParser(XMLValidator* const valToAdopt) :
     , fGrammarResolver(0)
     , fURIStringPool(0)
     , fValidator(valToAdopt)
+    , fMemoryManager(manager)
 {
     try
     {
@@ -138,18 +140,18 @@ DOMParser::~DOMParser()
 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::setStandardUriConformant(const bool newState)
 
 void DOMParser::useScanner(const XMLCh* const scannerName)
 {
-    XMLScanner* tempScanner = XMLScannerResolver::resolveScanner(scannerName, fValidator);
+    XMLScanner* tempScanner = XMLScannerResolver::resolveScanner
+    (
+        scannerName
+        , fValidator
+        , fMemoryManager
+    );
 
     if (tempScanner) {
 
diff --git a/src/xercesc/dom/deprecated/DOMParser.hpp b/src/xercesc/dom/deprecated/DOMParser.hpp
index a1e49db79..4c4414c1d 100644
--- a/src/xercesc/dom/deprecated/DOMParser.hpp
+++ b/src/xercesc/dom/deprecated/DOMParser.hpp
@@ -127,7 +127,11 @@ public :
       * @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 @@ private :
     GrammarResolver*        fGrammarResolver;
     XMLStringPool*          fURIStringPool;
     XMLValidator*           fValidator;
+    MemoryManager*          fMemoryManager;
 };
 
 
diff --git a/src/xercesc/dom/deprecated/DOMString.hpp b/src/xercesc/dom/deprecated/DOMString.hpp
index 69a3ed403..5b6469bd3 100644
--- a/src/xercesc/dom/deprecated/DOMString.hpp
+++ b/src/xercesc/dom/deprecated/DOMString.hpp
@@ -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 @@ class DOM_NullPtr;
  * 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 */
     //@{
diff --git a/src/xercesc/dom/deprecated/DStringPool.hpp b/src/xercesc/dom/deprecated/DStringPool.hpp
index d7781e345..2449b2630 100644
--- a/src/xercesc/dom/deprecated/DStringPool.hpp
+++ b/src/xercesc/dom/deprecated/DStringPool.hpp
@@ -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 @@ struct DStringPoolEntry;
 //  if the name has been seen before, the already existing string
 //  will be reused.
 //
-class DStringPool
+class DStringPool : public XMemory
 {
 public:
     DStringPool(int  hashTableSize);
diff --git a/src/xercesc/dom/deprecated/DocumentImpl.cpp b/src/xercesc/dom/deprecated/DocumentImpl.cpp
index 7ed36dc60..e0fa677e8 100644
--- a/src/xercesc/dom/deprecated/DocumentImpl.cpp
+++ b/src/xercesc/dom/deprecated/DocumentImpl.cpp
@@ -100,17 +100,19 @@ static XMLRegisterCleanup namCleanup;
 
 DocumentImpl::DocumentImpl()
     : ParentNode(this)
-{
-    docType     = null;
-    docElement  = null;
-    namePool    = new DStringPool(257);
-    iterators   = 0L;
-    treeWalkers = 0L;
-    fNodeIDMap  = 0;
-    userData    = 0;
-    ranges      = 0;
-    fChanges = 0;
-    errorChecking = true;
+    , docType(0)
+    , docElement(0)
+    , namePool(0)
+    , fNodeIDMap(0)
+    , iterators(0)
+    , treeWalkers(0)
+    , userData(0)
+    , ranges(0)
+    , fChanges(0)
+    , errorChecking(true)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
+{
+    namePool    = new (fMemoryManager) DStringPool(257);
 };
 
 
@@ -119,20 +121,20 @@ DocumentImpl::DocumentImpl(const DOMString &fNamespaceURI,
                            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 @@ AttrImpl *DocumentImpl::createAttribute(const DOMString &nam)
     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 @@ DocumentTypeImpl *DocumentImpl::createDocumentType(const DOMString &nam)
     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 @@ DocumentTypeImpl *
     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 @@ ElementImpl *DocumentImpl::createElement(const DOMString &tagName)
         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 @@ EntityImpl *DocumentImpl::createEntity(const DOMString &nam)
     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 @@ EntityReferenceImpl *DocumentImpl::createEntityReference(const DOMString &nam)
     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 @@ NotationImpl *DocumentImpl::createNotation(const DOMString &nam)
     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 @@ ProcessingInstructionImpl *DocumentImpl::createProcessingInstruction(
     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 @@ ProcessingInstructionImpl *DocumentImpl::createProcessingInstruction(
 
 TextImpl *DocumentImpl::createTextNode(const DOMString &data)
 {
-    return new TextImpl(this,data);
+    return new (fMemoryManager) TextImpl(this,data);
 };
 
 
@@ -360,7 +362,7 @@ NodeIteratorImpl* DocumentImpl::createNodeIterator (DOM_Node root, unsigned long
 		//	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 @@ NodeIteratorImpl* DocumentImpl::createNodeIterator (DOM_Node root, unsigned long
         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 @@ TreeWalkerImpl* DocumentImpl::createTreeWalker (DOM_Node root, unsigned long wha
 {
 		// 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 @@ TreeWalkerImpl* DocumentImpl::createTreeWalker (DOM_Node root, unsigned long wha
         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 @@ ElementImpl *DocumentImpl::createElementNS(const DOMString &fNamespaceURI,
         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 @@ AttrImpl *DocumentImpl::createAttributeNS(const DOMString &fNamespaceURI,
     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 @@ int DocumentImpl::indexofQualifiedName(const DOMString & qName)
 
 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 @@ bool DocumentImpl::isKidOK(NodeImpl *parent, NodeImpl *child)
 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
diff --git a/src/xercesc/dom/deprecated/DocumentImpl.hpp b/src/xercesc/dom/deprecated/DocumentImpl.hpp
index 90d590c76..5441c586e 100644
--- a/src/xercesc/dom/deprecated/DocumentImpl.hpp
+++ b/src/xercesc/dom/deprecated/DocumentImpl.hpp
@@ -166,6 +166,8 @@ private:
     /** Bypass error checking. */
     bool errorChecking;
 
+    MemoryManager               *fMemoryManager;
+
     friend class NodeIteratorImpl;
     friend class TreeWalkerImpl;
     friend class RangeImpl;
@@ -268,6 +270,10 @@ public:
         return errorChecking;
     }
 
+    inline MemoryManager* getMemoryManager() const {
+        return fMemoryManager;
+    }
+
     // -----------------------------------------------------------------------
     //  Notification that lazy data has been deleted
     // -----------------------------------------------------------------------
diff --git a/src/xercesc/dom/deprecated/ElementImpl.cpp b/src/xercesc/dom/deprecated/ElementImpl.cpp
index b76765fa9..04f59b0ca 100644
--- a/src/xercesc/dom/deprecated/ElementImpl.cpp
+++ b/src/xercesc/dom/deprecated/ElementImpl.cpp
@@ -241,8 +241,12 @@ AttrImpl *ElementImpl::setAttribute(const DOMString &nam, const DOMString &val)
     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 @@ AttrImpl * ElementImpl::setAttributeNode(AttrImpl *newAttr)
     }
     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 *ElementImpl::setAttributeNS(const DOMString &fNamespaceURI,
       (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 @@ AttrImpl *ElementImpl::setAttributeNodeNS(AttrImpl *newAttr)
         }
     }
     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_removeNamedItem(const DOMString &nnm_name)
 
 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_getNamedItemNS(const DOMString &nnm_namespaceURI, con
 
 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 @@ void ElementImpl::setupDefaultAttributes()
 		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);
+    }
 }
 
 // -----------------------------------------------------------------------
diff --git a/src/xercesc/dom/deprecated/NamedNodeMapImpl.hpp b/src/xercesc/dom/deprecated/NamedNodeMapImpl.hpp
index 0a1a258df..ab336eca0 100644
--- a/src/xercesc/dom/deprecated/NamedNodeMapImpl.hpp
+++ b/src/xercesc/dom/deprecated/NamedNodeMapImpl.hpp
@@ -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 NodeVector;
 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
diff --git a/src/xercesc/dom/deprecated/NodeImpl.hpp b/src/xercesc/dom/deprecated/NodeImpl.hpp
index 4af566750..744ddeae0 100644
--- a/src/xercesc/dom/deprecated/NodeImpl.hpp
+++ b/src/xercesc/dom/deprecated/NodeImpl.hpp
@@ -88,7 +88,7 @@
  * ownerDocument.
  **/
 
-#include <xercesc/util/XercesDefs.hpp>
+#include <xercesc/util/XMemory.hpp>
 #include "NodeListImpl.hpp"
 #include "DOMString.hpp"
 
diff --git a/src/xercesc/dom/deprecated/NodeIteratorImpl.hpp b/src/xercesc/dom/deprecated/NodeIteratorImpl.hpp
index f3b6b9653..ab67786d4 100644
--- a/src/xercesc/dom/deprecated/NodeIteratorImpl.hpp
+++ b/src/xercesc/dom/deprecated/NodeIteratorImpl.hpp
@@ -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"
diff --git a/src/xercesc/dom/deprecated/RefCountedImpl.hpp b/src/xercesc/dom/deprecated/RefCountedImpl.hpp
index 16282e934..54a6c83e5 100644
--- a/src/xercesc/dom/deprecated/RefCountedImpl.hpp
+++ b/src/xercesc/dom/deprecated/RefCountedImpl.hpp
@@ -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;
diff --git a/src/xercesc/dom/deprecated/TreeWalkerImpl.hpp b/src/xercesc/dom/deprecated/TreeWalkerImpl.hpp
index ca8fad82c..81236e6ec 100644
--- a/src/xercesc/dom/deprecated/TreeWalkerImpl.hpp
+++ b/src/xercesc/dom/deprecated/TreeWalkerImpl.hpp
@@ -70,7 +70,7 @@
 #ifndef TreeWalkerImpl_HEADER_GUARD_
 #define TreeWalkerImpl_HEADER_GUARD_
 
-
+#include <xercesc/util/XMemory.hpp>
 #include "DOM_TreeWalker.hpp"
 #include "RefCountedImpl.hpp"
 
diff --git a/src/xercesc/dom/impl/DOMAttrNSImpl.cpp b/src/xercesc/dom/impl/DOMAttrNSImpl.cpp
index 7eff94b24..334069279 100644
--- a/src/xercesc/dom/impl/DOMAttrNSImpl.cpp
+++ b/src/xercesc/dom/impl/DOMAttrNSImpl.cpp
@@ -155,7 +155,10 @@ void DOMAttrNSImpl::setPrefix(const XMLCh *prefix)
     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 @@ void DOMAttrNSImpl::setPrefix(const XMLCh *prefix)
                                            getPooledString(newName);
 
     if (newQualifiedNameLen >= 3999)
-        delete[] newName;
+        XMLPlatformUtils::fgMemoryManager->deallocate(newName);//delete[] newName;
 
 }
 
@@ -228,7 +231,10 @@ void DOMAttrNSImpl::setName(const XMLCh* namespaceURI, const XMLCh* qualifiedNam
         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 @@ void DOMAttrNSImpl::setName(const XMLCh* namespaceURI, const XMLCh* qualifiedNam
         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))
diff --git a/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp b/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp
index 7f609e3ea..987fddf4a 100644
--- a/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp
+++ b/src/xercesc/dom/impl/DOMCharacterDataImpl.cpp
@@ -171,7 +171,10 @@ void DOMCharacterDataImpl::deleteData(const DOMNode *node, XMLSize_t offset, XML
     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 @@ void DOMCharacterDataImpl::deleteData(const DOMNode *node, XMLSize_t offset, XML
     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 @@ void DOMCharacterDataImpl::insertData(const DOMNode *node, XMLSize_t offset, con
     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 @@ void DOMCharacterDataImpl::insertData(const DOMNode *node, XMLSize_t offset, con
     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 @@ const XMLCh * DOMCharacterDataImpl::substringData(const DOMNode *node, XMLSize_t
     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 * DOMCharacterDataImpl::substringData(const DOMNode *node, XMLSize_t
     const XMLCh* retString = ((DOMDocumentImpl *)node->getOwnerDocument())->getPooledString(newString);
 
     if (len >= 3999)
-        delete[] newString;
+        XMLPlatformUtils::fgMemoryManager->deallocate(newString);//delete[] newString;
 
     return retString;
 
diff --git a/src/xercesc/dom/impl/DOMDeepNodeListPool.c b/src/xercesc/dom/impl/DOMDeepNodeListPool.c
index e3de1ee90..98784409a 100644
--- a/src/xercesc/dom/impl/DOMDeepNodeListPool.c
+++ b/src/xercesc/dom/impl/DOMDeepNodeListPool.c
@@ -74,21 +74,23 @@ XERCES_CPP_NAMESPACE_BEGIN
 // ---------------------------------------------------------------------------
 //  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 @@ template <class TVal> DOMDeepNodeListPool<TVal>::DOMDeepNodeListPool(
     //
     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 @@ template <class TVal> DOMDeepNodeListPool<TVal>::DOMDeepNodeListPool(
     //
     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 @@ template <class TVal> DOMDeepNodeListPool<TVal>::DOMDeepNodeListPool(const XMLSi
     //
     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 @@ template <class TVal> DOMDeepNodeListPool<TVal>::~DOMDeepNodeListPool()
     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 @@ template <class TVal> DOMDeepNodeListPool<TVal>::~DOMDeepNodeListPool()
 // ---------------------------------------------------------------------------
 //  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 @@ template <class TVal> bool DOMDeepNodeListPool<TVal>::isEmpty() const
     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 @@ template <class TVal> void DOMDeepNodeListPool<TVal>::removeAll()
                 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 @@ template <class TVal> void DOMDeepNodeListPool<TVal>::cleanup()
     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 @@ DOMDeepNodeListPool<TVal>::put(void* key1, XMLCh* key2, XMLCh* key3, TVal* const
         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 @@ DOMDeepNodeListPool<TVal>::put(void* key1, XMLCh* key2, XMLCh* key3, TVal* const
     {
         // 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;
     }
diff --git a/src/xercesc/dom/impl/DOMDeepNodeListPool.hpp b/src/xercesc/dom/impl/DOMDeepNodeListPool.hpp
index 98178b0ce..c60806fa3 100644
--- a/src/xercesc/dom/impl/DOMDeepNodeListPool.hpp
+++ b/src/xercesc/dom/impl/DOMDeepNodeListPool.hpp
@@ -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 @@ template <class TVal> struct DOMDeepNodeListPoolTableBucketElem;
 //  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 @@ public:
     DOMDeepNodeListPool
     (
          const XMLSize_t modulus
-       , const bool adoptElems, HashBase* hash
+       , const bool adoptElems
+       , HashBase* hash
        , const XMLSize_t initSize = 128
     );
 
@@ -224,13 +227,14 @@ private:
     //      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
diff --git a/src/xercesc/dom/impl/DOMDocumentImpl.cpp b/src/xercesc/dom/impl/DOMDocumentImpl.cpp
index c023cb442..f792dab9f 100644
--- a/src/xercesc/dom/impl/DOMDocumentImpl.cpp
+++ b/src/xercesc/dom/impl/DOMDocumentImpl.cpp
@@ -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 @@ XERCES_CPP_NAMESPACE_BEGIN
 //                             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 @@ DOMDocumentImpl::DOMDocumentImpl()
       fUserDataTable(0),
       fRecycleNodePtr(0),
       fRecycleBufferPtr(0),
+      fMemoryManager(manager),
       errorChecking(true)
 {
     fNamePool    = new (this) DOMStringPool(257, this);
@@ -143,7 +134,8 @@ DOMDocumentImpl::DOMDocumentImpl()
 //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 @@ DOMDocumentImpl::DOMDocumentImpl(const XMLCh *fNamespaceURI,
       fUserDataTable(0),
       fRecycleNodePtr(0),
       fRecycleBufferPtr(0),
+      fMemoryManager(manager),
       errorChecking(true)
 {
     fNamePool    = new (this) DOMStringPool(257, this);
@@ -214,13 +207,13 @@ DOMDocumentImpl::~DOMDocumentImpl()
         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 @@ DOMNode *DOMDocumentImpl::cloneNode(bool deep) const {
     // 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 @@ DOMNodeIterator* DOMDocumentImpl::createNodeIterator (
     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 @@ DOMRange* DOMDocumentImpl::createRange()
     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 *         DOMDocumentImpl::allocate(size_t amount)
     {
         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 @@ void *         DOMDocumentImpl::allocate(size_t amount)
         //   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 @@ void    DOMDocumentImpl::deleteHeap()
     while (fCurrentBlock != 0)
     {
         void *nextBlock = *(void **)fCurrentBlock;
-        delete [] (char*) fCurrentBlock;
+        fMemoryManager->deallocate(fCurrentBlock); //delete [] (char*) fCurrentBlock;
         fCurrentBlock = nextBlock;
     }
 
@@ -1181,7 +1176,8 @@ void* DOMDocumentImpl::setUserData(DOMNodeImpl* n, const XMLCh* key, void* data,
 
     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 @@ void* DOMDocumentImpl::setUserData(DOMNodeImpl* n, const XMLCh* key, void* data,
         // 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::releaseDocNotifyUserData(DOMNode* object)
 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::release(DOMNode* object, NodeObjectType type)
 void DOMDocumentImpl::releaseBuffer(DOMBuffer* buffer)
 {
     if (!fRecycleBufferPtr)
-        fRecycleBufferPtr = new RefStackOf<DOMBuffer> (15, false);
+        fRecycleBufferPtr = new (fMemoryManager) RefStackOf<DOMBuffer> (15, false);
 
     fRecycleBufferPtr->push(buffer);
 }
diff --git a/src/xercesc/dom/impl/DOMDocumentImpl.hpp b/src/xercesc/dom/impl/DOMDocumentImpl.hpp
index 130e347c4..9455027e6 100644
--- a/src/xercesc/dom/impl/DOMDocumentImpl.hpp
+++ b/src/xercesc/dom/impl/DOMDocumentImpl.hpp
@@ -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 DOMDocumentTypeImpl;
 class DOMElementImpl;
 class DOMEntityImpl;
 class DOMEntityReferenceImpl;
-class DOMNodeImpl;
 class DOMNotationImpl;
 class DOMProcessingInstructionImpl;
 class DOMTextImpl;
@@ -109,9 +104,9 @@ class DOMNodeFilterImpl;
 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 KeyRefPair<void, DOMUserDataHandler> DOMUserDataRecord;
 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 @@ public:
     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 @@ private:
     DOMNormalizer*        fNormalizer;
     Ranges*               fRanges;
     NodeIterators*        fNodeIterators;
+    MemoryManager*        fMemoryManager;   // configurable memory manager
 
     int                   fChanges;
     bool                  errorChecking;    // Bypass error checking.
diff --git a/src/xercesc/dom/impl/DOMElementNSImpl.cpp b/src/xercesc/dom/impl/DOMElementNSImpl.cpp
index 973bf211c..10fe6b0e8 100644
--- a/src/xercesc/dom/impl/DOMElementNSImpl.cpp
+++ b/src/xercesc/dom/impl/DOMElementNSImpl.cpp
@@ -179,7 +179,10 @@ void DOMElementNSImpl::setPrefix(const XMLCh *prefix)
     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 @@ void DOMElementNSImpl::setPrefix(const XMLCh *prefix)
                                            getPooledString(newName);
 
     if (newQualifiedNameLen >= 3999)
-        delete[] newName;
+        XMLPlatformUtils::fgMemoryManager->deallocate(newName);//delete[] newName;
 
 }
 
@@ -237,7 +240,10 @@ void DOMElementNSImpl::setName(const XMLCh *namespaceURI,
         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 @@ void DOMElementNSImpl::setName(const XMLCh *namespaceURI,
         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))
diff --git a/src/xercesc/dom/impl/DOMImplementationImpl.cpp b/src/xercesc/dom/impl/DOMImplementationImpl.cpp
index 435be872f..568a0bd0a 100644
--- a/src/xercesc/dom/impl/DOMImplementationImpl.cpp
+++ b/src/xercesc/dom/impl/DOMImplementationImpl.cpp
@@ -227,9 +227,10 @@ DOMDocumentType *DOMImplementationImpl::createDocumentType(const XMLCh *qualifie
 }
 
 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 @@ DOMImplementation* DOMImplementationImpl::getInterface(const XMLCh* feature){
 }
 
 // Non-standard extension
-DOMDocument *DOMImplementationImpl::createDocument()
+DOMDocument *DOMImplementationImpl::createDocument(MemoryManager* const manager)
 {
-        return new DOMDocumentImpl();
+        return new (manager) DOMDocumentImpl(manager);
 }
 
 //
@@ -281,18 +282,19 @@ bool DOMImplementation::loadDOMExceptionMsg
 // ------------------------------------------------------------
 //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()
diff --git a/src/xercesc/dom/impl/DOMImplementationImpl.hpp b/src/xercesc/dom/impl/DOMImplementationImpl.hpp
index 1293b0085..46bcb903a 100644
--- a/src/xercesc/dom/impl/DOMImplementationImpl.hpp
+++ b/src/xercesc/dom/impl/DOMImplementationImpl.hpp
@@ -100,13 +100,14 @@ public:
                                                    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 @@ public:
     // 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();
 
     // ------------------------------------------------------------
diff --git a/src/xercesc/dom/impl/DOMRangeImpl.cpp b/src/xercesc/dom/impl/DOMRangeImpl.cpp
index 9ee756c47..29ffc753d 100644
--- a/src/xercesc/dom/impl/DOMRangeImpl.cpp
+++ b/src/xercesc/dom/impl/DOMRangeImpl.cpp
@@ -873,7 +873,10 @@ const XMLCh* DOMRangeImpl::toString() const
             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* DOMRangeImpl::toString() const
             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 @@ const XMLCh* DOMRangeImpl::toString() const
                 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 @@ const XMLCh* DOMRangeImpl::toString() const
                 retStringBuf.append(tempString);
 
                 if ((length - fStartOffset) >= 3999)
-                    delete[] tempString;
+                    XMLPlatformUtils::fgMemoryManager->deallocate(tempString);//delete[] tempString;
             }
 
             node = nextNode(node, true);
@@ -957,7 +963,10 @@ const XMLCh* DOMRangeImpl::toString() const
             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 @@ const XMLCh* DOMRangeImpl::toString() const
             retStringBuf.append(tempString);
 
             if (fEndOffset >= 3999)
-                delete[] tempString;
+                XMLPlatformUtils::fgMemoryManager->deallocate(tempString);//delete[] tempString;
         }
     }
     return ((DOMDocumentImpl *)fDocument)->getPooledString(retStringBuf.getRawBuffer());
@@ -1284,7 +1293,10 @@ DOMDocumentFragment* DOMRangeImpl::traverseSameContainer( int how )
             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 @@ DOMDocumentFragment* DOMRangeImpl::traverseSameContainer( int how )
             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 @@ DOMNode* DOMRangeImpl::traverseTextNode( DOMNode*n, bool isLeft, int how )
             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 @@ DOMNode* DOMRangeImpl::traverseTextNode( DOMNode*n, bool isLeft, int how )
                 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 @@ DOMNode* DOMRangeImpl::traverseTextNode( DOMNode*n, bool isLeft, int how )
             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 @@ DOMNode* DOMRangeImpl::traverseTextNode( DOMNode*n, bool isLeft, int how )
             newNode->setNodeValue( ((DOMDocumentImpl *)fDocument)->getPooledString(newNodeValue) );
 
             if (offset>= 3999)
-                delete[] newNodeValue;
+                XMLPlatformUtils::fgMemoryManager->deallocate(newNodeValue);//delete[] newNodeValue;
 
         }
         return newNode;
@@ -1760,7 +1778,10 @@ DOMNode* DOMRangeImpl::traverseTextNode( DOMNode*n, bool isLeft, int how )
             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 @@ DOMNode* DOMRangeImpl::traverseTextNode( DOMNode*n, bool isLeft, int how )
                 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 @@ DOMNode* DOMRangeImpl::traverseTextNode( DOMNode*n, bool isLeft, int how )
             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 @@ DOMNode* DOMRangeImpl::traverseTextNode( DOMNode*n, bool isLeft, int how )
             newNode->setNodeValue( ((DOMDocumentImpl *)fDocument)->getPooledString(newNodeValue) );
 
             if (offset>= 3999)
-                delete[] newNodeValue;
+                XMLPlatformUtils::fgMemoryManager->deallocate(newNodeValue);//delete[] newNodeValue;
 
         }
         return newNode;
diff --git a/src/xercesc/dom/impl/DOMWriterImpl.cpp b/src/xercesc/dom/impl/DOMWriterImpl.cpp
index 89a9d8ab9..cfce2e586 100644
--- a/src/xercesc/dom/impl/DOMWriterImpl.cpp
+++ b/src/xercesc/dom/impl/DOMWriterImpl.cpp
@@ -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 @@ catch(TranscodingException const &e)                                 \
 
 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 @@ DOMWriterImpl::DOMWriterImpl()
 ,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 @@ bool DOMWriterImpl::getFeature(const XMLCh* const featName) const
 // 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 @@ const XMLCh* DOMWriterImpl::getEncoding() const
 
 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 @@ bool DOMWriterImpl::writeNode(XMLFormatTarget* const destination
 
     try
     {
-        fFormatter = new XMLFormatter(fEncodingUsed
+        fFormatter = new (fMemoryManager) XMLFormatter(fEncodingUsed
                                      ,fDocumentVersion
                                      ,destination
                                      ,XMLFormatter::NoEscapes
@@ -909,9 +913,9 @@ void DOMWriterImpl::processNode(const DOMNode* const nodeToWrite, int level)
             //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 @@ void DOMWriterImpl::processNode(const DOMNode* const nodeToWrite, int level)
                 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 @@ void DOMWriterImpl::procCdataSection(const XMLCh*   const nodeValue
      * 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;
diff --git a/src/xercesc/dom/impl/DOMWriterImpl.hpp b/src/xercesc/dom/impl/DOMWriterImpl.hpp
index 4df5b6c61..7a7efc821 100644
--- a/src/xercesc/dom/impl/DOMWriterImpl.hpp
+++ b/src/xercesc/dom/impl/DOMWriterImpl.hpp
@@ -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 @@ public:
     /**
      * Constructor.
      */
-    DOMWriterImpl();
+    DOMWriterImpl(MemoryManager* const manager);
 
     /**
      * Destructor.
@@ -487,6 +490,7 @@ private:
     int                           fCurrentLine;
 
     RefVectorOf< RefHashTableOf<XMLCh> >* fNamespaceStack;
+    MemoryManager*               fMemoryManager;
 };
 
 inline void DOMWriterImpl::setFeature(const int featureId
diff --git a/src/xercesc/framework/LocalFileFormatTarget.cpp b/src/xercesc/framework/LocalFileFormatTarget.cpp
index d80f7394f..620fbf482 100644
--- a/src/xercesc/framework/LocalFileFormatTarget.cpp
+++ b/src/xercesc/framework/LocalFileFormatTarget.cpp
@@ -57,6 +57,9 @@
 /*
  * $Id$
  * $Log$
+ * Revision 1.6  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.5  2003/01/24 20:20:22  tng
  * Add method flush to XMLFormatTarget
  *
@@ -76,7 +79,7 @@
  */
 
 #include <xercesc/framework/LocalFileFormatTarget.hpp>
-#include <xercesc/util/PlatformUtils.hpp>
+#include <xercesc/framework/MemoryManager.hpp>
 #include <xercesc/util/IOException.hpp>
 #include <string.h>
 
@@ -87,6 +90,7 @@ LocalFileFormatTarget::LocalFileFormatTarget(const XMLCh* const fileName)
 , fDataBuf(0)
 , fIndex(0)
 , fCapacity(1023)
+, fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
     fSource = XMLPlatformUtils::openFileToWrite(fileName);
 
@@ -94,7 +98,10 @@ LocalFileFormatTarget::LocalFileFormatTarget(const XMLCh* const fileName)
         ThrowXML1(IOException, XMLExcepts::File_CouldNotOpenFile, fileName);
 
     // Buffer is one larger than capacity, to allow for zero term
-    fDataBuf = new XMLByte[fCapacity+4];
+    fDataBuf = (XMLByte*) fMemoryManager->allocate
+    (
+        (fCapacity+4) * sizeof(XMLByte)
+    );//new XMLByte[fCapacity+4];
 
     // Keep it null terminated
     fDataBuf[0] = XMLByte(0);
@@ -106,6 +113,7 @@ LocalFileFormatTarget::LocalFileFormatTarget(const char* const fileName)
 , fDataBuf(0)
 , fIndex(0)
 , fCapacity(1023)
+, fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
     fSource = XMLPlatformUtils::openFileToWrite(fileName);
 
@@ -113,7 +121,10 @@ LocalFileFormatTarget::LocalFileFormatTarget(const char* const fileName)
         ThrowXML1(IOException, XMLExcepts::File_CouldNotOpenFile, fileName);
 
     // Buffer is one larger than capacity, to allow for zero term
-    fDataBuf = new XMLByte[fCapacity+4];
+    fDataBuf = (XMLByte*) fMemoryManager->allocate
+    (
+        (fCapacity+4) * sizeof(XMLByte)
+    );//new XMLByte[fCapacity+4];
 
     // Keep it null terminated
     fDataBuf[0] = XMLByte(0);
@@ -127,7 +138,7 @@ LocalFileFormatTarget::~LocalFileFormatTarget()
     if (fSource)
         XMLPlatformUtils::closeFile(fSource);
 
-    delete [] fDataBuf;
+    fMemoryManager->deallocate(fDataBuf);//delete [] fDataBuf;
 }
 
 void LocalFileFormatTarget::flush()
@@ -169,13 +180,16 @@ void LocalFileFormatTarget::insureCapacity(const unsigned int extraNeeded)
 
     // Oops, not enough room. Calc new capacity and allocate new buffer
     const unsigned int newCap = (unsigned int)((fIndex + extraNeeded) * 2);
-    XMLByte* newBuf = new XMLByte[newCap+4];
+    XMLByte* newBuf = (XMLByte*) fMemoryManager->allocate
+    (
+        (newCap+4) * sizeof(XMLByte)
+    );//new XMLByte[newCap+4];
 
     // Copy over the old stuff
     memcpy(newBuf, fDataBuf, fCapacity * sizeof(XMLByte) + 4);
 
     // Clean up old buffer and store new stuff
-    delete [] fDataBuf;
+    fMemoryManager->deallocate(fDataBuf); //delete [] fDataBuf;
     fDataBuf = newBuf;
     fCapacity = newCap;
 
diff --git a/src/xercesc/framework/LocalFileFormatTarget.hpp b/src/xercesc/framework/LocalFileFormatTarget.hpp
index cc45e7bcd..90c9b5c79 100644
--- a/src/xercesc/framework/LocalFileFormatTarget.hpp
+++ b/src/xercesc/framework/LocalFileFormatTarget.hpp
@@ -57,6 +57,9 @@
 /*
  * $Id$
  * $Log$
+ * Revision 1.5  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.4  2003/01/24 20:20:22  tng
  * Add method flush to XMLFormatTarget
  *
@@ -136,7 +139,7 @@ private:
     XMLByte*        fDataBuf;
     unsigned int    fIndex;
     unsigned int    fCapacity;
-
+    MemoryManager*  fMemoryManager;
 };
 
 
diff --git a/src/xercesc/framework/LocalFileInputSource.cpp b/src/xercesc/framework/LocalFileInputSource.cpp
index 1e09dc2a0..039b680f2 100644
--- a/src/xercesc/framework/LocalFileInputSource.cpp
+++ b/src/xercesc/framework/LocalFileInputSource.cpp
@@ -58,11 +58,11 @@
 // ---------------------------------------------------------------------------
 //  Includes
 // ---------------------------------------------------------------------------
+#include <xercesc/framework/LocalFileInputSource.hpp>
 #include <xercesc/util/BinFileInputStream.hpp>
 #include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/XMLString.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
-#include <xercesc/framework/LocalFileInputSource.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -131,14 +131,14 @@ LocalFileInputSource::LocalFileInputSource( const XMLCh* const basePath
     {
         XMLCh* tmpBuf = XMLPlatformUtils::weavePaths(basePath, relativePath);
         setSystemId(tmpBuf);
-        delete [] tmpBuf;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmpBuf); //delete [] tmpBuf;
     }
     else
     {
-        XMLCh* tmpBuf = XMLString::replicate(relativePath);
+        XMLCh* tmpBuf = XMLString::replicate(relativePath, getMemoryManager());
         XMLPlatformUtils::removeDotSlash(tmpBuf);
         setSystemId(tmpBuf);
-        delete [] tmpBuf;
+        getMemoryManager()->deallocate(tmpBuf);//delete [] tmpBuf;
     }
 
 }
@@ -153,11 +153,14 @@ LocalFileInputSource::LocalFileInputSource(const XMLCh* const filePath)
     //
     if (XMLPlatformUtils::isRelative(filePath))
     {
-        XMLCh* curDir = XMLPlatformUtils::getCurrentDirectory();
+        XMLCh* curDir = XMLPlatformUtils::getCurrentDirectory(getMemoryManager());
 
         int    curDirLen = XMLString::stringLen(curDir);
         int    filePathLen = XMLString::stringLen(filePath);
-        XMLCh* fullDir = new XMLCh [ curDirLen + filePathLen + 2];
+        XMLCh* fullDir = (XMLCh*) getMemoryManager()->allocate
+        (
+            (curDirLen + filePathLen + 2) * sizeof(XMLCh)
+        );//new XMLCh [ curDirLen + filePathLen + 2];
 
         XMLString::copyString(fullDir, curDir);
         fullDir[curDirLen] = chForwardSlash;
@@ -168,15 +171,15 @@ LocalFileInputSource::LocalFileInputSource(const XMLCh* const filePath)
 
         setSystemId(fullDir);
 
-        delete [] curDir;
-        delete [] fullDir;
+        getMemoryManager()->deallocate(curDir);//delete [] curDir;
+        getMemoryManager()->deallocate(fullDir);//delete [] fullDir;
     }
      else
     {
-        XMLCh* tmpBuf = XMLString::replicate(filePath);
+        XMLCh* tmpBuf = XMLString::replicate(filePath, getMemoryManager());
         XMLPlatformUtils::removeDotSlash(tmpBuf);
         setSystemId(tmpBuf);
-        delete [] tmpBuf;
+        getMemoryManager()->deallocate(tmpBuf);//delete [] tmpBuf;
     }
 
 }
@@ -191,7 +194,7 @@ LocalFileInputSource::~LocalFileInputSource()
 // ---------------------------------------------------------------------------
 BinInputStream* LocalFileInputSource::makeStream() const
 {
-    BinFileInputStream* retStrm = new BinFileInputStream(getSystemId());
+    BinFileInputStream* retStrm = new (getMemoryManager()) BinFileInputStream(getSystemId());
     if (!retStrm->getIsOpen())
     {
         delete retStrm;
diff --git a/src/xercesc/framework/MemBufFormatTarget.cpp b/src/xercesc/framework/MemBufFormatTarget.cpp
index 3ebb2462b..fe3c70121 100644
--- a/src/xercesc/framework/MemBufFormatTarget.cpp
+++ b/src/xercesc/framework/MemBufFormatTarget.cpp
@@ -57,6 +57,9 @@
 /*
  * $Id$
  * $Log$
+ * Revision 1.6  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.5  2002/11/04 15:00:21  tng
  * C++ Namespace Support.
  *
@@ -82,12 +85,16 @@
 XERCES_CPP_NAMESPACE_BEGIN
 
 MemBufFormatTarget::MemBufFormatTarget(int initCapacity)
-    : fDataBuf(0)
+    : fMemoryManager(XMLPlatformUtils::fgMemoryManager)
+    , fDataBuf(0)
     , fIndex(0)
     , fCapacity(initCapacity)
 {
     // Buffer is one larger than capacity, to allow for zero term
-    fDataBuf = new XMLByte[fCapacity+4];
+    fDataBuf = (XMLByte*) fMemoryManager->allocate
+    (
+        (fCapacity + 4) * sizeof(XMLByte)
+    );//new XMLByte[fCapacity+4];
 
     // Keep it null terminated
     fDataBuf[0] = XMLByte(0);
@@ -95,7 +102,7 @@ MemBufFormatTarget::MemBufFormatTarget(int initCapacity)
 
 MemBufFormatTarget::~MemBufFormatTarget()
 {
-    delete [] fDataBuf;
+    fMemoryManager->deallocate(fDataBuf);//delete [] fDataBuf;
 }
 
 void MemBufFormatTarget::writeChars(const XMLByte* const toWrite
@@ -140,13 +147,16 @@ void MemBufFormatTarget::insureCapacity(const unsigned int extraNeeded)
 
     // Oops, not enough room. Calc new capacity and allocate new buffer
     const unsigned int newCap = (unsigned int)((fIndex + extraNeeded) * 2);
-    XMLByte* newBuf = new XMLByte[newCap+4];
+    XMLByte* newBuf = (XMLByte*) fMemoryManager->allocate
+    (
+        (newCap+4) * sizeof(XMLByte)
+    );//new XMLByte[newCap+4];
 
     // Copy over the old stuff
     memcpy(newBuf, fDataBuf, fCapacity * sizeof(XMLByte) + 4);
 
     // Clean up old buffer and store new stuff
-    delete [] fDataBuf;
+    fMemoryManager->deallocate(fDataBuf); //delete [] fDataBuf;
     fDataBuf = newBuf;
     fCapacity = newCap;
 }
diff --git a/src/xercesc/framework/MemBufFormatTarget.hpp b/src/xercesc/framework/MemBufFormatTarget.hpp
index e402048b6..648306af0 100644
--- a/src/xercesc/framework/MemBufFormatTarget.hpp
+++ b/src/xercesc/framework/MemBufFormatTarget.hpp
@@ -57,6 +57,9 @@
 /*
  * $Id$
  * $Log$
+ * Revision 1.6  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.5  2002/11/04 15:00:21  tng
  * C++ Namespace Support.
  *
@@ -175,6 +178,7 @@ private:
     //      larger, to leave room for the null terminator.
     //
     // -----------------------------------------------------------------------
+    MemoryManager*  fMemoryManager;
     XMLByte*        fDataBuf;
     unsigned int    fIndex;
     unsigned int    fCapacity;
diff --git a/src/xercesc/framework/MemBufInputSource.cpp b/src/xercesc/framework/MemBufInputSource.cpp
index 92b9f1b35..b425adb99 100644
--- a/src/xercesc/framework/MemBufInputSource.cpp
+++ b/src/xercesc/framework/MemBufInputSource.cpp
@@ -56,6 +56,9 @@
 
 /**
  * $Log$
+ * Revision 1.3  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.2  2002/11/04 15:00:21  tng
  * C++ Namespace Support.
  *
@@ -130,7 +133,7 @@ BinInputStream* MemBufInputSource::makeStream() const
     //  fCopyBufToStream flag, we either tell it to copy the buffer or to
     //  just reference it.
     //
-    return new BinMemInputStream
+    return new (getMemoryManager()) BinMemInputStream
     (
         fSrcBytes
         , fByteCount
diff --git a/src/xercesc/framework/XMLAttDef.cpp b/src/xercesc/framework/XMLAttDef.cpp
index fd0af0cba..96f9cc98a 100644
--- a/src/xercesc/framework/XMLAttDef.cpp
+++ b/src/xercesc/framework/XMLAttDef.cpp
@@ -162,6 +162,7 @@ XMLAttDef::XMLAttDef(const  XMLAttDef::AttTypes     type
     , fId(XMLAttDef::fgInvalidAttrId)
     , fValue(0)
     , fEnumeration(0)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
 }
 
@@ -176,12 +177,14 @@ XMLAttDef::XMLAttDef(const  XMLCh* const            attrValue
     , fProvided(false)
     , fExternalAttribute(false)
     , fId(XMLAttDef::fgInvalidAttrId)
-    , fValue(XMLString::replicate(attrValue))
+    , fValue(0)
     , fEnumeration(0)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
     try
     {
-        fEnumeration = XMLString::replicate(enumValues);
+        fValue = XMLString::replicate(attrValue, fMemoryManager);
+        fEnumeration = XMLString::replicate(enumValues, fMemoryManager);
     }
     catch(...)
     {
@@ -196,10 +199,10 @@ XMLAttDef::XMLAttDef(const  XMLCh* const            attrValue
 void XMLAttDef::cleanUp()
 {
     if (fEnumeration)
-       XMLString::release(&fEnumeration);
+        fMemoryManager->deallocate(fEnumeration);
 
     if (fValue)
-        XMLString::release(&fValue);
+        fMemoryManager->deallocate(fValue);
 }
 
 XERCES_CPP_NAMESPACE_END
diff --git a/src/xercesc/framework/XMLAttDef.hpp b/src/xercesc/framework/XMLAttDef.hpp
index 2070b2dd6..e41d375d2 100644
--- a/src/xercesc/framework/XMLAttDef.hpp
+++ b/src/xercesc/framework/XMLAttDef.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.8  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.7  2003/04/21 20:46:01  knoaman
  * Use XMLString::release to prepare for configurable memory manager.
  *
@@ -125,7 +128,9 @@
 #if !defined(ATTDEF_HPP)
 #define ATTDEF_HPP
 
+#include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/XMLString.hpp>
+#include <xercesc/util/XMemory.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -149,7 +154,7 @@ class XMLAttr;
  *  enumerated or notation type, it will have an 'enumeration value' as well
  *  which is a space separated list of its possible vlaues.
  */
-class XMLPARSER_EXPORT XMLAttDef
+class XMLPARSER_EXPORT XMLAttDef : public XMemory
 {
 public:
     // -----------------------------------------------------------------------
@@ -389,6 +394,15 @@ public:
       */
     bool isExternal() const;
 
+    /** Get the plugged-in memory manager
+      *
+      * This method returns the plugged-in memory manager user for dynamic
+      * memory allocation/deallocation.
+      *
+      * @return the plugged-in memory manager
+      */
+    MemoryManager* getMemoryManager() const;
+
 
     /**
      * @return the uri part of DOM Level 3 TypeInfo
@@ -567,6 +581,7 @@ private :
     unsigned int    fId;
     XMLCh*          fValue;
     XMLCh*          fEnumeration;
+    MemoryManager*  fMemoryManager;
 };
 
 
@@ -613,6 +628,10 @@ inline bool XMLAttDef::isExternal() const
     return fExternalAttribute;
 }
 
+inline MemoryManager* XMLAttDef::getMemoryManager() const
+{
+    return fMemoryManager;
+}
 
 // ---------------------------------------------------------------------------
 //  XMLAttDef: Setter methods
@@ -625,9 +644,9 @@ inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)
 inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)
 {
     if (fEnumeration)
-        XMLString::release(&fEnumeration);
+        fMemoryManager->deallocate(fEnumeration);
 
-    fEnumeration = XMLString::replicate(newValue);
+    fEnumeration = XMLString::replicate(newValue, fMemoryManager);
 }
 
 inline void XMLAttDef::setId(const unsigned int newId)
@@ -648,9 +667,9 @@ inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)
 inline void XMLAttDef::setValue(const XMLCh* const newValue)
 {
     if (fValue)
-       XMLString::release(&fValue);
+       fMemoryManager->deallocate(fValue);
 
-    fValue = XMLString::replicate(newValue);
+    fValue = XMLString::replicate(newValue, fMemoryManager);
 }
 
 inline void
diff --git a/src/xercesc/framework/XMLAttDefList.hpp b/src/xercesc/framework/XMLAttDefList.hpp
index 449815ed3..5f93c026c 100644
--- a/src/xercesc/framework/XMLAttDefList.hpp
+++ b/src/xercesc/framework/XMLAttDefList.hpp
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.3  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.2  2002/11/04 15:00:21  tng
  * C++ Namespace Support.
  *
@@ -82,12 +85,12 @@
 #if !defined(XMLATTDEFLIST_HPP)
 #define XMLATTDEFLIST_HPP
 
-#include <xercesc/util/XMLEnumerator.hpp>
-#include <xercesc/util/XMLString.hpp>
-#include <xercesc/framework/XMLAttDef.hpp>
+#include <xercesc/util/XercesDefs.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
+class XMLAttDef;
+
 /**
  *  This class defines an abstract interface that all validators must support.
  *  When the scanner scans the attributes in a start tag, it must have a list
diff --git a/src/xercesc/framework/XMLAttr.cpp b/src/xercesc/framework/XMLAttr.cpp
index db5020845..4ade7edc0 100644
--- a/src/xercesc/framework/XMLAttr.cpp
+++ b/src/xercesc/framework/XMLAttr.cpp
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -62,24 +62,24 @@
 // ---------------------------------------------------------------------------
 //  Includes
 // ---------------------------------------------------------------------------
-#include <xercesc/util/XMLUniDefs.hpp>
-#include <xercesc/util/XMLUni.hpp>
-#include <xercesc/util/XMLString.hpp>
 #include <xercesc/framework/XMLAttr.hpp>
+#include <xercesc/framework/MemoryManager.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
 // ---------------------------------------------------------------------------
 //  XMLAttr: Constructors and Destructor
 // ---------------------------------------------------------------------------
-XMLAttr::XMLAttr() :
-      fType(XMLAttDef::CData)
-    , fValue(0)
+XMLAttr::XMLAttr(MemoryManager* const manager) :
+
+      fSpecified(false)
+    , fType(XMLAttDef::CData)
     , fValueBufSz(0)
-    , fSpecified(false)
+    , fValue(0)
     , fAttName(0)
+    , fMemoryManager(manager)
 {
-    fAttName = new QName();
+    fAttName = new (fMemoryManager) QName();
 }
 
 XMLAttr::XMLAttr(   const   unsigned int        uriId
@@ -87,12 +87,15 @@ XMLAttr::XMLAttr(   const   unsigned int        uriId
                     , const XMLCh* const        attrPrefix
                     , const XMLCh* const        attrValue
                     , const XMLAttDef::AttTypes type
-                    , const bool                specified) :
+                    , const bool                specified
+                    , MemoryManager* const      manager) :
 
-      fType(type)
-    , fValue(0)
+      fSpecified(specified)
+    , fType(type)
     , fValueBufSz(0)
-    , fSpecified(specified)
+    , fValue(0)
+    , fAttName(0)
+    , fMemoryManager(manager)
 {
     try
     {
@@ -100,10 +103,9 @@ XMLAttr::XMLAttr(   const   unsigned int        uriId
         //  Just call the local setters to set up everything. Too much
         //  work is required to replicate that functionality here.
         //
-        fAttName = new QName(attrPrefix, attrName, uriId);
+        fAttName = new (fMemoryManager) QName(attrPrefix, attrName, uriId);
         setValue(attrValue);
     }
-
     catch(...)
     {
         cleanUp();
@@ -114,21 +116,23 @@ XMLAttr::XMLAttr(   const   unsigned int        uriId
                     , const XMLCh* const        rawName
                     , const XMLCh* const        attrValue
                     , const XMLAttDef::AttTypes type
-                    , const bool                specified) :
+                    , const bool                specified
+                    , MemoryManager* const      manager) :
 
-      fType(type)
-    , fValue(0)
+      fSpecified(specified)
+    , fType(type)
     , fValueBufSz(0)
-    , fSpecified(specified)
+    , fValue(0)
+    , fAttName(0)
+    , fMemoryManager(manager)
 {
     try
     {
         //  Just call the local setters to set up everything. Too much
         //  work is required to replicate that functionality here.
-        fAttName = new QName(rawName, uriId);
+        fAttName = new (fMemoryManager) QName(rawName, uriId);
         setValue(attrValue);
     }
-
     catch(...)
     {
         cleanUp();
@@ -167,9 +171,9 @@ void XMLAttr::setValue(const XMLCh* const newValue)
     const unsigned int newLen = XMLString::stringLen(newValue);
     if (!fValueBufSz || (newLen > fValueBufSz))
     {
-        delete [] fValue;
+        fMemoryManager->deallocate(fValue); //delete [] fValue;
         fValueBufSz = newLen + 8;
-        fValue = new XMLCh[fValueBufSz + 1];
+        fValue = (XMLCh*) fMemoryManager->allocate((fValueBufSz+1) * sizeof(XMLCh)); //new XMLCh[fValueBufSz + 1];
     }
     XMLString::moveChars(fValue, newValue, newLen + 1);
 }
@@ -181,7 +185,7 @@ void XMLAttr::setValue(const XMLCh* const newValue)
 void XMLAttr::cleanUp()
 {
     delete fAttName;
-    delete [] fValue;
+    fMemoryManager->deallocate(fValue); //delete [] fValue;
 }
 
 XERCES_CPP_NAMESPACE_END
diff --git a/src/xercesc/framework/XMLAttr.hpp b/src/xercesc/framework/XMLAttr.hpp
index 130e1b320..41bc9f590 100644
--- a/src/xercesc/framework/XMLAttr.hpp
+++ b/src/xercesc/framework/XMLAttr.hpp
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.5  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.4  2002/11/28 20:12:45  knoaman
  * Allow creating/setting of XMLAttr using a rawname (i.e. 'prefix:localpart').
  *
@@ -106,7 +109,7 @@
 #if !defined(XMLATTR_HPP)
 #define XMLATTR_HPP
 
-#include <xercesc/util/XMLString.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/QName.hpp>
 #include <xercesc/framework/XMLAttDef.hpp>
 
@@ -133,7 +136,7 @@ XERCES_CPP_NAMESPACE_BEGIN
  *  string members unless it has to. It keeps up with how long each buffer
  *  is and only reallocates if the new value won't fit.
  */
-class XMLPARSER_EXPORT XMLAttr
+class XMLPARSER_EXPORT XMLAttr : public XMemory
 {
 public:
     // -----------------------------------------------------------------------
@@ -146,8 +149,10 @@ public:
       * The default constructor just setsup an empty attribute to be filled
       * in the later. Though the initial state is a reasonable one, it is
       * not documented because it should not be depended on.
+      *
+      * @param  manager     The configurable memory manager
       */
-    XMLAttr();
+    XMLAttr(MemoryManager* const manager);
 
     /**
       * This is the primary constructor which takes all of the information
@@ -174,15 +179,18 @@ public:
       * @param  specified   Indicates whether the attribute was explicitly
       *                     specified or not. If not, then it was faulted
       *                     in from a FIXED or DEFAULT value.
+      *
+      * @param  manager     The configurable memory manager
       */
     XMLAttr
     (
-        const   unsigned int        uriId
+          const unsigned int        uriId
         , const XMLCh* const        attrName
         , const XMLCh* const        attrPrefix
         , const XMLCh* const        attrValue
-        , const XMLAttDef::AttTypes type = XMLAttDef::CData
-        , const bool                specified = true
+        , const XMLAttDef::AttTypes type// = XMLAttDef::CData
+        , const bool                specified// = true
+        , MemoryManager* const      manager //= XMLPlatformUtils::fgMemoryManager
     );
 
     /**
@@ -206,14 +214,17 @@ public:
       * @param  specified   Indicates whether the attribute was explicitly
       *                     specified or not. If not, then it was faulted
       *                     in from a FIXED or DEFAULT value.
+      *
+      * @param  manager     The configurable memory manager
       */
     XMLAttr
     (
         const unsigned int uriId
         , const XMLCh* const rawName
         , const XMLCh* const attrValue
-        , const XMLAttDef::AttTypes type = XMLAttDef::CData
-        , const bool specified = true
+        , const XMLAttDef::AttTypes type// = XMLAttDef::CData
+        , const bool specified// = true
+        , MemoryManager* const manager //= XMLPlatformUtils::fgMemoryManager
     );
 
     //@}
@@ -446,12 +457,16 @@ private :
     //      The attribute value that was given in the attribute instance, and
     //      its current buffer size (minus one, where the null is.)
     //
+    //  fMemoryManager
+    //      The memory manager used for dynamic memory allocation/deallocation
+    //
     // -----------------------------------------------------------------------
     bool                fSpecified;
     XMLAttDef::AttTypes fType;
-    XMLCh*              fValue;
     unsigned int        fValueBufSz;
+    XMLCh*              fValue;
     QName*              fAttName;
+    MemoryManager*      fMemoryManager;
 };
 
 // ---------------------------------------------------------------------------
diff --git a/src/xercesc/framework/XMLBuffer.cpp b/src/xercesc/framework/XMLBuffer.cpp
index e8272a52b..813543e31 100644
--- a/src/xercesc/framework/XMLBuffer.cpp
+++ b/src/xercesc/framework/XMLBuffer.cpp
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -56,6 +56,9 @@
 
 /**
  * $Log$
+ * Revision 1.4  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.3  2002/11/04 15:00:21  tng
  * C++ Namespace Support.
  *
@@ -91,10 +94,8 @@
 // ---------------------------------------------------------------------------
 //  Includes
 // ---------------------------------------------------------------------------
-#include <xercesc/util/RuntimeException.hpp>
-#include <xercesc/util/XMLString.hpp>
 #include <xercesc/framework/XMLBuffer.hpp>
-#include <string.h>
+#include <xercesc/util/XMLString.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -131,13 +132,13 @@ void XMLBuffer::expand()
     unsigned int newCap = (unsigned int)(fCapacity * 1.5);
 
     // Allocate the new buffer
-    XMLCh* newBuf = new XMLCh[newCap + 1];
+    XMLCh* newBuf = (XMLCh*) fMemoryManager->allocate((newCap + 1) * sizeof(XMLCh)); //new XMLCh[newCap + 1];
 
     // Copy over the old stuff
     memcpy(newBuf, fBuffer, fCapacity * sizeof(XMLCh));
 
     // Clean up old buffer and store new stuff
-    delete [] fBuffer;
+    fMemoryManager->deallocate(fBuffer); //delete [] fBuffer;
     fBuffer = newBuf;
     fCapacity = newCap;
 }
@@ -150,13 +151,13 @@ void XMLBuffer::insureCapacity(const unsigned int extraNeeded)
 
     // Oops, not enough room. Calc new capacity and allocate new buffer
     const unsigned int newCap = (unsigned int)((fIndex + extraNeeded) * 2);
-    XMLCh* newBuf = new XMLCh[newCap+1];
+    XMLCh* newBuf = (XMLCh*) fMemoryManager->allocate((newCap+1) * sizeof(XMLCh)); //new XMLCh[newCap+1];
 
     // Copy over the old stuff
     memcpy(newBuf, fBuffer, fCapacity * sizeof(XMLCh));
 
     // Clean up old buffer and store new stuff
-    delete [] fBuffer;
+    fMemoryManager->deallocate(fBuffer); //delete [] fBuffer;
     fBuffer = newBuf;
     fCapacity = newCap;
 }
diff --git a/src/xercesc/framework/XMLBuffer.hpp b/src/xercesc/framework/XMLBuffer.hpp
index 3c170dff9..2d1289c73 100644
--- a/src/xercesc/framework/XMLBuffer.hpp
+++ b/src/xercesc/framework/XMLBuffer.hpp
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.4  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.3  2002/11/04 15:00:21  tng
  * C++ Namespace Support.
  *
@@ -94,7 +97,9 @@
 #if !defined(XMLBUFFER_HPP)
 #define XMLBUFFER_HPP
 
-#include <xercesc/util/XercesDefs.hpp>
+#include <xercesc/util/XMemory.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
+#include <xercesc/framework/MemoryManager.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -108,7 +113,7 @@ XERCES_CPP_NAMESPACE_BEGIN
  *  The buffer is not nul terminated until some asks to see the raw buffer
  *  contents. This also avoids overhead during append operations.
  */
-class XMLPARSER_EXPORT XMLBuffer
+ class XMLPARSER_EXPORT XMLBuffer : public XMemory
 {
 public :
     // -----------------------------------------------------------------------
@@ -117,15 +122,17 @@ public :
 
     /** @name Constructor */
     //@{
-    XMLBuffer(int capacity = 1023) :
+    XMLBuffer(int capacity = 1023,
+              MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) :
 
-        fBuffer(0)
+        fUsed(false)
         , fIndex(0)
         , fCapacity(capacity)
-        , fUsed(false)
+        , fMemoryManager(manager)
+        , fBuffer(0)
     {
         // Buffer is one larger than capacity, to allow for zero term
-        fBuffer = new XMLCh[fCapacity+1];
+        fBuffer = (XMLCh*) manager->allocate((capacity+1) * sizeof(XMLCh)); //new XMLCh[fCapacity+1];
 
         // Keep it null terminated
         fBuffer[0] = XMLCh(0);
@@ -136,7 +143,7 @@ public :
     //@{
     ~XMLBuffer()
     {
-        delete [] fBuffer;
+        fMemoryManager->deallocate(fBuffer); //delete [] fBuffer;
     }
     //@}
 
@@ -243,10 +250,11 @@ private :
     //  fUsed
     //      Indicates whether this buffer is in use or not.
     // -----------------------------------------------------------------------
-    XMLCh*          fBuffer;
+    bool            fUsed;
     unsigned int    fIndex;
     unsigned int    fCapacity;
-    bool            fUsed;
+    MemoryManager*  fMemoryManager;
+    XMLCh*          fBuffer;
 };
 
 XERCES_CPP_NAMESPACE_END
diff --git a/src/xercesc/framework/XMLBufferMgr.cpp b/src/xercesc/framework/XMLBufferMgr.cpp
index 39f68ae8e..45859eebf 100644
--- a/src/xercesc/framework/XMLBufferMgr.cpp
+++ b/src/xercesc/framework/XMLBufferMgr.cpp
@@ -56,6 +56,9 @@
 
 /**
  * $Log$
+ * Revision 1.3  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.2  2002/11/04 15:00:21  tng
  * C++ Namespace Support.
  *
@@ -85,23 +88,23 @@
 // ---------------------------------------------------------------------------
 //  Includes
 // ---------------------------------------------------------------------------
-#include <string.h>
-#include <xercesc/util/RuntimeException.hpp>
-#include <xercesc/framework/XMLBuffer.hpp>
+//#include <string.h>
 #include <xercesc/framework/XMLBufferMgr.hpp>
+#include <xercesc/util/RuntimeException.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
 // ---------------------------------------------------------------------------
 //  Constructors and Destructor
 // ---------------------------------------------------------------------------
-XMLBufferMgr::XMLBufferMgr() :
+XMLBufferMgr::XMLBufferMgr(MemoryManager* const manager) :
 
     fBufCount(32)
+    , fMemoryManager(manager)
     , fBufList(0)
 {
     // Allocate the buffer list and zero it out
-    fBufList = new XMLBuffer*[fBufCount];
+    fBufList = (XMLBuffer**) fMemoryManager->allocate(fBufCount * sizeof(XMLBuffer*)); // new XMLBuffer*[fBufCount];
     for (unsigned int index = 0; index < fBufCount; index++)
         fBufList[index] = 0;
 }
@@ -113,7 +116,7 @@ XMLBufferMgr::~XMLBufferMgr()
         delete fBufList[index];
 
     // And then the buffer list
-    delete [] fBufList;
+    fMemoryManager->deallocate(fBufList); //delete [] fBufList;
 }
 
 
@@ -131,7 +134,7 @@ XMLBuffer& XMLBufferMgr::bidOnBuffer()
         // No more buffers available, so create one and take it
         if (!fBufList[index])
         {
-            fBufList[index] = new XMLBuffer;
+            fBufList[index] = new (fMemoryManager) XMLBuffer(1023, fMemoryManager);
             fBufList[index]->setInUse(true);
             return *fBufList[index];
         }
diff --git a/src/xercesc/framework/XMLBufferMgr.hpp b/src/xercesc/framework/XMLBufferMgr.hpp
index b61de2102..e82065def 100644
--- a/src/xercesc/framework/XMLBufferMgr.hpp
+++ b/src/xercesc/framework/XMLBufferMgr.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.5  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.4  2002/12/04 02:32:43  knoaman
  * #include cleanup.
  *
@@ -108,7 +111,7 @@ class XMLBufBid;
  *  back into the pool. This provides a good compromise between performance
  *  and easier maintenance.
  */
-class XMLPARSER_EXPORT XMLBufferMgr
+class XMLPARSER_EXPORT XMLBufferMgr : public XMemory
 {
 public :
     // -----------------------------------------------------------------------
@@ -117,7 +120,7 @@ public :
 
     /** @name Constructor */
     //@{
-    XMLBufferMgr();
+    XMLBufferMgr(MemoryManager* const manager/* = XMLPlatformUtils::fgMemoryManager*/);
     //@}
 
     /** @name Destructor */
@@ -145,6 +148,7 @@ private :
     //      never be a lot of them, so a flat list is good enough.
     // -----------------------------------------------------------------------
     unsigned int    fBufCount;
+    MemoryManager*  fMemoryManager;
     XMLBuffer**     fBufList;
 };
 
@@ -154,7 +158,7 @@ private :
  *  for a buffer on a scoped basis and then insure that it gets freed back
  *  into the pool no matter how the scope is exited (exception or normal exit.)
  */
-class XMLBufBid
+class XMLBufBid : public XMemory
 {
 public :
     // -----------------------------------------------------------------------
diff --git a/src/xercesc/framework/XMLContentModel.hpp b/src/xercesc/framework/XMLContentModel.hpp
index 58922b981..041e097b3 100644
--- a/src/xercesc/framework/XMLContentModel.hpp
+++ b/src/xercesc/framework/XMLContentModel.hpp
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.4  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.3  2003/03/07 18:08:10  tng
  * Return a reference instead of void for operator=
  *
@@ -118,8 +121,7 @@
 #if !defined(CONTENTMODEL_HPP)
 #define CONTENTMODEL_HPP
 
-#include <xercesc/util/XercesDefs.hpp>
-#include <xercesc/util/RefVectorOf.hpp>
+#include <xercesc/util/XMemory.hpp>
 #include <xercesc/util/QName.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
@@ -139,7 +141,7 @@ class SchemaGrammar;
  *  the abstract API via which all the types of contents models are dealt
  *  with generically. Its pretty simple.
  */
-class XMLPARSER_EXPORT XMLContentModel
+class XMLPARSER_EXPORT XMLContentModel : public XMemory
 {
 public:
     // ---------------------------------------------------------------------------
diff --git a/src/xercesc/framework/XMLElementDecl.cpp b/src/xercesc/framework/XMLElementDecl.cpp
index afef91ec7..759320c72 100644
--- a/src/xercesc/framework/XMLElementDecl.cpp
+++ b/src/xercesc/framework/XMLElementDecl.cpp
@@ -62,9 +62,9 @@
 // ---------------------------------------------------------------------------
 //  Includes
 // ---------------------------------------------------------------------------
+#include <xercesc/framework/XMLElementDecl.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xercesc/util/XMLUni.hpp>
-#include <xercesc/framework/XMLElementDecl.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -100,7 +100,7 @@ XMLElementDecl::setElementName(const XMLCh* const       prefix
     if (fElementName)
         fElementName->setName(prefix, localPart, uriId);
     else
-        fElementName = new QName(prefix, localPart, uriId);
+        fElementName = new (fMemoryManager) QName(prefix, localPart, uriId);
 }
 
 void
@@ -110,7 +110,7 @@ XMLElementDecl::setElementName(const XMLCh* const       rawName
     if (fElementName)
         fElementName->setName(rawName, uriId);
     else
-        fElementName = new QName(rawName, uriId);
+        fElementName = new (fMemoryManager) QName(rawName, uriId);
 }
 
 void
@@ -119,18 +119,19 @@ XMLElementDecl::setElementName(const QName* const    elementName)
     if (fElementName)
         fElementName->setValues(*elementName);
     else
-        fElementName = new QName(*elementName);
+        fElementName = new (fMemoryManager) QName(*elementName);
 }
 
 // ---------------------------------------------------------------------------
 //  ElementDecl: Hidden constructors
 // ---------------------------------------------------------------------------
-XMLElementDecl::XMLElementDecl() :
+XMLElementDecl::XMLElementDecl(MemoryManager* const manager) :
 
-    fElementName(0)
+    fMemoryManager(manager)
+    , fElementName(0)
     , fCreateReason(XMLElementDecl::NoReason)
     , fId(XMLElementDecl::fgInvalidElemId)
-    , fExternalElement (false)
+    , fExternalElement(false)
 {
 }
 
diff --git a/src/xercesc/framework/XMLElementDecl.hpp b/src/xercesc/framework/XMLElementDecl.hpp
index 85d7b735b..2b87daa3d 100644
--- a/src/xercesc/framework/XMLElementDecl.hpp
+++ b/src/xercesc/framework/XMLElementDecl.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.6  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.5  2003/03/07 18:08:10  tng
  * Return a reference instead of void for operator=
  *
@@ -136,9 +139,10 @@
 #if !defined(XMLELEMENTDECL_HPP)
 #define XMLELEMENTDECL_HPP
 
-#include <xercesc/util/XMLString.hpp>
 #include <xercesc/framework/XMLAttr.hpp>
 #include <xercesc/framework/XMLAttDefList.hpp>
+#include <xercesc/util/XMLString.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -160,7 +164,7 @@ class XMLContentModel;
  *  with invalid or PCDATA element ids without having to know what type of
  *  validator its messing with.)
  */
-class XMLPARSER_EXPORT XMLElementDecl
+class XMLPARSER_EXPORT XMLElementDecl : public XMemory
 {
  public:
     // -----------------------------------------------------------------------
@@ -487,6 +491,15 @@ class XMLPARSER_EXPORT XMLElementDecl
 
     bool isExternal() const;
 
+    /** Get the memory manager
+      *
+      * This method returns the configurable memory manager used by the
+      * element declaration for dynamic allocation/deacllocation.
+      *
+      * @return the memory manager
+      */
+    MemoryManager* getMemoryManager() const;
+
     //@}
 
 
@@ -576,7 +589,7 @@ protected :
     // -----------------------------------------------------------------------
     //  Hidden constructors
     // -----------------------------------------------------------------------
-    XMLElementDecl();
+    XMLElementDecl(MemoryManager* const manager /*= XMLPlatformUtils::fgMemoryManager*/);
 
 private :
     // -----------------------------------------------------------------------
@@ -609,6 +622,7 @@ private :
     //  fExternalElement
     //      This flag indicates whether or the element was declared externally.
     // -----------------------------------------------------------------------
+    MemoryManager*      fMemoryManager;
     QName*              fElementName;
     CreateReasons       fCreateReason;
     unsigned int        fId;
@@ -670,6 +684,11 @@ inline bool XMLElementDecl::isExternal() const
     return fExternalElement;
 }
 
+inline MemoryManager* XMLElementDecl::getMemoryManager() const
+{
+    return fMemoryManager;
+}
+
 
 // ---------------------------------------------------------------------------
 //  XMLElementDecl: Setter methods
diff --git a/src/xercesc/framework/XMLEntityDecl.cpp b/src/xercesc/framework/XMLEntityDecl.cpp
index 6a042823c..368d496e8 100644
--- a/src/xercesc/framework/XMLEntityDecl.cpp
+++ b/src/xercesc/framework/XMLEntityDecl.cpp
@@ -81,6 +81,7 @@ XMLEntityDecl::XMLEntityDecl() :
     , fPublicId(0)
     , fSystemId(0)
     , fBaseURI(0)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
 }
 
@@ -89,28 +90,32 @@ XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName) :
     fId(0)
     , fValueLen(0)
     , fValue(0)
-    , fName(XMLString::replicate(entName))
+    , fName(0)
     , fNotationName(0)
     , fPublicId(0)
     , fSystemId(0)
     , fBaseURI(0)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
+    fName = XMLString::replicate(entName, fMemoryManager);
 }
 
 XMLEntityDecl::XMLEntityDecl(const  XMLCh* const    entName
                             , const XMLCh* const    value) :
     fId(0)
     , fValueLen(XMLString::stringLen(value))
-    , fValue(XMLString::replicate(value))
+    , fValue(0)
     , fName(0)
     , fNotationName(0)
     , fPublicId(0)
     , fSystemId(0)
     , fBaseURI(0)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
     try
     {
-        fName = XMLString::replicate(entName);
+        fValue = XMLString::replicate(value, fMemoryManager);
+        fName = XMLString::replicate(entName, fMemoryManager);
     }
     catch(...)
     {
@@ -123,17 +128,19 @@ XMLEntityDecl::XMLEntityDecl(const  XMLCh* const    entName
     fId(0)
     , fValueLen(1)
     , fValue(0)
-    , fName(XMLString::replicate(entName))
+    , fName(0)
     , fNotationName(0)
     , fPublicId(0)
     , fSystemId(0)
     , fBaseURI(0)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
     try
     {
         XMLCh dummy[2] = { chNull, chNull };
         dummy[0] = value;
-        fValue = XMLString::replicate(dummy);
+        fValue = XMLString::replicate(dummy, fMemoryManager);
+        fName = XMLString::replicate(entName, fMemoryManager);
     }
     catch(...)
     {
@@ -154,9 +161,9 @@ void XMLEntityDecl::setName(const XMLCh* const entName)
 {
     // Clean up the current name stuff
     if (fName)
-       XMLString::release(&fName);
+       fMemoryManager->deallocate(fName);
 
-    fName = XMLString::replicate(entName);
+    fName = XMLString::replicate(entName, fMemoryManager);
 }
 
 
@@ -165,12 +172,12 @@ void XMLEntityDecl::setName(const XMLCh* const entName)
 // ---------------------------------------------------------------------------
 void XMLEntityDecl::cleanUp()
 {
-    XMLString::release(&fName);
-    XMLString::release(&fNotationName);
-    XMLString::release(&fValue);
-    XMLString::release(&fPublicId);
-    XMLString::release(&fSystemId);
-    XMLString::release(&fBaseURI);
+    fMemoryManager->deallocate(fName);
+    fMemoryManager->deallocate(fNotationName);
+    fMemoryManager->deallocate(fValue);
+    fMemoryManager->deallocate(fPublicId);
+    fMemoryManager->deallocate(fSystemId);
+    fMemoryManager->deallocate(fBaseURI);
 }
 
 XERCES_CPP_NAMESPACE_END
diff --git a/src/xercesc/framework/XMLEntityDecl.hpp b/src/xercesc/framework/XMLEntityDecl.hpp
index 9511167cb..1c47d88f1 100644
--- a/src/xercesc/framework/XMLEntityDecl.hpp
+++ b/src/xercesc/framework/XMLEntityDecl.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.6  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.5  2003/04/21 20:46:01  knoaman
  * Use XMLString::release to prepare for configurable memory manager.
  *
@@ -97,6 +100,8 @@
 #if !defined(XMLENTITYDECL_HPP)
 #define XMLENTITYDECL_HPP
 
+#include <xercesc/util/XMemory.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/XMLString.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
@@ -119,7 +124,7 @@ XERCES_CPP_NAMESPACE_BEGIN
  *  or whatever, at which time they confirm the correctness of the data before
  *  creating the entity decl object.
  */
-class XMLPARSER_EXPORT XMLEntityDecl
+class XMLPARSER_EXPORT XMLEntityDecl : public XMemory
 {
 public:
     // -----------------------------------------------------------------------
@@ -282,6 +287,15 @@ public:
       */
     bool isUnparsed() const;
 
+    /** Get the plugged-in memory manager
+      *
+      * This method returns the plugged-in memory manager user for dynamic
+      * memory allocation/deallocation.
+      *
+      * @return the plugged-in memory manager
+      */
+    MemoryManager* getMemoryManager() const;
+
     //@}
 
 
@@ -423,6 +437,7 @@ private :
     XMLCh*          fPublicId;
     XMLCh*          fSystemId;
     XMLCh*          fBaseURI;
+    MemoryManager*  fMemoryManager;
 };
 
 
@@ -481,6 +496,10 @@ inline bool XMLEntityDecl::isUnparsed() const
     return (fNotationName != 0);
 }
 
+inline MemoryManager* XMLEntityDecl::getMemoryManager() const
+{
+    return fMemoryManager;
+}
 
 // ---------------------------------------------------------------------------
 //  XMLEntityDecl: Setter methods
@@ -493,41 +512,41 @@ inline void XMLEntityDecl::setId(const unsigned int newId)
 inline void XMLEntityDecl::setNotationName(const XMLCh* const newName)
 {
     if (fNotationName)
-        XMLString::release(&fNotationName);
+        fMemoryManager->deallocate(fNotationName);
 
-    fNotationName = XMLString::replicate(newName);
+    fNotationName = XMLString::replicate(newName, fMemoryManager);
 }
 
 inline void XMLEntityDecl::setPublicId(const XMLCh* const newId)
 {
     if (fPublicId)
-        XMLString::release(&fPublicId);
+        fMemoryManager->deallocate(fPublicId);
 
-    fPublicId = XMLString::replicate(newId);
+    fPublicId = XMLString::replicate(newId, fMemoryManager);
 }
 
 inline void XMLEntityDecl::setSystemId(const XMLCh* const newId)
 {
     if (fSystemId)
-        XMLString::release(&fSystemId);
+        fMemoryManager->deallocate(fSystemId);
 
-    fSystemId = XMLString::replicate(newId);
+    fSystemId = XMLString::replicate(newId, fMemoryManager);
 }
 
 inline void XMLEntityDecl::setBaseURI(const XMLCh* const newId)
 {
     if (fBaseURI)
-        XMLString::release(&fBaseURI);
+        fMemoryManager->deallocate(fBaseURI);
 
-    fBaseURI = XMLString::replicate(newId);
+    fBaseURI = XMLString::replicate(newId, fMemoryManager);
 }
 
 inline void XMLEntityDecl::setValue(const XMLCh* const newValue)
 {
     if (fValue)
-        XMLString::release(&fValue);
+        fMemoryManager->deallocate(fValue);
 
-    fValue = XMLString::replicate(newValue);
+    fValue = XMLString::replicate(newValue, fMemoryManager);
     fValueLen = XMLString::stringLen(newValue);
 }
 
diff --git a/src/xercesc/framework/XMLFormatter.cpp b/src/xercesc/framework/XMLFormatter.cpp
index 9ad2f99f4..4f3731e2d 100644
--- a/src/xercesc/framework/XMLFormatter.cpp
+++ b/src/xercesc/framework/XMLFormatter.cpp
@@ -199,9 +199,10 @@ XMLFormatter::XMLFormatter( const   char* const             outEncoding
     , fQuoteRef(0)
     , fQuoteLen(0) 
     , fIsXML11(false)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
     // Transcode the encoding string
-    fOutEncoding = XMLString::transcode(outEncoding);
+    fOutEncoding = XMLString::transcode(outEncoding, fMemoryManager);
 
     // Try to create a transcoder for this encoding
     XMLTransService::Codes resCode;
@@ -210,12 +211,12 @@ XMLFormatter::XMLFormatter( const   char* const             outEncoding
         fOutEncoding
         , resCode
         , kTmpBufSize
+        , fMemoryManager
     );
 
     if (!fXCoder)
     {
-        delete [] fOutEncoding;
-        fOutEncoding = 0;
+        fMemoryManager->deallocate(fOutEncoding); //delete [] fOutEncoding;
         ThrowXML1
         (
             TranscodingException
@@ -224,8 +225,8 @@ XMLFormatter::XMLFormatter( const   char* const             outEncoding
         );
     }
 
-    XMLCh* const tmpDocVer = XMLString::transcode(docVersion);
-    ArrayJanitor<XMLCh> jname(tmpDocVer);
+    XMLCh* const tmpDocVer = XMLString::transcode(docVersion, fMemoryManager);
+    ArrayJanitor<XMLCh> jname(tmpDocVer, fMemoryManager);
     fIsXML11 = XMLString::equals(tmpDocVer, XMLUni::fgVersion1_1);
 }
 
@@ -251,23 +252,20 @@ XMLFormatter::XMLFormatter( const   XMLCh* const            outEncoding
     , fQuoteRef(0)
     , fQuoteLen(0) 
     , fIsXML11(false)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
-    // Copy the encoding string
-    fOutEncoding = XMLString::replicate(outEncoding);
-
     // Try to create a transcoder for this encoding
     XMLTransService::Codes resCode;
     fXCoder = XMLPlatformUtils::fgTransService->makeNewTranscoderFor
     (
-        fOutEncoding
+        outEncoding
         , resCode
         , kTmpBufSize
+        , fMemoryManager
     );
 
     if (!fXCoder)
     {
-        delete [] fOutEncoding;
-        fOutEncoding = 0;
         ThrowXML1
         (
             TranscodingException
@@ -276,18 +274,21 @@ XMLFormatter::XMLFormatter( const   XMLCh* const            outEncoding
         );
     }
 
+    // Copy the encoding string
+    fOutEncoding = XMLString::replicate(outEncoding, fMemoryManager);
+
+
     fIsXML11 = XMLString::equals(docVersion, XMLUni::fgVersion1_1);
 }
 
 XMLFormatter::~XMLFormatter()
 {
-    delete [] fAposRef;
-    delete [] fAmpRef;
-    delete [] fGTRef;
-    delete [] fLTRef;
-    delete [] fQuoteRef;
-
-    delete [] fOutEncoding;
+    fMemoryManager->deallocate(fAposRef); //delete [] fAposRef;
+    fMemoryManager->deallocate(fAmpRef); //delete [] fAmpRef;
+    fMemoryManager->deallocate(fGTRef); //delete [] fGTRef;
+    fMemoryManager->deallocate(fLTRef); //delete [] fLTRef;
+    fMemoryManager->deallocate(fQuoteRef); //delete [] fQuoteRef;
+    fMemoryManager->deallocate(fOutEncoding); //delete [] fOutEncoding;
     delete fXCoder;
 
     // We DO NOT own the target object!
@@ -523,7 +524,10 @@ const XMLByte* XMLFormatter::getCharRef(unsigned int & count,
        fTmpBuf[outBytes + 2] = 0; 
        fTmpBuf[outBytes + 3] = 0;
 
-       ref = new XMLByte[outBytes + 4]; 
+       ref = (XMLByte*) fMemoryManager->allocate
+       (
+           (outBytes + 4) * sizeof(XMLByte)
+       );//new XMLByte[outBytes + 4]; 
        memcpy(ref, fTmpBuf, outBytes + 4); 
        count = outBytes; 
    }
diff --git a/src/xercesc/framework/XMLFormatter.hpp b/src/xercesc/framework/XMLFormatter.hpp
index 567ec164c..69b1d2d5d 100644
--- a/src/xercesc/framework/XMLFormatter.hpp
+++ b/src/xercesc/framework/XMLFormatter.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.13  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.12  2003/03/17 03:19:52  peiyongz
  * Bug#18051 memory leakage in XMLFormatter
  *
@@ -127,7 +130,7 @@
 #if !defined(XMLFORMATTER_HPP)
 #define XMLFORMATTER_HPP
 
-#include <xercesc/util/XercesDefs.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -143,7 +146,7 @@ class XMLTranscoder;
  *  A number of flags are provided to control whether various optional
  *  formatting operations are performed.
  */
-class XMLPARSER_EXPORT XMLFormatter
+class XMLPARSER_EXPORT XMLFormatter : public XMemory
 {
 public:
     // -----------------------------------------------------------------------
@@ -351,7 +354,8 @@ public:
      * @return return the transcoder used internally for transcoding the formatter conent
      */
     inline const XMLTranscoder*   getTranscoder() const;
-    //@}
+
+   //@}
 
     // -----------------------------------------------------------------------
     //  Setter methods
@@ -484,7 +488,6 @@ private :
     UnRepFlags                  fUnRepFlags;
     XMLTranscoder*              fXCoder;
     XMLByte                     fTmpBuf[kTmpBufSize + 4];
-
     XMLByte*                    fAposRef;
     unsigned int                fAposLen;
     XMLByte*                    fAmpRef;
@@ -495,13 +498,12 @@ private :
     unsigned int                fLTLen;
     XMLByte*                    fQuoteRef;
     unsigned int                fQuoteLen;
-
     bool                        fIsXML11;
-
+    MemoryManager*              fMemoryManager;
 };
 
 
-class XMLPARSER_EXPORT XMLFormatTarget
+class XMLPARSER_EXPORT XMLFormatTarget : public XMemory
 {
 public:
     // -----------------------------------------------------------------------
diff --git a/src/xercesc/framework/XMLNotationDecl.cpp b/src/xercesc/framework/XMLNotationDecl.cpp
index 1d0baf98a..646a00a20 100644
--- a/src/xercesc/framework/XMLNotationDecl.cpp
+++ b/src/xercesc/framework/XMLNotationDecl.cpp
@@ -56,6 +56,9 @@
 
 /**
  * $Log$
+ * Revision 1.5  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.4  2003/04/21 20:46:01  knoaman
  * Use XMLString::release to prepare for configurable memory manager.
  *
@@ -97,6 +100,7 @@ XMLNotationDecl::XMLNotationDecl() :
     , fPublicId(0)
     , fSystemId(0)
     , fBaseURI(0)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
 }
 
@@ -105,16 +109,18 @@ XMLNotationDecl::XMLNotationDecl(   const   XMLCh* const    notName
                                     , const XMLCh* const    sysId
                                     , const XMLCh* const    baseURI) :
     fId(0)
-    , fName(XMLString::replicate(notName))
+    , fName(0)
     , fPublicId(0)
     , fSystemId(0)
     , fBaseURI(0)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
     try
     {
-        fPublicId = XMLString::replicate(pubId);
-        fSystemId = XMLString::replicate(sysId);
-        fBaseURI  = XMLString::replicate(baseURI);
+        fName = XMLString::replicate(notName, fMemoryManager);
+        fPublicId = XMLString::replicate(pubId, fMemoryManager);
+        fSystemId = XMLString::replicate(sysId, fMemoryManager);
+        fBaseURI  = XMLString::replicate(baseURI, fMemoryManager);
     }
     catch(...)
     {
@@ -135,9 +141,9 @@ void XMLNotationDecl::setName(const XMLCh* const notName)
 {
     // Clean up the current name stuff and replicate the passed name
     if (fName)
-        XMLString::release(&fName);
+        fMemoryManager->deallocate(fName);
 
-    fName = XMLString::replicate(notName);
+    fName = XMLString::replicate(notName, fMemoryManager);
 }
 
 
@@ -147,10 +153,10 @@ void XMLNotationDecl::setName(const XMLCh* const notName)
 // ---------------------------------------------------------------------------
 void XMLNotationDecl::cleanUp()
 {
-    XMLString::release(&fName);
-    XMLString::release(&fPublicId);
-    XMLString::release(&fSystemId);
-    XMLString::release(&fBaseURI);
+    fMemoryManager->deallocate(fName);
+    fMemoryManager->deallocate(fPublicId);
+    fMemoryManager->deallocate(fSystemId);
+    fMemoryManager->deallocate(fBaseURI);
 }
 
 XERCES_CPP_NAMESPACE_END
diff --git a/src/xercesc/framework/XMLNotationDecl.hpp b/src/xercesc/framework/XMLNotationDecl.hpp
index 3e676952d..12120b9b6 100644
--- a/src/xercesc/framework/XMLNotationDecl.hpp
+++ b/src/xercesc/framework/XMLNotationDecl.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.6  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.5  2003/04/21 20:46:01  knoaman
  * Use XMLString::release to prepare for configurable memory manager.
  *
@@ -96,6 +99,8 @@
 #if !defined(XMLNOTATIONDECL_HPP)
 #define XMLNOTATIONDECL_HPP
 
+#include <xercesc/util/XMemory.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/XMLString.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
@@ -109,7 +114,7 @@ XERCES_CPP_NAMESPACE_BEGIN
  *  At this common level, the information supported is the notation name
  *  and the public and sysetm ids indicated in the notation declaration.
  */
-class XMLPARSER_EXPORT XMLNotationDecl
+class XMLPARSER_EXPORT XMLNotationDecl : public XMemory
 {
 public:
     // -----------------------------------------------------------------------
@@ -142,6 +147,7 @@ public:
     const XMLCh* getPublicId() const;
     const XMLCh* getSystemId() const;
     const XMLCh* getBaseURI() const;
+    MemoryManager* getMemoryManager() const;
 
 
     // -----------------------------------------------------------------------
@@ -201,6 +207,7 @@ private :
     XMLCh*          fPublicId;
     XMLCh*          fSystemId;
     XMLCh*          fBaseURI;
+    MemoryManager*  fMemoryManager;
 };
 
 
@@ -232,6 +239,10 @@ inline const XMLCh* XMLNotationDecl::getBaseURI() const
     return fBaseURI;
 }
 
+inline MemoryManager* XMLNotationDecl::getMemoryManager() const
+{
+    return fMemoryManager;
+}
 
 // -----------------------------------------------------------------------
 //  Setter methods
@@ -244,25 +255,25 @@ inline void XMLNotationDecl::setId(const unsigned int newId)
 inline void XMLNotationDecl::setPublicId(const XMLCh* const newId)
 {
     if (fPublicId)
-        XMLString::release(&fPublicId);
+        fMemoryManager->deallocate(fPublicId);
 
-    fPublicId = XMLString::replicate(newId);
+    fPublicId = XMLString::replicate(newId, fMemoryManager);
 }
 
 inline void XMLNotationDecl::setSystemId(const XMLCh* const newId)
 {
     if (fSystemId)
-        XMLString::release(&fSystemId);
+        fMemoryManager->deallocate(fSystemId);
 
-    fSystemId = XMLString::replicate(newId);
+    fSystemId = XMLString::replicate(newId, fMemoryManager);
 }
 
 inline void XMLNotationDecl::setBaseURI(const XMLCh* const newId)
 {
     if (fBaseURI)
-        XMLString::release(&fBaseURI);
+        fMemoryManager->deallocate(fBaseURI);
 
-    fBaseURI = XMLString::replicate(newId);
+    fBaseURI = XMLString::replicate(newId, fMemoryManager);
 }
 
 
diff --git a/src/xercesc/framework/XMLPScanToken.hpp b/src/xercesc/framework/XMLPScanToken.hpp
index 9b0a16ccc..45a3c3e04 100644
--- a/src/xercesc/framework/XMLPScanToken.hpp
+++ b/src/xercesc/framework/XMLPScanToken.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.3  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.2  2002/11/04 15:00:21  tng
  * C++ Namespace Support.
  *
@@ -83,7 +86,7 @@
 #if !defined(XMLPSCANTOKEN_HPP)
 #define XMLPSCANTOKEN_HPP
 
-#include <xercesc/util/XercesDefs.hpp>
+#include <xercesc/util/XMemory.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -99,7 +102,7 @@ class XMLScanner;
  *  progressive parse is begun, and which is passed back in on each subsequent
  *  call of the progressive parse.
  */
-class XMLPARSER_EXPORT XMLPScanToken
+class XMLPARSER_EXPORT XMLPScanToken : public XMemory
 {
 public :
     // -----------------------------------------------------------------------
diff --git a/src/xercesc/framework/XMLRecognizer.cpp b/src/xercesc/framework/XMLRecognizer.cpp
index 5a854191a..68507fc56 100644
--- a/src/xercesc/framework/XMLRecognizer.cpp
+++ b/src/xercesc/framework/XMLRecognizer.cpp
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -62,11 +62,9 @@
 // ---------------------------------------------------------------------------
 //  Includes
 // ---------------------------------------------------------------------------
+#include <xercesc/framework/XMLRecognizer.hpp>
 #include <xercesc/util/RuntimeException.hpp>
 #include <xercesc/util/XMLString.hpp>
-#include <xercesc/util/XMLUni.hpp>
-#include <xercesc/framework/XMLRecognizer.hpp>
-#include <string.h>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
diff --git a/src/xercesc/framework/XMLRefInfo.hpp b/src/xercesc/framework/XMLRefInfo.hpp
index 1c560a9fe..0bc62bb9a 100644
--- a/src/xercesc/framework/XMLRefInfo.hpp
+++ b/src/xercesc/framework/XMLRefInfo.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.6  2003/05/15 18:26:07  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.5  2003/04/21 20:46:01  knoaman
  * Use XMLString::release to prepare for configurable memory manager.
  *
@@ -95,6 +98,8 @@
 #if !defined(XMLIDREFINFO_HPP)
 #define XMLIDREFINFO_HPP
 
+#include <xercesc/util/XMemory.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/XMLString.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
@@ -113,7 +118,7 @@ XERCES_CPP_NAMESPACE_BEGIN
  *  not enabled/supported by the validator, or it will be in the form
  *  {url}name if namespace processing is enabled.
  */
-class XMLPARSER_EXPORT XMLRefInfo
+class XMLPARSER_EXPORT XMLRefInfo : public XMemory
 {
 public :
     // -----------------------------------------------------------------------
@@ -178,6 +183,7 @@ private :
     bool        fDeclared;
     bool        fUsed;
     XMLCh*      fRefName;
+    MemoryManager* fMemoryManager;
 };
 
 
@@ -189,13 +195,15 @@ inline XMLRefInfo::XMLRefInfo(  const   XMLCh* const    refName
                                 , const bool            used) :
     fDeclared(declared)
     , fUsed(used)
-    , fRefName(XMLString::replicate(refName))
+    , fRefName(0)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
+    fRefName = XMLString::replicate(refName, fMemoryManager);
 }
 
 inline XMLRefInfo::~XMLRefInfo()
 {
-    XMLString::release(&fRefName);
+    fMemoryManager->deallocate(fRefName);
 }
 
 
diff --git a/src/xercesc/framework/XMLValidator.cpp b/src/xercesc/framework/XMLValidator.cpp
index 52ae40687..0615a538c 100644
--- a/src/xercesc/framework/XMLValidator.cpp
+++ b/src/xercesc/framework/XMLValidator.cpp
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -56,6 +56,9 @@
 
 /**
   * $Log$
+  * Revision 1.4  2003/05/15 18:26:07  knoaman
+  * Partial implementation of the configurable memory manager.
+  *
   * Revision 1.3  2003/03/09 16:38:04  peiyongz
   * PanicHandler
   *
@@ -122,14 +125,11 @@
 // ---------------------------------------------------------------------------
 //  Includes
 // ---------------------------------------------------------------------------
-#include <xercesc/util/Janitor.hpp>
+#include <xercesc/framework/XMLValidator.hpp>
 #include <xercesc/util/Mutexes.hpp>
 #include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/XMLMsgLoader.hpp>
-#include <xercesc/util/XMLString.hpp>
 #include <xercesc/util/XMLRegisterCleanup.hpp>
-#include <xercesc/framework/XMLErrorReporter.hpp>
-#include <xercesc/framework/XMLValidator.hpp>
 #include <xercesc/internal/XMLScanner.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
diff --git a/src/xercesc/framework/XMLValidator.hpp b/src/xercesc/framework/XMLValidator.hpp
index 010bb2758..bfc43c258 100644
--- a/src/xercesc/framework/XMLValidator.hpp
+++ b/src/xercesc/framework/XMLValidator.hpp
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
+ * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -56,6 +56,9 @@
 
  /*
   * $Log$
+  * Revision 1.9  2003/05/15 18:26:07  knoaman
+  * Partial implementation of the configurable memory manager.
+  *
   * Revision 1.8  2003/03/07 18:08:10  tng
   * Return a reference instead of void for operator=
   *
@@ -147,20 +150,14 @@
 #if !defined(XMLVALIDATOR_HPP)
 #define XMLVALIDATOR_HPP
 
-#include <xercesc/util/XercesDefs.hpp>
 #include <xercesc/framework/XMLAttr.hpp>
 #include <xercesc/framework/XMLValidityCodes.hpp>
-#include <xercesc/framework/XMLRefInfo.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
 class ReaderMgr;
-class XMLBuffer;
 class XMLBufferMgr;
 class XMLElementDecl;
-class XMLEntityHandler;
-class XMLErrorReporter;
-class XMLMsgLoader;
 class XMLScanner;
 class Grammar;
 
@@ -180,7 +177,7 @@ class Grammar;
  *  via the base decl classes, from which each validator derives its own
  *  decl classes.
  */
-class XMLPARSER_EXPORT XMLValidator
+class XMLPARSER_EXPORT XMLValidator : public XMemory
 {
 public:
     // -----------------------------------------------------------------------
@@ -501,7 +498,6 @@ private :
     XMLErrorReporter*   fErrorReporter;
     ReaderMgr*          fReaderMgr;
     XMLScanner*         fScanner;
-
 };
 
 
diff --git a/src/xercesc/internal/DGXMLScanner.cpp b/src/xercesc/internal/DGXMLScanner.cpp
index d446db420..100eaf995 100644
--- a/src/xercesc/internal/DGXMLScanner.cpp
+++ b/src/xercesc/internal/DGXMLScanner.cpp
@@ -82,9 +82,9 @@ XERCES_CPP_NAMESPACE_BEGIN
 // ---------------------------------------------------------------------------
 //  DGXMLScanner: Constructors and Destructor
 // ---------------------------------------------------------------------------
-DGXMLScanner::DGXMLScanner(XMLValidator* const valToAdopt) :
+DGXMLScanner::DGXMLScanner(XMLValidator* const valToAdopt, MemoryManager* const manager) :
 
-    XMLScanner(valToAdopt)
+    XMLScanner(valToAdopt, manager)
     , fAttrNSList(0)
     , fDTDValidator(0)
     , fDTDGrammar(0)
@@ -110,13 +110,14 @@ DGXMLScanner::DGXMLScanner(XMLValidator* const valToAdopt) :
     }
 }
 
-DGXMLScanner::DGXMLScanner( XMLDocumentHandler* const  docHandler
-                            , DocTypeHandler* const    docTypeHandler
-                            , XMLEntityHandler* const  entityHandler
-                            , XMLErrorReporter* const  errHandler
-                            , XMLValidator* const      valToAdopt) :
+DGXMLScanner::DGXMLScanner( XMLDocumentHandler* const docHandler
+                          , DocTypeHandler* const     docTypeHandler
+                          , XMLEntityHandler* const   entityHandler
+                          , XMLErrorReporter* const   errHandler
+                          , XMLValidator* const       valToAdopt
+                          , MemoryManager* const      manager) :
 
-    XMLScanner(docHandler, docTypeHandler, entityHandler, errHandler, valToAdopt)
+    XMLScanner(docHandler, docTypeHandler, entityHandler, errHandler, valToAdopt, manager)
     , fAttrNSList(0)
     , fDTDValidator(0)
     , fDTDGrammar(0)
@@ -764,7 +765,13 @@ void DGXMLScanner::scanDocTypeDecl()
     //
     //  Only do this if we are not reusing the validator! If we are reusing,
     //  then look it up instead. It has to exist!
-    DTDElementDecl* rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(), fEmptyNamespaceId);
+    DTDElementDecl* rootDecl = new (fMemoryManager) DTDElementDecl
+    (
+        bbRootName.getRawBuffer()
+        , fEmptyNamespaceId
+        , DTDElementDecl::Any
+        , fMemoryManager
+    );
 
     rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
     rootDecl->setExternalElemDeclaration(true);
@@ -794,7 +801,12 @@ void DGXMLScanner::scanDocTypeDecl()
     XMLCh*  sysId = 0;
     XMLCh*  pubId = 0;
 
-    DTDScanner dtdScanner((DTDGrammar*)fGrammar, fDocTypeHandler);
+    DTDScanner dtdScanner
+    (
+        (DTDGrammar*) fGrammar
+        , fDocTypeHandler
+        , fMemoryManager
+    );
     dtdScanner.setScannerInfo(this, &fReaderMgr, &fBufMgr);
 
     //  If the next character is '[' then we have no external subset cause
@@ -824,8 +836,8 @@ void DGXMLScanner::scanDocTypeDecl()
         }
 
         // Get copies of the ids we got
-        pubId = XMLString::replicate(bbPubId.getRawBuffer());
-        sysId = XMLString::replicate(bbSysId.getRawBuffer());
+        pubId = XMLString::replicate(bbPubId.getRawBuffer(), fMemoryManager);
+        sysId = XMLString::replicate(bbSysId.getRawBuffer(), fMemoryManager);
 
         // Skip spaces and check again for the opening of an internal subset
         fReaderMgr.skipPastSpaces();
@@ -837,8 +849,8 @@ void DGXMLScanner::scanDocTypeDecl()
     }
 
     // Insure that the ids get cleaned up, if they got allocated
-    ArrayJanitor<XMLCh> janSysId(sysId);
-    ArrayJanitor<XMLCh> janPubId(pubId);
+    ArrayJanitor<XMLCh> janSysId(sysId, fMemoryManager);
+    ArrayJanitor<XMLCh> janPubId(pubId, fMemoryManager);
 
     //  If we have a doc type handler and advanced callbacks are enabled,
     //  call the doctype event.
@@ -915,7 +927,13 @@ void DGXMLScanner::scanDocTypeDecl()
                 if (rootDecl)
                     ((DTDGrammar*)fGrammar)->setRootElemId(rootDecl->getId());
                 else {
-                    rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(), fEmptyNamespaceId);
+                    rootDecl = new (fMemoryManager) DTDElementDecl
+                    (
+                        bbRootName.getRawBuffer()
+                        , fEmptyNamespaceId
+                        , DTDElementDecl::Any
+                        , fMemoryManager
+                    );
                     rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
                     rootDecl->setExternalElemDeclaration(true);
                     ((DTDGrammar*)fGrammar)->setRootElemId(fGrammar->putElemDecl(rootDecl));
@@ -963,7 +981,7 @@ void DGXMLScanner::scanDocTypeDecl()
             //  with an external entity. Put a janitor on it to insure it gets
             //  cleaned up. The reader manager does not adopt them.
             const XMLCh gDTDStr[] = { chLatin_D, chLatin_T, chLatin_D , chNull };
-            DTDEntityDecl* declDTD = new DTDEntityDecl(gDTDStr);
+            DTDEntityDecl* declDTD = new (fMemoryManager) DTDEntityDecl(gDTDStr);
             declDTD->setSystemId(sysId);
             Janitor<DTDEntityDecl> janDecl(declDTD);
 
@@ -1311,18 +1329,19 @@ bool DGXMLScanner::scanStartTag(bool& gotData)
             if (attCount >= curAttListSize)
             {
                 if (fDoNamespaces) {
-                    curAtt = new XMLAttr
+                    curAtt = new (fMemoryManager) XMLAttr
                     (
                         fEmptyNamespaceId
                         , fAttNameBuf.getRawBuffer()
                         , fAttValueBuf.getRawBuffer()
                         , attDef->getType()
                         , true
+                        , fMemoryManager
                     );
                 }
                 else
                 {
-                    curAtt = new XMLAttr
+                    curAtt = new (fMemoryManager) XMLAttr
                     (
                         -1
                         , fAttNameBuf.getRawBuffer()
@@ -1330,6 +1349,7 @@ bool DGXMLScanner::scanStartTag(bool& gotData)
                         , fAttValueBuf.getRawBuffer()
                         , attDef->getType()
                         , true
+                        , fMemoryManager
                     );
                 }
                 fAttrList->addElement(curAtt);
@@ -1653,7 +1673,7 @@ Grammar* DGXMLScanner::loadDTDGrammar(const InputSource& src,
     if (fValidatorFromUser)
         fValidator->reset();
 
-    fDTDGrammar = new DTDGrammar();
+    fDTDGrammar = new (fMemoryManager) DTDGrammar(fMemoryManager);
     fGrammarResolver->putGrammar(XMLUni::fgDTDEntityString, fDTDGrammar);
     fGrammar = fDTDGrammar;
     fValidator->setGrammar(fGrammar);
@@ -1703,7 +1723,7 @@ Grammar* DGXMLScanner::loadDTDGrammar(const InputSource& src,
     //  with an external entity. Put a janitor on it to insure it gets
     //  cleaned up. The reader manager does not adopt them.
     const XMLCh gDTDStr[] = { chLatin_D, chLatin_T, chLatin_D , chNull };
-    DTDEntityDecl* declDTD = new DTDEntityDecl(gDTDStr);
+    DTDEntityDecl* declDTD = new (fMemoryManager) DTDEntityDecl(gDTDStr);
     declDTD->setSystemId(src.getSystemId());
     Janitor<DTDEntityDecl> janDecl(declDTD);
 
@@ -1718,7 +1738,13 @@ Grammar* DGXMLScanner::loadDTDGrammar(const InputSource& src,
     if (fDocTypeHandler) {
 
         // Create a dummy root
-        DTDElementDecl* rootDecl = new DTDElementDecl(gDTDStr, fEmptyNamespaceId);
+        DTDElementDecl* rootDecl = new (fMemoryManager) DTDElementDecl
+        (
+            gDTDStr
+            , fEmptyNamespaceId
+            , DTDElementDecl::Any
+            , fMemoryManager
+        );
         rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
         rootDecl->setExternalElemDeclaration(true);
         Janitor<DTDElementDecl> janSrc(rootDecl);
@@ -1727,7 +1753,12 @@ Grammar* DGXMLScanner::loadDTDGrammar(const InputSource& src,
     }
 
     // Create DTDScanner
-    DTDScanner dtdScanner((DTDGrammar*)fGrammar, fDocTypeHandler);
+    DTDScanner dtdScanner
+    (
+        (DTDGrammar*)fGrammar
+        , fDocTypeHandler
+        , fMemoryManager
+    );
     dtdScanner.setScannerInfo(this, &fReaderMgr, &fBufMgr);
 
     // Tell it its not in an include section
@@ -1755,10 +1786,10 @@ void DGXMLScanner::commonInit()
 
     //  And we need one for the raw attribute scan. This just stores key/
     //  value string pairs (prior to any processing.)
-    fAttrNSList = new ValueVectorOf<XMLAttr*>(8);
+    fAttrNSList = new (fMemoryManager) ValueVectorOf<XMLAttr*>(8);
 
     //  Create the Validator and init them
-    fDTDValidator = new DTDValidator();
+    fDTDValidator = new (fMemoryManager) DTDValidator();
     initValidator(fDTDValidator);
 }
 
@@ -1858,7 +1889,7 @@ DGXMLScanner::buildAttList(const unsigned int           attCount
                     {
                         if (fDoNamespaces)
                         {
-                            curAtt = new XMLAttr
+                            curAtt = new (fMemoryManager) XMLAttr
                             (
                                 -1
                                 , curDef.getFullName()
@@ -1866,11 +1897,12 @@ DGXMLScanner::buildAttList(const unsigned int           attCount
                                 , curDef.getValue()
                                 , curDef.getType()
                                 , false
+                                , fMemoryManager
                             );
                         }
                         else
                         {
-                            curAtt = new XMLAttr
+                            curAtt = new (fMemoryManager) XMLAttr
                             (
                                 -1
                                 , curDef.getFullName()
@@ -1878,6 +1910,7 @@ DGXMLScanner::buildAttList(const unsigned int           attCount
                                 , curDef.getValue()
                                 , curDef.getType()
                                 , false
+                                , fMemoryManager
                             );
                         }
 
@@ -1994,7 +2027,7 @@ void DGXMLScanner::scanReset(const InputSource& src)
     fGrammarResolver->cacheGrammarFromParse(fToCacheGrammar);
     fGrammarResolver->useCachedGrammarInParse(fUseCachedGrammar);
 
-    fDTDGrammar = new DTDGrammar();
+    fDTDGrammar = new (fMemoryManager) DTDGrammar(fMemoryManager);
     fGrammarResolver->putGrammar(XMLUni::fgDTDEntityString, fDTDGrammar);
     fGrammar = fDTDGrammar;
     fRootGrammar = 0;
@@ -2016,7 +2049,7 @@ void DGXMLScanner::scanReset(const InputSource& src)
     fIDRefList->removeAll();
 
     // Reset the Root Element Name
-    delete [] fRootElemName;
+    fMemoryManager->deallocate(fRootElemName);//delete [] fRootElemName;
     fRootElemName = 0;
 
     //  Reset the element stack, and give it the latest ids for the special
@@ -2283,14 +2316,14 @@ InputSource* DGXMLScanner::resolveSystemId(const XMLCh* const sysId)
             else {
                 if (fStandardUriConformant && urlTmp.hasInvalidChar())
                     ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
-                srcToFill = new URLInputSource(urlTmp);
+                srcToFill = new (fMemoryManager) URLInputSource(urlTmp);
             }
         }
         catch(const MalformedURLException& e)
         {
             // Its not a URL, so lets assume its a local file name if non-standard uri is allowed
             if (!fStandardUriConformant)
-                srcToFill = new LocalFileInputSource
+                srcToFill = new (fMemoryManager) LocalFileInputSource
                 (
                     lastInfo.systemId
                     , expSysId.getRawBuffer()
diff --git a/src/xercesc/internal/DGXMLScanner.hpp b/src/xercesc/internal/DGXMLScanner.hpp
index 4fc194718..a5168afd0 100644
--- a/src/xercesc/internal/DGXMLScanner.hpp
+++ b/src/xercesc/internal/DGXMLScanner.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.5  2003/05/15 18:26:29  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.4  2003/03/07 18:08:58  tng
  * Return a reference instead of void for operator=
  *
@@ -95,15 +98,17 @@ public :
     // -----------------------------------------------------------------------
     DGXMLScanner
     (
-        XMLValidator* const valToAdopt
+          XMLValidator* const  valToAdopt
+        , MemoryManager* const manager
     );
     DGXMLScanner
     (
-        XMLDocumentHandler* const  docHandler
-        , DocTypeHandler* const    docTypeHandler
-        , XMLEntityHandler* const  entityHandler
-        , XMLErrorReporter* const  errReporter
-        , XMLValidator* const      valToAdopt
+          XMLDocumentHandler* const docHandler
+        , DocTypeHandler* const     docTypeHandler
+        , XMLEntityHandler* const   entityHandler
+        , XMLErrorReporter* const   errReporter
+        , XMLValidator* const       valToAdopt
+        , MemoryManager* const      manager
     );
     virtual ~DGXMLScanner();
 
diff --git a/src/xercesc/internal/ElemStack.cpp b/src/xercesc/internal/ElemStack.cpp
index 5d92d1fe7..6fbc251bc 100644
--- a/src/xercesc/internal/ElemStack.cpp
+++ b/src/xercesc/internal/ElemStack.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.5  2003/05/15 18:26:29  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.4  2003/01/02 16:38:00  knoaman
  * Some cleanup.
  *
@@ -155,9 +158,13 @@ ElemStack::ElemStack() :
     , fXMLPoolId(0)
     , fXMLNSNamespaceId(0)
     , fXMLNSPoolId(0)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
     // Do an initial allocation of the stack and zero it out
-    fStack = new StackElem*[fStackCapacity];
+    fStack = (StackElem**) fMemoryManager->allocate
+    (
+        fStackCapacity * sizeof(StackElem*)
+    );//new StackElem*[fStackCapacity];
     memset(fStack, 0, fStackCapacity * sizeof(StackElem*));
 }
 
@@ -173,13 +180,13 @@ ElemStack::~ElemStack()
         if (!fStack[stackInd])
             break;
 
-        delete [] fStack[stackInd]->fChildren;
-        delete [] fStack[stackInd]->fMap;
+        fMemoryManager->deallocate(fStack[stackInd]->fChildren);//delete [] fStack[stackInd]->fChildren;
+        fMemoryManager->deallocate(fStack[stackInd]->fMap);//delete [] fStack[stackInd]->fMap;
         delete fStack[stackInd];
     }
 
     // Delete the stack array itself now
-    delete [] fStack;
+    fMemoryManager->deallocate(fStack);//delete [] fStack;
 }
 
 
@@ -195,7 +202,7 @@ unsigned int ElemStack::addLevel()
     // If this element has not been initialized yet, then initialize it
     if (!fStack[fStackTop])
     {
-        fStack[fStackTop] = new StackElem;
+        fStack[fStackTop] = new (fMemoryManager) StackElem;
         fStack[fStackTop]->fChildCapacity = 0;
         fStack[fStackTop]->fChildren = 0;
         fStack[fStackTop]->fMapCapacity = 0;
@@ -229,7 +236,7 @@ ElemStack::addLevel(XMLElementDecl* const toSet, const unsigned int readerNum)
     // If this element has not been initialized yet, then initialize it
     if (!fStack[fStackTop])
     {
-        fStack[fStackTop] = new StackElem;
+        fStack[fStackTop] = new (fMemoryManager) StackElem;
         fStack[fStackTop]->fChildCapacity = 0;
         fStack[fStackTop]->fChildren = 0;
         fStack[fStackTop]->fMapCapacity = 0;
@@ -302,7 +309,10 @@ unsigned int ElemStack::addChild(QName* const child, const bool toParent)
         const unsigned int newCapacity = curRow->fChildCapacity ?
                                          (unsigned int)(curRow->fChildCapacity * 1.25) :
                                          32;
-        QName** newRow = new QName*[newCapacity];
+        QName** newRow = (QName**) fMemoryManager->allocate
+        (
+            newCapacity * sizeof(QName*)
+        );//new QName*[newCapacity];
 
         //
         //  Copy over the old contents. We don't have to initialize the new
@@ -321,7 +331,7 @@ unsigned int ElemStack::addChild(QName* const child, const bool toParent)
         }
 
         // Clean up the old children and store the new info
-        delete [] curRow->fChildren;
+        fMemoryManager->deallocate(curRow->fChildren);//delete [] curRow->fChildren;
         curRow->fChildren = newRow;
         curRow->fChildCapacity = newCapacity;
     }
@@ -491,7 +501,10 @@ void ElemStack::expandMap(StackElem* const toExpand)
     //
     const unsigned int newCapacity = oldCap ?
                                      (unsigned int)(oldCap * 1.25) : 16;
-    PrefMapElem* newMap = new PrefMapElem[newCapacity];
+    PrefMapElem* newMap = (PrefMapElem*) fMemoryManager->allocate
+    (
+        newCapacity * sizeof(PrefMapElem)
+    );//new PrefMapElem[newCapacity];
 
     //
     //  Copy over the old stuff. We DON'T have to zero out the new stuff
@@ -501,7 +514,7 @@ void ElemStack::expandMap(StackElem* const toExpand)
     memcpy(newMap, toExpand->fMap, oldCap * sizeof(PrefMapElem));
 
     // Delete the old map and store the new stuff
-    delete [] toExpand->fMap;
+    fMemoryManager->deallocate(toExpand->fMap);//delete [] toExpand->fMap;
     toExpand->fMap = newMap;
     toExpand->fMapCapacity = newCapacity;
 }
@@ -510,7 +523,10 @@ void ElemStack::expandStack()
 {
     // Expand the capacity by 25% and allocate a new buffer
     const unsigned int newCapacity = (unsigned int)(fStackCapacity * 1.25);
-    StackElem** newStack = new StackElem*[newCapacity];
+    StackElem** newStack = (StackElem**) fMemoryManager->allocate
+    (
+        newCapacity * sizeof(StackElem*)
+    );//new StackElem*[newCapacity];
 
     // Copy over the old stuff
     memcpy(newStack, fStack, fStackCapacity * sizeof(StackElem*));
@@ -528,7 +544,7 @@ void ElemStack::expandStack()
     );
 
     // Delete the old array and update our members
-    delete [] fStack;
+    fMemoryManager->deallocate(fStack);//delete [] fStack;
     fStack = newStack;
     fStackCapacity = newCapacity;
 }
@@ -552,9 +568,13 @@ WFElemStack::WFElemStack() :
     , fMapCapacity(0)
     , fMap(0)
     , fStack(0)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
     // Do an initial allocation of the stack and zero it out
-    fStack = new StackElem*[fStackCapacity];
+    fStack = (StackElem**) fMemoryManager->allocate
+    (
+        fStackCapacity * sizeof(StackElem*)
+    );//new StackElem*[fStackCapacity];
     memset(fStack, 0, fStackCapacity * sizeof(StackElem*));
 }
 
@@ -570,15 +590,15 @@ WFElemStack::~WFElemStack()
         if (!fStack[stackInd])
             break;
 
-        delete [] fStack[stackInd]->fThisElement;
+        fMemoryManager->deallocate(fStack[stackInd]->fThisElement);//delete [] fStack[stackInd]->fThisElement;
         delete fStack[stackInd];
     }
 
     if (fMap)
-        delete [] fMap;
+        fMemoryManager->deallocate(fMap);//delete [] fMap;
 
     // Delete the stack array itself now
-    delete [] fStack;
+    fMemoryManager->deallocate(fStack);//delete [] fStack;
 }
 
 
@@ -595,7 +615,7 @@ unsigned int WFElemStack::addLevel()
     // If this element has not been initialized yet, then initialize it
     if (!fStack[fStackTop])
     {
-        fStack[fStackTop] = new StackElem;
+        fStack[fStackTop] = new (fMemoryManager) StackElem;
         fStack[fStackTop]->fThisElement = 0;
         fStack[fStackTop]->fElemMaxLength = 0;
     }
@@ -627,7 +647,7 @@ WFElemStack::addLevel(const XMLCh* const toSet,
     // If this element has not been initialized yet, then initialize it
     if (!fStack[fStackTop])
     {
-        fStack[fStackTop] = new StackElem;
+        fStack[fStackTop] = new (fMemoryManager) StackElem;
         fStack[fStackTop]->fThisElement = 0;
         fStack[fStackTop]->fElemMaxLength = 0;
     }
@@ -639,9 +659,12 @@ WFElemStack::addLevel(const XMLCh* const toSet,
     // And store the new stuff
     if (toSetLen > fStack[fStackTop]->fElemMaxLength) {
 
-        delete [] fStack[fStackTop]->fThisElement;
+        fMemoryManager->deallocate(fStack[fStackTop]->fThisElement);//delete [] fStack[fStackTop]->fThisElement;
         fStack[fStackTop]->fElemMaxLength = toSetLen;
-        fStack[fStackTop]->fThisElement = new XMLCh[toSetLen + 1];
+        fStack[fStackTop]->fThisElement = (XMLCh*) fMemoryManager->allocate
+        (
+            (toSetLen + 1) * sizeof(XMLCh)
+        );//new XMLCh[toSetLen + 1];
     }
 
     XMLString::moveChars(fStack[fStackTop]->fThisElement, toSet, toSetLen + 1);
@@ -679,9 +702,12 @@ WFElemStack::setElement(const XMLCh* const toSet,
 
     if (toSetLen > fStack[fStackTop - 1]->fElemMaxLength) {
 
-        delete [] fStack[fStackTop - 1]->fThisElement;
+        fMemoryManager->deallocate(fStack[fStackTop - 1]->fThisElement);//delete [] fStack[fStackTop - 1]->fThisElement;
         fStack[fStackTop - 1]->fElemMaxLength = toSetLen;
-        fStack[fStackTop - 1]->fThisElement = new XMLCh[toSetLen + 1];
+        fStack[fStackTop - 1]->fThisElement = (XMLCh*) fMemoryManager->allocate
+        (
+            (toSetLen + 1) * sizeof(XMLCh)
+        );//new XMLCh[toSetLen + 1];
     }
 
     XMLString::moveChars(fStack[fStackTop - 1]->fThisElement, toSet, toSetLen + 1);
@@ -837,7 +863,10 @@ void WFElemStack::expandMap()
     //
     const unsigned int newCapacity = fMapCapacity ?
                                      (unsigned int)(fMapCapacity * 1.25) : 16;
-    PrefMapElem* newMap = new PrefMapElem[newCapacity];
+    PrefMapElem* newMap = (PrefMapElem*) fMemoryManager->allocate
+    (
+        newCapacity * sizeof(PrefMapElem)
+    );//new PrefMapElem[newCapacity];
 
     //
     //  Copy over the old stuff. We DON'T have to zero out the new stuff
@@ -847,7 +876,7 @@ void WFElemStack::expandMap()
     if (fMapCapacity) {
 
         memcpy(newMap, fMap, fMapCapacity * sizeof(PrefMapElem));
-        delete [] fMap;
+        fMemoryManager->deallocate(fMap);//delete [] fMap;
     }
 
     fMap = newMap;
@@ -858,7 +887,10 @@ void WFElemStack::expandStack()
 {
     // Expand the capacity by 25% and allocate a new buffer
     const unsigned int newCapacity = (unsigned int)(fStackCapacity * 1.25);
-    StackElem** newStack = new StackElem*[newCapacity];
+    StackElem** newStack = (StackElem**) fMemoryManager->allocate
+    (
+        newCapacity * sizeof(StackElem*)
+    );//new StackElem*[newCapacity];
 
     // Copy over the old stuff
     memcpy(newStack, fStack, fStackCapacity * sizeof(StackElem*));
@@ -876,7 +908,7 @@ void WFElemStack::expandStack()
     );
 
     // Delete the old array and update our members
-    delete [] fStack;
+    fMemoryManager->deallocate(fStack);//delete [] fStack;
     fStack = newStack;
     fStackCapacity = newCapacity;
 }
diff --git a/src/xercesc/internal/ElemStack.hpp b/src/xercesc/internal/ElemStack.hpp
index 153b86231..1db473488 100644
--- a/src/xercesc/internal/ElemStack.hpp
+++ b/src/xercesc/internal/ElemStack.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.5  2003/05/15 18:26:29  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.4  2003/03/07 18:08:58  tng
  * Return a reference instead of void for operator=
  *
@@ -111,7 +114,6 @@
 #if !defined(ELEMSTACK_HPP)
 #define ELEMSTACK_HPP
 
-#include <xercesc/util/XercesDefs.hpp>
 #include <xercesc/util/StringPool.hpp>
 #include <xercesc/util/QName.hpp>
 
@@ -147,7 +149,7 @@ class Grammar;
 //  each level, the prefixes defined at that level (and the namespaces that
 //  they map to) are stored.
 //
-class XMLPARSER_EXPORT ElemStack
+class XMLPARSER_EXPORT ElemStack : public XMemory
 {
 public :
     // -----------------------------------------------------------------------
@@ -179,13 +181,13 @@ public :
     //      affected by an sibling xmlns attributes, whereas elements are
     //      affected by its own xmlns attributes.
     // -----------------------------------------------------------------------
-    struct PrefMapElem
+    struct PrefMapElem : public XMemory
     {
         unsigned int        fPrefId;
         unsigned int        fURIId;
     };
 
-    struct StackElem
+    struct StackElem : public XMemory
     {
         XMLElementDecl*     fThisElement;
         unsigned int        fReaderNum;
@@ -339,10 +341,11 @@ private :
     unsigned int    fXMLPoolId;
     unsigned int    fXMLNSNamespaceId;
     unsigned int    fXMLNSPoolId;
+    MemoryManager*  fMemoryManager;
 };
 
 
-class XMLPARSER_EXPORT WFElemStack
+class XMLPARSER_EXPORT WFElemStack : public XMemory
 {
 public :
     // -----------------------------------------------------------------------
@@ -374,13 +377,13 @@ public :
     //      affected by an sibling xmlns attributes, whereas elements are
     //      affected by its own xmlns attributes.
     // -----------------------------------------------------------------------
-    struct PrefMapElem
+    struct PrefMapElem : public XMemory
     {
         unsigned int        fPrefId;
         unsigned int        fURIId;
     };
 
-    struct StackElem
+    struct StackElem : public XMemory
     {
         int                 fTopPrefix;        
         unsigned int        fCurrentURI;
@@ -518,6 +521,7 @@ private :
     PrefMapElem*    fMap;
     StackElem**     fStack;
     XMLStringPool   fPrefixPool;
+    MemoryManager*  fMemoryManager;
 };
 
 
diff --git a/src/xercesc/internal/IGXMLScanner.cpp b/src/xercesc/internal/IGXMLScanner.cpp
index 8afb1e5b7..e4ac69b68 100644
--- a/src/xercesc/internal/IGXMLScanner.cpp
+++ b/src/xercesc/internal/IGXMLScanner.cpp
@@ -70,6 +70,8 @@
 #include <xercesc/framework/XMLEntityHandler.hpp>
 #include <xercesc/framework/XMLPScanToken.hpp>
 #include <xercesc/internal/EndOfEntityException.hpp>
+#include <xercesc/framework/MemoryManager.hpp>
+#include <xercesc/validators/common/GrammarResolver.hpp>
 #include <xercesc/validators/DTD/DocTypeHandler.hpp>
 #include <xercesc/validators/DTD/DTDScanner.hpp>
 #include <xercesc/validators/DTD/DTDValidator.hpp>
@@ -85,9 +87,10 @@ XERCES_CPP_NAMESPACE_BEGIN
 // ---------------------------------------------------------------------------
 //  IGXMLScanner: Constructors and Destructor
 // ---------------------------------------------------------------------------
-IGXMLScanner::IGXMLScanner(XMLValidator* const valToAdopt) :
+IGXMLScanner::IGXMLScanner( XMLValidator* const  valToAdopt
+                          , MemoryManager* const manager) :
 
-    XMLScanner(valToAdopt)
+    XMLScanner(valToAdopt, manager)
     , fSeeXsi(false)
     , fElemStateSize(16)
     , fElemState(0)
@@ -114,13 +117,14 @@ IGXMLScanner::IGXMLScanner(XMLValidator* const valToAdopt) :
     }
 }
 
-IGXMLScanner::IGXMLScanner( XMLDocumentHandler* const  docHandler
-                            , DocTypeHandler* const    docTypeHandler
-                            , XMLEntityHandler* const  entityHandler
-                            , XMLErrorReporter* const  errHandler
-                            , XMLValidator* const      valToAdopt) :
+IGXMLScanner::IGXMLScanner( XMLDocumentHandler* const docHandler
+                          , DocTypeHandler* const     docTypeHandler
+                          , XMLEntityHandler* const   entityHandler
+                          , XMLErrorReporter* const   errHandler
+                          , XMLValidator* const       valToAdopt
+                          , MemoryManager* const      manager) :
 
-    XMLScanner(docHandler, docTypeHandler, entityHandler, errHandler, valToAdopt)
+    XMLScanner(docHandler, docTypeHandler, entityHandler, errHandler, valToAdopt, manager)
     , fSeeXsi(false)
     , fElemStateSize(16)
     , fElemState(0)
@@ -486,28 +490,31 @@ void IGXMLScanner::commonInit()
 {
 
     //  Create the element state array
-    fElemState = new unsigned int[fElemStateSize];
+    fElemState = (unsigned int*) fMemoryManager->allocate
+    (
+        fElemStateSize * sizeof(unsigned int)
+    ); //new unsigned int[fElemStateSize];
 
     //  And we need one for the raw attribute scan. This just stores key/
     //  value string pairs (prior to any processing.)
-    fRawAttrList = new RefVectorOf<KVStringPair>(32);
+    fRawAttrList = new (fMemoryManager) RefVectorOf<KVStringPair>(32);
 
     //  Create the Validator and init them
-    fDTDValidator = new DTDValidator();
+    fDTDValidator = new (fMemoryManager) DTDValidator();
     initValidator(fDTDValidator);
-    fSchemaValidator = new SchemaValidator();
+    fSchemaValidator = new (fMemoryManager) SchemaValidator(0, fMemoryManager);
     initValidator(fSchemaValidator);
 
     // Create IdentityConstraint info
-    fMatcherStack = new XPathMatcherStack();
-    fValueStoreCache = new ValueStoreCache();
-    fFieldActivator = new FieldActivator(fValueStoreCache, fMatcherStack);
+    fMatcherStack = new (fMemoryManager) XPathMatcherStack(fMemoryManager);
+    fValueStoreCache = new (fMemoryManager) ValueStoreCache(fMemoryManager);
+    fFieldActivator = new (fMemoryManager) FieldActivator(fValueStoreCache, fMatcherStack, fMemoryManager);
     fValueStoreCache->setScanner(this);
 }
 
 void IGXMLScanner::cleanUp()
 {
-    delete [] fElemState;
+    fMemoryManager->deallocate(fElemState); //delete [] fElemState;
     delete fRawAttrList;
     delete fDTDValidator;
     delete fSchemaValidator;
@@ -687,7 +694,7 @@ IGXMLScanner::rawAttrScan(const   XMLCh* const                elemName
             KVStringPair* curPair = 0;
             if (attCount >= curVecSize)
             {
-                curPair = new KVStringPair
+                curPair = new (fMemoryManager) KVStringPair
                 (
                     fAttNameBuf.getRawBuffer()
                     , fAttValueBuf.getRawBuffer()
@@ -1161,7 +1168,13 @@ void IGXMLScanner::scanDocTypeDecl()
     //
     //  Only do this if we are not reusing the validator! If we are reusing,
     //  then look it up instead. It has to exist!
-    DTDElementDecl* rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(), fEmptyNamespaceId);
+    DTDElementDecl* rootDecl = new (fMemoryManager) DTDElementDecl
+    (
+        bbRootName.getRawBuffer()
+        , fEmptyNamespaceId
+        , DTDElementDecl::Any
+        , fMemoryManager
+    );
 
     rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
     rootDecl->setExternalElemDeclaration(true);
@@ -1191,7 +1204,12 @@ void IGXMLScanner::scanDocTypeDecl()
     XMLCh*  sysId = 0;
     XMLCh*  pubId = 0;
 
-    DTDScanner dtdScanner((DTDGrammar*)fGrammar, fDocTypeHandler);
+    DTDScanner dtdScanner
+    (
+        (DTDGrammar*) fGrammar
+        , fDocTypeHandler
+        , fMemoryManager
+    );
     dtdScanner.setScannerInfo(this, &fReaderMgr, &fBufMgr);
 
     //  If the next character is '[' then we have no external subset cause
@@ -1221,8 +1239,8 @@ void IGXMLScanner::scanDocTypeDecl()
         }
 
         // Get copies of the ids we got
-        pubId = XMLString::replicate(bbPubId.getRawBuffer());
-        sysId = XMLString::replicate(bbSysId.getRawBuffer());
+        pubId = XMLString::replicate(bbPubId.getRawBuffer(), fMemoryManager);
+        sysId = XMLString::replicate(bbSysId.getRawBuffer(), fMemoryManager);
 
         // Skip spaces and check again for the opening of an internal subset
         fReaderMgr.skipPastSpaces();
@@ -1234,8 +1252,8 @@ void IGXMLScanner::scanDocTypeDecl()
     }
 
     // Insure that the ids get cleaned up, if they got allocated
-    ArrayJanitor<XMLCh> janSysId(sysId);
-    ArrayJanitor<XMLCh> janPubId(pubId);
+    ArrayJanitor<XMLCh> janSysId(sysId, fMemoryManager);
+    ArrayJanitor<XMLCh> janPubId(pubId, fMemoryManager);
 
     //  If we have a doc type handler and advanced callbacks are enabled,
     //  call the doctype event.
@@ -1312,7 +1330,13 @@ void IGXMLScanner::scanDocTypeDecl()
                 if (rootDecl)
                     ((DTDGrammar*)fGrammar)->setRootElemId(rootDecl->getId());
                 else {
-                    rootDecl = new DTDElementDecl(bbRootName.getRawBuffer(), fEmptyNamespaceId);
+                    rootDecl = new (fMemoryManager) DTDElementDecl
+                    (
+                        bbRootName.getRawBuffer()
+                        , fEmptyNamespaceId
+                        , DTDElementDecl::Any
+                        , fMemoryManager
+                    );
                     rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
                     rootDecl->setExternalElemDeclaration(true);
                     ((DTDGrammar*)fGrammar)->setRootElemId(fGrammar->putElemDecl(rootDecl));
@@ -1360,7 +1384,7 @@ void IGXMLScanner::scanDocTypeDecl()
             //  with an external entity. Put a janitor on it to insure it gets
             //  cleaned up. The reader manager does not adopt them.
             const XMLCh gDTDStr[] = { chLatin_D, chLatin_T, chLatin_D , chNull };
-            DTDEntityDecl* declDTD = new DTDEntityDecl(gDTDStr);
+            DTDEntityDecl* declDTD = new (fMemoryManager) DTDEntityDecl(gDTDStr);
             declDTD->setSystemId(sysId);
             Janitor<DTDEntityDecl> janDecl(declDTD);
 
@@ -1699,7 +1723,7 @@ bool IGXMLScanner::scanStartTag(bool& gotData)
             XMLAttr* curAtt;
             if (attCount >= curAttListSize)
             {
-                curAtt = new XMLAttr
+                curAtt = new (fMemoryManager) XMLAttr
                 (
                     -1
                     , fAttNameBuf.getRawBuffer()
@@ -1707,6 +1731,7 @@ bool IGXMLScanner::scanStartTag(bool& gotData)
                     , fAttValueBuf.getRawBuffer()
                     , attDef->getType()
                     , true
+                    , fMemoryManager
                 );
                 fAttrList->addElement(curAtt);
             }
@@ -1828,7 +1853,7 @@ bool IGXMLScanner::scanStartTag(bool& gotData)
                     XMLAttr* curAtt;
                     if (attCount >= curAttListSize)
                     {
-                        curAtt = new XMLAttr
+                        curAtt = new (fMemoryManager) XMLAttr
                         (
                             -1
                             , curDef.getFullName()
@@ -1836,6 +1861,7 @@ bool IGXMLScanner::scanStartTag(bool& gotData)
                             , curDef.getValue()
                             , curDef.getType()
                             , false
+                            , fMemoryManager
                         );
                         fAttrList->addElement(curAtt);
                         curAttListSize++;
@@ -2662,7 +2688,10 @@ IGXMLScanner::resolveQName(const   XMLCh* const qName
 void IGXMLScanner::resizeElemState() {
 
     unsigned int newSize = fElemStateSize * 2;
-    unsigned int* newElemState = new unsigned int[newSize];
+    unsigned int* newElemState = (unsigned int*) fMemoryManager->allocate
+    (
+        newSize * sizeof(unsigned int)
+    ); //new unsigned int[newSize];
 
     // Copy the existing values
     unsigned int index = 0;
@@ -2673,7 +2702,7 @@ void IGXMLScanner::resizeElemState() {
         newElemState[index] = 0;
 
     // Delete the old array and udpate our members
-    delete [] fElemState;
+    fMemoryManager->deallocate(fElemState); //delete [] fElemState;
     fElemState = newElemState;
     fElemStateSize = newSize;
 }
@@ -2688,7 +2717,7 @@ void IGXMLScanner::activateSelectorFor(IdentityConstraint* const ic, const int i
     if (!selector)
         return;
 
-    XPathMatcher* matcher = selector->createMatcher(fFieldActivator, initialDepth);
+    XPathMatcher* matcher = selector->createMatcher(fFieldActivator, initialDepth, fMemoryManager);
 
     fMatcherStack->addMatcher(matcher);
     matcher->startDocumentFragment();
@@ -2811,7 +2840,7 @@ Grammar* IGXMLScanner::loadDTDGrammar(const InputSource& src,
         }
     }
 
-    fDTDGrammar = new DTDGrammar();
+    fDTDGrammar = new (fMemoryManager) DTDGrammar(fMemoryManager);
     fGrammarResolver->putGrammar(XMLUni::fgDTDEntityString, fDTDGrammar);
     fGrammar = fDTDGrammar;
     fGrammarType = fGrammar->getGrammarType();
@@ -2862,7 +2891,7 @@ Grammar* IGXMLScanner::loadDTDGrammar(const InputSource& src,
     //  with an external entity. Put a janitor on it to insure it gets
     //  cleaned up. The reader manager does not adopt them.
     const XMLCh gDTDStr[] = { chLatin_D, chLatin_T, chLatin_D , chNull };
-    DTDEntityDecl* declDTD = new DTDEntityDecl(gDTDStr);
+    DTDEntityDecl* declDTD = new (fMemoryManager) DTDEntityDecl(gDTDStr);
     declDTD->setSystemId(src.getSystemId());
     Janitor<DTDEntityDecl> janDecl(declDTD);
 
@@ -2877,7 +2906,13 @@ Grammar* IGXMLScanner::loadDTDGrammar(const InputSource& src,
     if (fDocTypeHandler) {
 
         // Create a dummy root
-        DTDElementDecl* rootDecl = new DTDElementDecl(gDTDStr, fEmptyNamespaceId);
+        DTDElementDecl* rootDecl = new (fMemoryManager) DTDElementDecl
+        (
+            gDTDStr
+            , fEmptyNamespaceId
+            , DTDElementDecl::Any
+            , fMemoryManager
+        );
         rootDecl->setCreateReason(DTDElementDecl::AsRootElem);
         rootDecl->setExternalElemDeclaration(true);
         Janitor<DTDElementDecl> janSrc(rootDecl);
@@ -2886,7 +2921,12 @@ Grammar* IGXMLScanner::loadDTDGrammar(const InputSource& src,
     }
 
     // Create DTDScanner
-    DTDScanner dtdScanner((DTDGrammar*)fGrammar, fDocTypeHandler);
+    DTDScanner dtdScanner
+    (
+        (DTDGrammar*) fGrammar
+        , fDocTypeHandler
+        , fMemoryManager
+    );
     dtdScanner.setScannerInfo(this, &fReaderMgr, &fBufMgr);
 
     // Tell it its not in an include section
diff --git a/src/xercesc/internal/IGXMLScanner.hpp b/src/xercesc/internal/IGXMLScanner.hpp
index 57b8c4ee0..760e6ec86 100644
--- a/src/xercesc/internal/IGXMLScanner.hpp
+++ b/src/xercesc/internal/IGXMLScanner.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.6  2003/05/15 18:26:29  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.5  2003/03/07 18:08:58  tng
  * Return a reference instead of void for operator=
  *
@@ -107,14 +110,16 @@ public :
     IGXMLScanner
     (
         XMLValidator* const valToAdopt
+        , MemoryManager* const manager
     );
     IGXMLScanner
     (
-        XMLDocumentHandler* const  docHandler
-        , DocTypeHandler* const    docTypeHandler
-        , XMLEntityHandler* const  entityHandler
-        , XMLErrorReporter* const  errReporter
-        , XMLValidator* const      valToAdopt
+          XMLDocumentHandler* const docHandler
+        , DocTypeHandler* const     docTypeHandler
+        , XMLEntityHandler* const   entityHandler
+        , XMLErrorReporter* const   errReporter
+        , XMLValidator* const       valToAdopt
+        , MemoryManager* const      manager
     );
     virtual ~IGXMLScanner();
 
diff --git a/src/xercesc/internal/IGXMLScanner2.cpp b/src/xercesc/internal/IGXMLScanner2.cpp
index f6cb653fb..6369b6cd8 100644
--- a/src/xercesc/internal/IGXMLScanner2.cpp
+++ b/src/xercesc/internal/IGXMLScanner2.cpp
@@ -159,7 +159,7 @@ IGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
             }
             else
             {
-                janName.reset(XMLString::replicate(namePtr));
+                janName.reset(XMLString::replicate(namePtr, fMemoryManager), fMemoryManager);
                 janName[colonInd] = chNull;
                 prefPtr = janName.get();
             }
@@ -454,7 +454,7 @@ IGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
         XMLAttr* curAttr;
         if (retCount >= curAttListSize)
         {
-            curAttr = new XMLAttr
+            curAttr = new (fMemoryManager) XMLAttr
             (
                 uriId
                 , suffPtr
@@ -462,6 +462,7 @@ IGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
                 , normBuf.getRawBuffer()
                 , attType
                 , true
+                , fMemoryManager
             );
             toFill.addElement(curAttr);
         }
@@ -556,7 +557,7 @@ IGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
                     XMLAttr* curAtt;
                     if (retCount >= curAttListSize)
                     {
-                        curAtt = new XMLAttr;
+                        curAtt = new (fMemoryManager) XMLAttr(fMemoryManager);
                         fValidator->faultInAttr(*curAtt, *curDef);
                         fAttrList->addElement(curAtt);
                     }
@@ -863,7 +864,7 @@ void IGXMLScanner::scanReset(const InputSource& src)
     fGrammarResolver->cacheGrammarFromParse(fToCacheGrammar);
     fGrammarResolver->useCachedGrammarInParse(fUseCachedGrammar);
 
-    fDTDGrammar = new DTDGrammar();
+    fDTDGrammar = new (fMemoryManager) DTDGrammar(fMemoryManager);
     fGrammarResolver->putGrammar(XMLUni::fgDTDEntityString, fDTDGrammar);
     fGrammar = fDTDGrammar;
     fGrammarType = fGrammar->getGrammarType();
@@ -901,7 +902,7 @@ void IGXMLScanner::scanReset(const InputSource& src)
     fIDRefList->removeAll();
 
     // Reset the Root Element Name
-    delete [] fRootElemName;
+    fMemoryManager->deallocate(fRootElemName);//delete [] fRootElemName;
     fRootElemName = 0;
 
     // Reset IdentityConstraints
@@ -1293,7 +1294,7 @@ void IGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
     Grammar* grammar = fGrammarResolver->getGrammar(uri);
 
     if (!grammar || grammar->getGrammarType() == Grammar::DTDGrammarType) {
-        XSDDOMParser parser;
+        XSDDOMParser parser(0, fMemoryManager);
 
         parser.setValidationScheme(XercesDOMParser::Val_Never);
         parser.setDoNamespaces(true);
@@ -1345,7 +1346,7 @@ void IGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
                 else {
                     if (fStandardUriConformant && urlTmp.hasInvalidChar())
                         ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
-                    srcToFill = new URLInputSource(urlTmp);
+                    srcToFill = new (fMemoryManager) URLInputSource(urlTmp);
                 }
             }
 
@@ -1353,7 +1354,7 @@ void IGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
             {
                 // Its not a URL, so lets assume its a local file name if non-standard uri is allowed
                 if (!fStandardUriConformant)
-                    srcToFill = new LocalFileInputSource
+                    srcToFill = new (fMemoryManager) LocalFileInputSource
                     (
                         lastInfo.systemId
                         , expSysId.getRawBuffer()
@@ -1415,8 +1416,19 @@ void IGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
                         }
                     }
 
-                    grammar = new SchemaGrammar();
-                    TraverseSchema traverseSchema(root, fURIStringPool, (SchemaGrammar*) grammar, fGrammarResolver, this, srcToFill->getSystemId(), fEntityHandler, fErrorReporter);
+                    grammar = new (fMemoryManager) SchemaGrammar(fMemoryManager);
+                    TraverseSchema traverseSchema
+                    (
+                        root
+                        , fURIStringPool
+                        , (SchemaGrammar*) grammar
+                        , fGrammarResolver
+                        , this
+                        , srcToFill->getSystemId()
+                        , fEntityHandler
+                        , fErrorReporter
+                        , fMemoryManager
+                    );
 
                     if (fGrammarType == Grammar::DTDGrammarType) {
                         fGrammar = grammar;
@@ -1504,14 +1516,14 @@ InputSource* IGXMLScanner::resolveSystemId(const XMLCh* const sysId)
             else {
                 if (fStandardUriConformant && urlTmp.hasInvalidChar())
                     ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
-                srcToFill = new URLInputSource(urlTmp);
+                srcToFill = new (fMemoryManager) URLInputSource(urlTmp);
             }
         }
         catch(const MalformedURLException& e)
         {
             // Its not a URL, so lets assume its a local file name if non-standard uri is allowed
             if (!fStandardUriConformant)
-                srcToFill = new LocalFileInputSource
+                srcToFill = new (fMemoryManager) LocalFileInputSource
                 (
                     lastInfo.systemId
                     , expSysId.getRawBuffer()
@@ -1548,7 +1560,7 @@ Grammar* IGXMLScanner::loadXMLSchemaGrammar(const InputSource& src,
         }
     }
 
-    XSDDOMParser parser;
+    XSDDOMParser parser(0, fMemoryManager);
 
     parser.setValidationScheme(XercesDOMParser::Val_Never);
     parser.setDoNamespaces(true);
@@ -1574,8 +1586,19 @@ Grammar* IGXMLScanner::loadXMLSchemaGrammar(const InputSource& src,
         DOMElement* root = document->getDocumentElement();// This is what we pass to TraverserSchema
         if (root != 0)
         {
-            SchemaGrammar* grammar = new SchemaGrammar();
-            TraverseSchema traverseSchema(root, fURIStringPool, (SchemaGrammar*) grammar, fGrammarResolver, this, src.getSystemId(), fEntityHandler, fErrorReporter);
+            SchemaGrammar* grammar = new (fMemoryManager) SchemaGrammar(fMemoryManager);
+            TraverseSchema traverseSchema
+            (
+                root
+                , fURIStringPool
+                , (SchemaGrammar*) grammar
+                , fGrammarResolver
+                , this
+                , src.getSystemId()
+                , fEntityHandler
+                , fErrorReporter
+                , fMemoryManager
+            );
 
             if (fValidate) {
                 //  validate the Schema scan so far
diff --git a/src/xercesc/internal/ReaderMgr.cpp b/src/xercesc/internal/ReaderMgr.cpp
index 461994b2f..50bd4747a 100644
--- a/src/xercesc/internal/ReaderMgr.cpp
+++ b/src/xercesc/internal/ReaderMgr.cpp
@@ -84,7 +84,7 @@ XERCES_CPP_NAMESPACE_BEGIN
 // ---------------------------------------------------------------------------
 //  ReaderMgr: Constructors and Destructor
 // ---------------------------------------------------------------------------
-ReaderMgr::ReaderMgr() :
+ReaderMgr::ReaderMgr(MemoryManager* const manager) :
 
     fCurEntity(0)
     , fCurReader(0)
@@ -95,6 +95,7 @@ ReaderMgr::ReaderMgr() :
     , fThrowEOE(false)
     , fXMLVersion(XMLReader::XMLV1_0)
     , fStandardUriConformant(false)
+    , fMemoryManager(manager)
 {
 }
 
@@ -441,7 +442,7 @@ XMLReader* ReaderMgr::createReader( const   InputSource&        src
     try {
         if (src.getEncoding())
         {
-            retVal = new XMLReader
+            retVal = new (fMemoryManager) XMLReader
                 (
                 src.getPublicId()
                 , src.getSystemId()
@@ -457,7 +458,7 @@ XMLReader* ReaderMgr::createReader( const   InputSource&        src
         }
         else
         {
-            retVal = new XMLReader
+            retVal = new (fMemoryManager) XMLReader
                 (
                 src.getPublicId()
                 , src.getSystemId()
@@ -550,7 +551,7 @@ XMLReader* ReaderMgr::createReader( const   XMLCh* const        sysId
             else {
                 if (fStandardUriConformant && urlTmp.hasInvalidChar())
                     ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
-                srcToFill = new URLInputSource(urlTmp);
+                srcToFill = new (fMemoryManager) URLInputSource(urlTmp);
             }
         }
 
@@ -558,7 +559,7 @@ XMLReader* ReaderMgr::createReader( const   XMLCh* const        sysId
         {
             // Its not a URL, so lets assume its a local file name if non-standard uri is allowed
             if (!fStandardUriConformant)
-                srcToFill = new LocalFileInputSource
+                srcToFill = new (fMemoryManager) LocalFileInputSource
                 (
                     lastInfo.systemId
                     , expSysId.getRawBuffer()
@@ -660,7 +661,7 @@ XMLReader* ReaderMgr::createReader( const   XMLCh* const        baseURI
             else {
                 if (fStandardUriConformant && urlTmp.hasInvalidChar())
                     ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
-                srcToFill = new URLInputSource(urlTmp);
+                srcToFill = new (fMemoryManager) URLInputSource(urlTmp);
             }
         }
 
@@ -668,7 +669,7 @@ XMLReader* ReaderMgr::createReader( const   XMLCh* const        baseURI
         {
             // Its not a URL, so lets assume its a local file name if non-standard uri is allowed
             if (!fStandardUriConformant)
-                srcToFill = new LocalFileInputSource
+                srcToFill = new (fMemoryManager) LocalFileInputSource
                 (
                     lastInfo.systemId
                     , expSysId.getRawBuffer()
@@ -725,7 +726,7 @@ ReaderMgr::createIntEntReader(  const   XMLCh* const        sysId
     //  as a 'do nothing' transcoder for the already internalized XMLCh
     //  data that makes up an internal entity.
     //
-    BinMemInputStream* newStream = new BinMemInputStream
+    BinMemInputStream* newStream = new (fMemoryManager) BinMemInputStream
                                    (
                                      (const XMLByte*)dataBuf
                                      , dataLen * sizeof(XMLCh)
@@ -735,7 +736,7 @@ ReaderMgr::createIntEntReader(  const   XMLCh* const        sysId
     if (!newStream)
         return 0;
 
-    XMLReader* retVal = new XMLReader
+    XMLReader* retVal = new (fMemoryManager) XMLReader
     (
         sysId
         , 0
@@ -893,11 +894,11 @@ bool ReaderMgr::pushReader(         XMLReader* const        reader
     //  tell it it does own its elements.
     //
     if (!fReaderStack)
-        fReaderStack = new RefStackOf<XMLReader>(16, true);
+        fReaderStack = new (fMemoryManager) RefStackOf<XMLReader>(16, true);
 
     // And the entity stack, which does not own its elements
     if (!fEntityStack)
-        fEntityStack = new RefStackOf<XMLEntityDecl>(16, false);
+        fEntityStack = new (fMemoryManager) RefStackOf<XMLEntityDecl>(16, false);
 
     //
     //  Push the current reader and entity onto their respective stacks.
diff --git a/src/xercesc/internal/ReaderMgr.hpp b/src/xercesc/internal/ReaderMgr.hpp
index dea75b79b..b14c9db4e 100644
--- a/src/xercesc/internal/ReaderMgr.hpp
+++ b/src/xercesc/internal/ReaderMgr.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.8  2003/05/15 18:26:29  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.7  2003/01/03 20:08:39  tng
  * New feature StandardUriConformant to force strict standard uri conformance.
  *
@@ -139,15 +142,14 @@
 #if !defined(READERMGR_HPP)
 #define READERMGR_HPP
 
+#include <xercesc/internal/XMLReader.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/RefStackOf.hpp>
-#include <xercesc/util/XMLString.hpp>
 #include <xercesc/sax/Locator.hpp>
 #include <xercesc/framework/XMLBuffer.hpp>
-#include <xercesc/internal/XMLReader.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
-class XMLBuffer;
 class XMLEntityDecl;
 class XMLEntityHandler;
 class XMLDocumentHandler;
@@ -163,7 +165,8 @@ class XMLScanner;
 //  talks to the reader manager, which handles the stack and popping off
 //  used up readers.
 // ---------------------------------------------------------------------------
-class XMLPARSER_EXPORT ReaderMgr : public Locator
+class XMLPARSER_EXPORT ReaderMgr :   public XMemory 
+                                   , public Locator
 {
 public :
     // -----------------------------------------------------------------------
@@ -181,7 +184,7 @@ public :
     // -----------------------------------------------------------------------
     //  Constructors and Destructor
     // -----------------------------------------------------------------------
-    ReaderMgr();
+    ReaderMgr(MemoryManager* const manager /*= XMLPlatformUtils::fgMemoryManager*/);
     ~ReaderMgr();
 
 
@@ -364,6 +367,7 @@ private :
     bool                        fThrowEOE;
     XMLReader::XMLVersion       fXMLVersion;
     bool                        fStandardUriConformant;
+    MemoryManager*              fMemoryManager;
 };
 
 
diff --git a/src/xercesc/internal/SGXMLScanner.cpp b/src/xercesc/internal/SGXMLScanner.cpp
index 2fc34b055..70c4dd0de 100644
--- a/src/xercesc/internal/SGXMLScanner.cpp
+++ b/src/xercesc/internal/SGXMLScanner.cpp
@@ -70,6 +70,7 @@
 #include <xercesc/framework/XMLDocumentHandler.hpp>
 #include <xercesc/framework/XMLEntityHandler.hpp>
 #include <xercesc/framework/XMLPScanToken.hpp>
+#include <xercesc/framework/MemoryManager.hpp>
 #include <xercesc/internal/EndOfEntityException.hpp>
 #include <xercesc/validators/common/ContentLeafNameTypeVector.hpp>
 #include <xercesc/validators/schema/SchemaValidator.hpp>
@@ -87,9 +88,10 @@ XERCES_CPP_NAMESPACE_BEGIN
 // ---------------------------------------------------------------------------
 //  SGXMLScanner: Constructors and Destructor
 // ---------------------------------------------------------------------------
-SGXMLScanner::SGXMLScanner(XMLValidator* const valToAdopt) :
+SGXMLScanner::SGXMLScanner( XMLValidator* const valToAdopt
+                          , MemoryManager* const manager) :
 
-    XMLScanner(valToAdopt)
+    XMLScanner(valToAdopt, manager)
     , fSeeXsi(false)
     , fElemStateSize(16)
     , fElemState(0)
@@ -121,13 +123,14 @@ SGXMLScanner::SGXMLScanner(XMLValidator* const valToAdopt) :
     }
 }
 
-SGXMLScanner::SGXMLScanner( XMLDocumentHandler* const  docHandler
-                            , DocTypeHandler* const    docTypeHandler
-                            , XMLEntityHandler* const  entityHandler
-                            , XMLErrorReporter* const  errHandler
-                            , XMLValidator* const      valToAdopt) :
+SGXMLScanner::SGXMLScanner( XMLDocumentHandler* const docHandler
+                          , DocTypeHandler* const     docTypeHandler
+                          , XMLEntityHandler* const   entityHandler
+                          , XMLErrorReporter* const   errHandler
+                          , XMLValidator* const       valToAdopt
+                          , MemoryManager* const      manager) :
 
-    XMLScanner(docHandler, docTypeHandler, entityHandler, errHandler, valToAdopt)
+    XMLScanner(docHandler, docTypeHandler, entityHandler, errHandler, valToAdopt, manager)
     , fSeeXsi(false)
     , fElemStateSize(16)
     , fElemState(0)
@@ -653,7 +656,7 @@ SGXMLScanner::rawAttrScan(const   XMLCh* const                elemName
             KVStringPair* curPair = 0;
             if (attCount >= curVecSize)
             {
-                curPair = new KVStringPair
+                curPair = new (fMemoryManager) KVStringPair
                 (
                     fAttNameBuf.getRawBuffer()
                     , fAttValueBuf.getRawBuffer()
@@ -1741,7 +1744,12 @@ void SGXMLScanner::activateSelectorFor(IdentityConstraint* const ic, const int i
     if (!selector)
         return;
 
-    XPathMatcher* matcher = selector->createMatcher(fFieldActivator, initialDepth);
+    XPathMatcher* matcher = selector->createMatcher
+    (
+        fFieldActivator
+        , initialDepth
+        , fMemoryManager
+    );
 
     fMatcherStack->addMatcher(matcher);
     matcher->startDocumentFragment();
@@ -1853,28 +1861,31 @@ Grammar* SGXMLScanner::loadGrammar(const   InputSource& src
 void SGXMLScanner::commonInit()
 {
     //  Create the element state array
-    fElemState = new unsigned int[fElemStateSize];
+    fElemState = (unsigned int*) fMemoryManager->allocate
+    (
+        fElemStateSize * sizeof(unsigned int)
+    ); //new unsigned int[fElemStateSize];
 
     //  And we need one for the raw attribute scan. This just stores key/
     //  value string pairs (prior to any processing.)
-    fRawAttrList = new RefVectorOf<KVStringPair>(32);
+    fRawAttrList = new (fMemoryManager) RefVectorOf<KVStringPair>(32);
 
     // Create dummy schema grammar
-    fSchemaGrammar = new SchemaGrammar();
+    fSchemaGrammar = new (fMemoryManager) SchemaGrammar(fMemoryManager);
 
     //  Create the Validator and init them
-    fSchemaValidator = new SchemaValidator();
+    fSchemaValidator = new (fMemoryManager) SchemaValidator(0, fMemoryManager);
     initValidator(fSchemaValidator);
 
     // Create IdentityConstraint info
-    fMatcherStack = new XPathMatcherStack();
-    fValueStoreCache = new ValueStoreCache();
-    fFieldActivator = new FieldActivator(fValueStoreCache, fMatcherStack);
+    fMatcherStack = new (fMemoryManager) XPathMatcherStack(fMemoryManager);
+    fValueStoreCache = new (fMemoryManager) ValueStoreCache(fMemoryManager);
+    fFieldActivator = new (fMemoryManager) FieldActivator(fValueStoreCache, fMatcherStack, fMemoryManager);
     fValueStoreCache->setScanner(this);
 
     //  Add the default entity entries for the character refs that must always
     //  be present.
-    fEntityTable = new ValueHashTableOf<XMLCh>(11);
+    fEntityTable = new (fMemoryManager) ValueHashTableOf<XMLCh>(11);
     fEntityTable->put((void*) XMLUni::fgAmp, chAmpersand);
     fEntityTable->put((void*) XMLUni::fgLT, chOpenAngle);
     fEntityTable->put((void*) XMLUni::fgGT, chCloseAngle);
@@ -1884,7 +1895,7 @@ void SGXMLScanner::commonInit()
 
 void SGXMLScanner::cleanUp()
 {
-    delete [] fElemState;
+    fMemoryManager->deallocate(fElemState); //delete [] fElemState;
     delete fSchemaGrammar;
     delete fEntityTable;
     delete fRawAttrList;
@@ -1897,7 +1908,10 @@ void SGXMLScanner::cleanUp()
 void SGXMLScanner::resizeElemState() {
 
     unsigned int newSize = fElemStateSize * 2;
-    unsigned int* newElemState = new unsigned int[newSize];
+    unsigned int* newElemState = (unsigned int*) fMemoryManager->allocate
+    (
+        newSize * sizeof(unsigned int)
+    ); //new unsigned int[newSize];
 
     // Copy the existing values
     unsigned int index = 0;
@@ -1908,7 +1922,7 @@ void SGXMLScanner::resizeElemState() {
         newElemState[index] = 0;
 
     // Delete the old array and udpate our members
-    delete [] fElemState;
+    fMemoryManager->deallocate(fElemState); //delete [] fElemState;
     fElemState = newElemState;
     fElemStateSize = newSize;
 }
@@ -1977,7 +1991,7 @@ SGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
             }
             else
             {
-                janName.reset(XMLString::replicate(namePtr));
+                janName.reset(XMLString::replicate(namePtr, fMemoryManager), fMemoryManager);
                 janName[colonInd] = chNull;
                 prefPtr = janName.get();
             }
@@ -2259,7 +2273,7 @@ SGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
         XMLAttr* curAttr;
         if (retCount >= curAttListSize)
         {
-            curAttr = new XMLAttr
+            curAttr = new (fMemoryManager) XMLAttr
             (
                 uriId
                 , suffPtr
@@ -2267,6 +2281,7 @@ SGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
                 , normBuf.getRawBuffer()
                 , attType
                 , true
+                , fMemoryManager
             );
             toFill.addElement(curAttr);
         }
@@ -2358,7 +2373,7 @@ SGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
                     XMLAttr* curAtt;
                     if (retCount >= curAttListSize)
                     {
-                        curAtt = new XMLAttr;
+                        curAtt = new (fMemoryManager) XMLAttr(fMemoryManager);
                         fValidator->faultInAttr(*curAtt, *curDef);
                         fAttrList->addElement(curAtt);
                     }
@@ -3041,7 +3056,7 @@ void SGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
     Grammar* grammar = fGrammarResolver->getGrammar(uri);
 
     if (!grammar || grammar->getGrammarType() == Grammar::DTDGrammarType) {
-        XSDDOMParser parser;
+        XSDDOMParser parser(0, fMemoryManager);
 
         parser.setValidationScheme(XercesDOMParser::Val_Never);
         parser.setDoNamespaces(true);
@@ -3093,7 +3108,7 @@ void SGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
                 else {
                     if (fStandardUriConformant && urlTmp.hasInvalidChar())
                         ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
-                    srcToFill = new URLInputSource(urlTmp);
+                    srcToFill = new (fMemoryManager) URLInputSource(urlTmp);
                 }
             }
 
@@ -3101,7 +3116,7 @@ void SGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
             {
                 // Its not a URL, so lets assume its a local file name if non-standard uri is allowed
                 if (!fStandardUriConformant)
-                    srcToFill = new LocalFileInputSource
+                    srcToFill = new (fMemoryManager) LocalFileInputSource
                     (
                         lastInfo.systemId
                         , expSysId.getRawBuffer()
@@ -3151,8 +3166,19 @@ void SGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con
                         fElemStack.setValidationFlag(fValidate);
                     }
 
-                    grammar = new SchemaGrammar();
-                    TraverseSchema traverseSchema(root, fURIStringPool, (SchemaGrammar*) grammar, fGrammarResolver, this, srcToFill->getSystemId(), fEntityHandler, fErrorReporter);
+                    grammar = new (fMemoryManager) SchemaGrammar(fMemoryManager);
+                    TraverseSchema traverseSchema
+                    (
+                        root
+                        , fURIStringPool
+                        , (SchemaGrammar*) grammar
+                        , fGrammarResolver
+                        , this
+                        , srcToFill->getSystemId()
+                        , fEntityHandler
+                        , fErrorReporter
+                        , fMemoryManager
+                    );
 
                     if (fGrammarType == Grammar::DTDGrammarType) {
                         fGrammar = grammar;
@@ -3229,14 +3255,14 @@ InputSource* SGXMLScanner::resolveSystemId(const XMLCh* const sysId)
             else {
                 if (fStandardUriConformant && urlTmp.hasInvalidChar())
                     ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL);
-                srcToFill = new URLInputSource(urlTmp);
+                srcToFill = new (fMemoryManager) URLInputSource(urlTmp);
             }
         }
         catch(const MalformedURLException& e)
         {
             // Its not a URL, so lets assume its a local file name if non-standard uri is allowed
             if (!fStandardUriConformant)
-                srcToFill = new LocalFileInputSource
+                srcToFill = new (fMemoryManager) LocalFileInputSource
                 (
                     lastInfo.systemId
                     , expSysId.getRawBuffer()
@@ -3265,7 +3291,7 @@ Grammar* SGXMLScanner::loadXMLSchemaGrammar(const InputSource& src,
     if (fValidatorFromUser)
         fValidator->reset();
 
-    XSDDOMParser parser;
+    XSDDOMParser parser(0, fMemoryManager);
 
     parser.setValidationScheme(XercesDOMParser::Val_Never);
     parser.setDoNamespaces(true);
@@ -3291,8 +3317,19 @@ Grammar* SGXMLScanner::loadXMLSchemaGrammar(const InputSource& src,
         DOMElement* root = document->getDocumentElement();// This is what we pass to TraverserSchema
         if (root != 0)
         {
-            SchemaGrammar* grammar = new SchemaGrammar();
-            TraverseSchema traverseSchema(root, fURIStringPool, (SchemaGrammar*) grammar, fGrammarResolver, this, src.getSystemId(), fEntityHandler, fErrorReporter);
+            SchemaGrammar* grammar = new (fMemoryManager) SchemaGrammar(fMemoryManager);
+            TraverseSchema traverseSchema
+            (
+                root
+                , fURIStringPool
+                , (SchemaGrammar*) grammar
+                , fGrammarResolver
+                , this
+                , src.getSystemId()
+                , fEntityHandler
+                , fErrorReporter
+                , fMemoryManager
+            );
 
             if (fValidate) {
                 //  validate the Schema scan so far
diff --git a/src/xercesc/internal/SGXMLScanner.hpp b/src/xercesc/internal/SGXMLScanner.hpp
index 10fa2b1d9..e88f291c0 100644
--- a/src/xercesc/internal/SGXMLScanner.hpp
+++ b/src/xercesc/internal/SGXMLScanner.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.6  2003/05/15 18:26:29  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.5  2003/03/07 18:08:58  tng
  * Return a reference instead of void for operator=
  *
@@ -106,6 +109,7 @@ public :
     SGXMLScanner
     (
         XMLValidator* const valToAdopt
+        , MemoryManager* const manager
     );
     SGXMLScanner
     (
@@ -114,6 +118,7 @@ public :
         , XMLEntityHandler* const  entityHandler
         , XMLErrorReporter* const  errReporter
         , XMLValidator* const      valToAdopt
+        , MemoryManager* const     manager
     );
     virtual ~SGXMLScanner();
 
diff --git a/src/xercesc/internal/VecAttrListImpl.cpp b/src/xercesc/internal/VecAttrListImpl.cpp
index 04d9d1996..fcd3ddb50 100644
--- a/src/xercesc/internal/VecAttrListImpl.cpp
+++ b/src/xercesc/internal/VecAttrListImpl.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.6  2003/05/15 18:26:29  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.5  2002/11/04 14:58:18  tng
  * C++ Namespace Support.
  *
@@ -197,8 +200,8 @@ const XMLCh* VecAttrListImpl::getValue(const XMLCh* const name) const
 const XMLCh* VecAttrListImpl::getValue(const char* const name) const
 {
     // Temporarily transcode the name for lookup
-    XMLCh* wideName = XMLString::transcode(name);
-    ArrayJanitor<XMLCh> janName(wideName);
+    XMLCh* wideName = XMLString::transcode(name, XMLPlatformUtils::fgMemoryManager);
+    ArrayJanitor<XMLCh> janName(wideName, XMLPlatformUtils::fgMemoryManager);
 
     //
     //  Search the vector for the attribute with the given name and return
diff --git a/src/xercesc/internal/VecAttrListImpl.hpp b/src/xercesc/internal/VecAttrListImpl.hpp
index 846b80f85..3377d9522 100644
--- a/src/xercesc/internal/VecAttrListImpl.hpp
+++ b/src/xercesc/internal/VecAttrListImpl.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.4  2003/05/15 18:26:29  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.3  2003/03/07 18:08:58  tng
  * Return a reference instead of void for operator=
  *
@@ -93,7 +96,7 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
-class XMLPARSER_EXPORT VecAttrListImpl : public AttributeList
+class XMLPARSER_EXPORT VecAttrListImpl : public XMemory, public AttributeList
 {
 public :
     // -----------------------------------------------------------------------
diff --git a/src/xercesc/internal/WFXMLScanner.cpp b/src/xercesc/internal/WFXMLScanner.cpp
index 49c81ce66..cd7cb2b65 100644
--- a/src/xercesc/internal/WFXMLScanner.cpp
+++ b/src/xercesc/internal/WFXMLScanner.cpp
@@ -79,9 +79,10 @@ XERCES_CPP_NAMESPACE_BEGIN
 // ---------------------------------------------------------------------------
 //  WFXMLScanner: Constructors and Destructor
 // ---------------------------------------------------------------------------
-WFXMLScanner::WFXMLScanner(XMLValidator* const valToAdopt) :
+WFXMLScanner::WFXMLScanner( XMLValidator* const  valToAdopt
+                          , MemoryManager* const manager) :
 
-    XMLScanner(valToAdopt)
+    XMLScanner(valToAdopt, manager)
     , fElementIndex(0)
     , fElements(0)
     , fEntityTable(0)
@@ -91,7 +92,7 @@ WFXMLScanner::WFXMLScanner(XMLValidator* const valToAdopt) :
 {
     try
     {
-         commonInit();
+        commonInit();
     }
     catch(...)
     {
@@ -100,13 +101,14 @@ WFXMLScanner::WFXMLScanner(XMLValidator* const valToAdopt) :
     }
 }
 
-WFXMLScanner::WFXMLScanner( XMLDocumentHandler* const  docHandler
-                            , DocTypeHandler* const    docTypeHandler
-                            , XMLEntityHandler* const  entityHandler
-                            , XMLErrorReporter* const  errHandler
-                            , XMLValidator* const      valToAdopt) :
+WFXMLScanner::WFXMLScanner( XMLDocumentHandler* const docHandler
+                          , DocTypeHandler* const     docTypeHandler
+                          , XMLEntityHandler* const   entityHandler
+                          , XMLErrorReporter* const   errHandler
+                          , XMLValidator* const       valToAdopt
+                          , MemoryManager* const      manager) :
 
-    XMLScanner(docHandler, docTypeHandler, entityHandler, errHandler, valToAdopt)
+    XMLScanner(docHandler, docTypeHandler, entityHandler, errHandler, valToAdopt, manager)
     , fElementIndex(0)
     , fElements(0)
     , fEntityTable(0)
@@ -435,11 +437,11 @@ bool WFXMLScanner::scanNext(XMLPScanToken& token)
 //  it redundantly in multiple constructors.
 void WFXMLScanner::commonInit()
 {
-    fEntityTable = new ValueHashTableOf<XMLCh>(11);
-    fAttrNameHashList = new ValueVectorOf<unsigned int>(16);
-    fAttrNSList = new ValueVectorOf<XMLAttr*>(8);
-    fElements = new RefVectorOf<XMLElementDecl>(32);
-    fElementLookup = new RefHashTableOf<XMLElementDecl>(109, false);
+    fEntityTable = new (fMemoryManager) ValueHashTableOf<XMLCh>(11);
+    fAttrNameHashList = new (fMemoryManager)ValueVectorOf<unsigned int>(16);
+    fAttrNSList = new (fMemoryManager) ValueVectorOf<XMLAttr*>(8);
+    fElements = new (fMemoryManager) RefVectorOf<XMLElementDecl>(32);
+    fElementLookup = new (fMemoryManager) RefHashTableOf<XMLElementDecl>(109, false);
 
     //  Add the default entity entries for the character refs that must always
     //  be present.
@@ -810,7 +812,10 @@ bool WFXMLScanner::scanStartTag(bool& gotData)
             elemDecl = fElements->elementAt(fElementIndex);
         }
         else {
-            elemDecl = new DTDElementDecl();
+            elemDecl = new (fMemoryManager) DTDElementDecl
+            (
+                fMemoryManager
+            );
             fElements->addElement(elemDecl);
         }
 
@@ -983,12 +988,15 @@ bool WFXMLScanner::scanStartTag(bool& gotData)
             XMLAttr* curAtt;
             if (attCount >= curAttListSize)
             {
-                curAtt = new XMLAttr
+                curAtt = new (fMemoryManager) XMLAttr
                 (
                     -1
                     , attNameRawBuf
                     , XMLUni::fgZeroLenString
                     , fAttValueBuf.getRawBuffer()
+                    , XMLAttDef::CData
+                    , true
+                    , fMemoryManager
                 );
                 fAttrList->addElement(curAtt);
                 fAttrNameHashList->addElement(attNameHash);
@@ -1131,7 +1139,10 @@ bool WFXMLScanner::scanStartTagNS(bool& gotData)
             elemDecl = fElements->elementAt(fElementIndex);
         }
         else {
-            elemDecl = new DTDElementDecl();
+            elemDecl = new (fMemoryManager) DTDElementDecl
+            (
+                fMemoryManager
+            );
             fElements->addElement(elemDecl);
         }
 
@@ -1300,11 +1311,14 @@ bool WFXMLScanner::scanStartTagNS(bool& gotData)
             XMLAttr* curAtt = 0;
             if (attCount >= curAttListSize)
             {
-                curAtt = new XMLAttr
+                curAtt = new (fMemoryManager) XMLAttr
                 (
                     fEmptyNamespaceId
                     , attNameRawBuf
                     , attValueRawBuf
+                    , XMLAttDef::CData
+                    , true
+                    , fMemoryManager
                 );
                 fAttrList->addElement(curAtt);
                 fAttrNameHashList->addElement(attNameHash);
diff --git a/src/xercesc/internal/WFXMLScanner.hpp b/src/xercesc/internal/WFXMLScanner.hpp
index 3582e7207..42830832e 100644
--- a/src/xercesc/internal/WFXMLScanner.hpp
+++ b/src/xercesc/internal/WFXMLScanner.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.5  2003/05/15 18:26:29  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.4  2003/03/07 18:08:58  tng
  * Return a reference instead of void for operator=
  *
@@ -94,6 +97,7 @@ public :
     WFXMLScanner
     (
         XMLValidator* const valToAdopt
+        , MemoryManager* const manager
     );
     WFXMLScanner
     (
@@ -102,6 +106,7 @@ public :
         , XMLEntityHandler* const  entityHandler
         , XMLErrorReporter* const  errReporter
         , XMLValidator* const      valToAdopt
+        , MemoryManager* const      manager
     );
     virtual ~WFXMLScanner();
 
diff --git a/src/xercesc/internal/XMLReader.cpp b/src/xercesc/internal/XMLReader.cpp
index 12a9c06be..546331504 100644
--- a/src/xercesc/internal/XMLReader.cpp
+++ b/src/xercesc/internal/XMLReader.cpp
@@ -70,7 +70,6 @@
 #include <xercesc/util/TransService.hpp>
 #include <xercesc/util/XMLEBCDICTranscoder.hpp>
 #include <xercesc/util/XMLString.hpp>
-#include <xercesc/framework/XMLBuffer.hpp>
 
 
 XERCES_CPP_NAMESPACE_BEGIN
@@ -158,6 +157,7 @@ XMLReader::XMLReader(const  XMLCh* const                pubId
     , fThrowAtEnd(throwAtEnd)
     , fTranscoder(0)
     , fType(type)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
     setXMLVersion(version);
 
@@ -237,6 +237,7 @@ XMLReader::XMLReader(const  XMLCh* const            pubId
     , fThrowAtEnd(throwAtEnd)
     , fTranscoder(0)
     , fType(type)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
     setXMLVersion(version);
 
@@ -276,6 +277,7 @@ XMLReader::XMLReader(const  XMLCh* const            pubId
             fEncodingStr
             , failReason
             , kCharBufSize
+            , fMemoryManager
         );
     }
      else
@@ -288,6 +290,7 @@ XMLReader::XMLReader(const  XMLCh* const            pubId
             fEncoding
             , failReason
             , kCharBufSize
+            , fMemoryManager
         );
 
     }
@@ -353,6 +356,7 @@ XMLReader::XMLReader(const  XMLCh* const            pubId
     , fThrowAtEnd(throwAtEnd)
     , fTranscoder(0)
     , fType(type)
+    , fMemoryManager(XMLPlatformUtils::fgMemoryManager)
 {
     setXMLVersion(version);
 
@@ -381,6 +385,7 @@ XMLReader::XMLReader(const  XMLCh* const            pubId
         fEncoding
         , failReason
         , kCharBufSize
+        , fMemoryManager
     );
 
     if (!fTranscoder)
@@ -476,6 +481,7 @@ bool XMLReader::refreshCharBuffer()
             fEncodingStr
             , failReason
             , kCharBufSize
+            , fMemoryManager
         );
 
         if (!fTranscoder)
@@ -1194,6 +1200,7 @@ bool XMLReader::setEncoding(const XMLCh* const newEncoding)
                 fEncodingStr
                 , failReason
                 , kCharBufSize
+                , fMemoryManager
             );
         }
     }
@@ -1216,6 +1223,7 @@ bool XMLReader::setEncoding(const XMLCh* const newEncoding)
             newBaseEncoding
             , failReason
             , kCharBufSize
+            , fMemoryManager
         );
 
         if (!fTranscoder)
diff --git a/src/xercesc/internal/XMLReader.hpp b/src/xercesc/internal/XMLReader.hpp
index 965bd64fb..c80074f66 100644
--- a/src/xercesc/internal/XMLReader.hpp
+++ b/src/xercesc/internal/XMLReader.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.13  2003/05/15 18:26:29  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.12  2003/01/27 16:50:27  knoaman
  * some cleanup.
  *
@@ -165,7 +168,6 @@
 #if !defined(XMLREADER_HPP)
 #define XMLREADER_HPP
 
-#include <xercesc/util/XMLUniDefs.hpp>
 #include <xercesc/util/XMLChar.hpp>
 #include <xercesc/framework/XMLRecognizer.hpp>
 #include <xercesc/framework/XMLBuffer.hpp>
@@ -175,7 +177,6 @@ XERCES_CPP_NAMESPACE_BEGIN
 class InputSource;
 class BinInputStream;
 class ReaderMgr;
-class XMLBuffer;
 class XMLScanner;
 class XMLTranscoder;
 
@@ -194,7 +195,7 @@ class XMLTranscoder;
 //  This is NOT to be derived from.
 //
 // ---------------------------------------------------------------------------
-class XMLPARSER_EXPORT XMLReader
+class XMLPARSER_EXPORT XMLReader : public XMemory
 {
 public:
     // -----------------------------------------------------------------------
@@ -577,6 +578,7 @@ private:
     XMLByte*                    fgCharCharsTable;
     bool                        fNEL;
     XMLVersion                  fXMLVersion;
+    MemoryManager*              fMemoryManager;
 };
 
 
diff --git a/src/xercesc/internal/XMLScanner.cpp b/src/xercesc/internal/XMLScanner.cpp
index 3d7d347bd..212097767 100644
--- a/src/xercesc/internal/XMLScanner.cpp
+++ b/src/xercesc/internal/XMLScanner.cpp
@@ -65,12 +65,10 @@
 #include <xercesc/internal/XMLScanner.hpp>
 #include <xercesc/util/Janitor.hpp>
 #include <xercesc/util/Mutexes.hpp>
-#include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/RuntimeException.hpp>
 #include <xercesc/util/UnexpectedEOFException.hpp>
 #include <xercesc/util/XMLMsgLoader.hpp>
 #include <xercesc/util/XMLRegisterCleanup.hpp>
-#include <xercesc/util/XMLUniDefs.hpp>
 #include <xercesc/framework/LocalFileInputSource.hpp>
 #include <xercesc/framework/URLInputSource.hpp>
 #include <xercesc/framework/XMLDocumentHandler.hpp>
@@ -165,7 +163,8 @@ static XMLMsgLoader& gScannerMsgLoader()
 // ---------------------------------------------------------------------------
 //  XMLScanner: Constructors and Destructor
 // ---------------------------------------------------------------------------
-XMLScanner::XMLScanner(XMLValidator* const valToAdopt) :
+XMLScanner::XMLScanner(XMLValidator* const valToAdopt,
+                       MemoryManager* const manager) :
 
     fCalculateSrcOfs(false)
     , fDoNamespaces(false)
@@ -197,6 +196,7 @@ XMLScanner::XMLScanner(XMLValidator* const valToAdopt) :
     , fErrorReporter(0)
     , fErrorHandler(0)
     , fIDRefList(0)
+    , fReaderMgr(manager)
     , fValidator(valToAdopt)
     , fValScheme(Val_Never)
     , fGrammarResolver(0)
@@ -209,6 +209,14 @@ XMLScanner::XMLScanner(XMLValidator* const valToAdopt) :
     , fStandardUriConformant(false)
     , fSecurityManager(0)
     , fXMLVersion(XMLReader::XMLV1_0)
+    , fMemoryManager(manager)
+    , fBufMgr(manager)
+    , fAttNameBuf(1023, manager)
+    , fAttValueBuf(1023, manager)
+    , fCDataBuf(1023, manager)
+    , fQNameBuf(1023, manager)
+    , fPrefixBuf(1023, manager)
+    , fURIBuf(1023, manager)
 {
    commonInit();
 
@@ -222,7 +230,8 @@ XMLScanner::XMLScanner( XMLDocumentHandler* const  docHandler
                           , DocTypeHandler* const    docTypeHandler
                           , XMLEntityHandler* const  entityHandler
                           , XMLErrorReporter* const  errHandler
-                          , XMLValidator* const      valToAdopt) :
+                          , XMLValidator* const      valToAdopt
+                          , MemoryManager* const     manager) :
 
     fCalculateSrcOfs(false)
     , fDoNamespaces(false)
@@ -254,6 +263,7 @@ XMLScanner::XMLScanner( XMLDocumentHandler* const  docHandler
     , fErrorReporter(errHandler)
     , fErrorHandler(0)
     , fIDRefList(0)
+    , fReaderMgr(manager)
     , fValidator(valToAdopt)
     , fValScheme(Val_Never)
     , fGrammarResolver(0)
@@ -266,6 +276,14 @@ XMLScanner::XMLScanner( XMLDocumentHandler* const  docHandler
     , fStandardUriConformant(false)
     , fSecurityManager(0)
     , fXMLVersion(XMLReader::XMLV1_0)
+    , fMemoryManager(manager)
+    , fBufMgr(manager)
+    , fAttNameBuf(1023, manager)
+    , fAttValueBuf(1023, manager)
+    , fCDataBuf(1023, manager)
+    , fQNameBuf(1023, manager)
+    , fPrefixBuf(1023, manager)
+    , fURIBuf(1023, manager)
 {
    commonInit();
 
@@ -279,9 +297,9 @@ XMLScanner::~XMLScanner()
 {
     delete fAttrList;
     delete fIDRefList;
-    delete [] fRootElemName;
-    delete [] fExternalSchemaLocation;
-    delete [] fExternalNoNamespaceSchemaLocation;
+    fMemoryManager->deallocate(fRootElemName);//delete [] fRootElemName;
+    fMemoryManager->deallocate(fExternalSchemaLocation);//delete [] fExternalSchemaLocation;
+    fMemoryManager->deallocate(fExternalNoNamespaceSchemaLocation);//delete [] fExternalNoNamespaceSchemaLocation;
 }
 
 
@@ -312,7 +330,7 @@ void XMLScanner::scanDocument(  const   XMLCh* const    systemId)
         XMLURL tmpURL(systemId);
         if (tmpURL.isRelative()) {
             if (!fStandardUriConformant)
-                srcToUse = new LocalFileInputSource(systemId);
+                srcToUse = new (fMemoryManager) LocalFileInputSource(systemId);
             else {
                 // since this is the top of the try/catch, cannot call ThrowXML
                 // emit the error directly
@@ -340,14 +358,14 @@ void XMLScanner::scanDocument(  const   XMLCh* const    systemId)
                 );
                 return;
             }
-            srcToUse = new URLInputSource(tmpURL);
+            srcToUse = new (fMemoryManager) URLInputSource(tmpURL);
         }
 
     }
     catch(const MalformedURLException& e)
     {
         if (!fStandardUriConformant)
-            srcToUse = new LocalFileInputSource(systemId);
+            srcToUse = new (fMemoryManager) LocalFileInputSource(systemId);
         else {
             // since this is the top of the try/catch, cannot call ThrowXML
             // emit the error directly
@@ -404,8 +422,8 @@ void XMLScanner::scanDocument(  const   XMLCh* const    systemId)
 void XMLScanner::scanDocument(  const   char* const systemId)
 {
     // We just delegate this to the XMLCh version after transcoding
-    XMLCh* tmpBuf = XMLString::transcode(systemId);
-    ArrayJanitor<XMLCh> janBuf(tmpBuf);
+    XMLCh* tmpBuf = XMLString::transcode(systemId, fMemoryManager);
+    ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager);
     scanDocument(tmpBuf);
 }
 
@@ -429,7 +447,7 @@ bool XMLScanner::scanFirst( const   XMLCh* const    systemId
         XMLURL tmpURL(systemId);
         if (tmpURL.isRelative()) {
             if (!fStandardUriConformant)
-                srcToUse = new LocalFileInputSource(systemId);
+                srcToUse = new (fMemoryManager) LocalFileInputSource(systemId);
             else {
                 // since this is the top of the try/catch, cannot call ThrowXML
                 // emit the error directly
@@ -457,13 +475,13 @@ bool XMLScanner::scanFirst( const   XMLCh* const    systemId
                 );
                 return false;
             }
-            srcToUse = new URLInputSource(tmpURL);
+            srcToUse = new (fMemoryManager) URLInputSource(tmpURL);
         }
     }
     catch(const MalformedURLException& e)
     {
         if (!fStandardUriConformant)
-            srcToUse = new LocalFileInputSource(systemId);
+            srcToUse = new (fMemoryManager) LocalFileInputSource(systemId);
         else {
             // since this is the top of the try/catch, cannot call ThrowXML
             // emit the error directly
@@ -520,8 +538,8 @@ bool XMLScanner::scanFirst( const   char* const     systemId
                             ,       XMLPScanToken&  toFill)
 {
     // We just delegate this to the XMLCh version after transcoding
-    XMLCh* tmpBuf = XMLString::transcode(systemId);
-    ArrayJanitor<XMLCh> janBuf(tmpBuf);
+    XMLCh* tmpBuf = XMLString::transcode(systemId, fMemoryManager);
+    ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager);
     return scanFirst(tmpBuf, toFill);
 }
 
@@ -684,11 +702,11 @@ void XMLScanner::commonInit()
     //  Create the attribute list, which is used to store attribute values
     //  during start tag processing. Give it a reasonable initial size that
     //  will serve for most folks, though it will grow as required.
-    fAttrList = new RefVectorOf<XMLAttr>(32);
+    fAttrList = new (fMemoryManager) RefVectorOf<XMLAttr>(32);
 
     //  Create the id ref list. This is used to enforce XML 1.0 ID ref
     //  semantics, i.e. all id refs must refer to elements that exist
-    fIDRefList = new RefHashTableOf<XMLRefInfo>(109);
+    fIDRefList = new (fMemoryManager) RefHashTableOf<XMLRefInfo>(109);
 
     //  Create the GrammarResolver
     //fGrammarResolver = new GrammarResolver();
@@ -1557,7 +1575,7 @@ Grammar* XMLScanner::loadGrammar(const   XMLCh* const systemId
             if (tmpURL.isRelative())
             {
                 if (!fStandardUriConformant)
-                    srcToUse = new LocalFileInputSource(systemId);
+                    srcToUse = new (fMemoryManager) LocalFileInputSource(systemId);
                 else {
                     // since this is the top of the try/catch, cannot call ThrowXML
                     // emit the error directly
@@ -1585,13 +1603,13 @@ Grammar* XMLScanner::loadGrammar(const   XMLCh* const systemId
                     );
                     return 0;
                 }
-                srcToUse = new URLInputSource(tmpURL);
+                srcToUse = new (fMemoryManager) URLInputSource(tmpURL);
             }
         }
         catch(const MalformedURLException& e)
         {
             if (!fStandardUriConformant)
-                srcToUse = new LocalFileInputSource(systemId);
+                srcToUse = new (fMemoryManager) LocalFileInputSource(systemId);
             else {
                 // since this is the top of the try/catch, cannot call ThrowXML
                 // emit the error directly
@@ -1650,8 +1668,8 @@ Grammar* XMLScanner::loadGrammar(const   char* const systemId
                                  , const bool        toCache)
 {
     // We just delegate this to the XMLCh version after transcoding
-    XMLCh* tmpBuf = XMLString::transcode(systemId);
-    ArrayJanitor<XMLCh> janBuf(tmpBuf);
+    XMLCh* tmpBuf = XMLString::transcode(systemId, fMemoryManager);
+    ArrayJanitor<XMLCh> janBuf(tmpBuf, fMemoryManager);
     return loadGrammar(tmpBuf, grammarType, toCache);
 }
 
diff --git a/src/xercesc/internal/XMLScanner.hpp b/src/xercesc/internal/XMLScanner.hpp
index 1d5a0b98f..76daf3df3 100644
--- a/src/xercesc/internal/XMLScanner.hpp
+++ b/src/xercesc/internal/XMLScanner.hpp
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.21  2003/05/15 18:26:29  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.20  2003/04/22 14:52:37  knoaman
  * Initialize security manager in constructor.
  *
@@ -270,6 +273,7 @@
 #include <xercesc/framework/XMLBufferMgr.hpp>
 #include <xercesc/framework/XMLErrorCodes.hpp>
 #include <xercesc/framework/XMLRefInfo.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/NameIdPool.hpp>
 #include <xercesc/util/RefHashTableOf.hpp>
 #include <xercesc/util/SecurityManager.hpp>
@@ -290,12 +294,13 @@ class XMLStringPool;
 class Grammar;
 class GrammarResolver;
 class XMLValidator;
+class MemoryManager;
 
 
 //  This is the mondo scanner class, which does the vast majority of the
 //  work of parsing. It handles reading in input and spitting out events
 //  to installed handlers.
-class XMLPARSER_EXPORT XMLScanner
+class XMLPARSER_EXPORT XMLScanner : public XMemory
 {
 public :
     // -----------------------------------------------------------------------
@@ -360,6 +365,7 @@ public :
     XMLScanner
     (
         XMLValidator* const valToAdopt
+        , MemoryManager* const manager// = XMLPlatformUtils::fgMemoryManager
     );
     XMLScanner
     (
@@ -368,6 +374,7 @@ public :
         , XMLEntityHandler* const  entityHandler
         , XMLErrorReporter* const  errReporter
         , XMLValidator* const      valToAdopt
+        , MemoryManager* const manager// = XMLPlatformUtils::fgMemoryManager
     );
     virtual ~XMLScanner();
 
@@ -470,6 +477,7 @@ public :
     bool getCalculateSrcOfs() const;
     Grammar* getRootGrammar() const;
     XMLReader::XMLVersion getXMLVersion() const;
+    MemoryManager* getMemoryManager() const;
 
     // -----------------------------------------------------------------------
     //  Getter methods
@@ -844,11 +852,11 @@ protected:
     //  fSecurityManager
     //      The SecurityManager instance; as and when set by the application.
     //
-    // fEntityExpansionLimit
+    //  fEntityExpansionLimit
     //      The number of entity expansions to be permitted while processing this document
     //      Only meaningful when fSecurityManager != 0
     //
-    // fEntityExpansionCount
+    //  fEntityExpansionCount
     //      The number of general entities expanded so far in this document.
     //      Only meaningful when fSecurityManager != null
     //
@@ -868,6 +876,9 @@ protected:
     //
     //  fXMLVersion
     //      Enum to indicate if the main doc is XML 1.1 or XML 1.0 conformant    
+    //
+    //  fMemoryManager
+    //      Pluggable memory manager for dynamic allocation/deallocation.
     // -----------------------------------------------------------------------
     bool                        fStandardUriConformant;
     bool                        fCalculateSrcOfs;
@@ -886,8 +897,8 @@ protected:
     bool                        fLoadExternalDTD;
     bool                        fNormalizeData;
     int                         fErrorCount;
-    unsigned int fEntityExpansionLimit;
-    unsigned int fEntityExpansionCount;
+    unsigned int                fEntityExpansionLimit;
+    unsigned int                fEntityExpansionCount;
     unsigned int                fEmptyNamespaceId;
     unsigned int                fUnknownNamespaceId;
     unsigned int                fXMLNamespaceId;
@@ -896,7 +907,6 @@ protected:
     XMLUInt32                   fScannerId;
     XMLUInt32                   fSequenceId;
     RefVectorOf<XMLAttr>*       fAttrList;
-    XMLBufferMgr                fBufMgr;
     XMLDocumentHandler*         fDocHandler;
     DocTypeHandler*             fDocTypeHandler;
     XMLEntityHandler*           fEntityHandler;
@@ -906,12 +916,6 @@ protected:
     ReaderMgr                   fReaderMgr;
     XMLValidator*               fValidator;
     ValSchemes                  fValScheme;
-    XMLBuffer                   fAttNameBuf;
-    XMLBuffer                   fAttValueBuf;
-    XMLBuffer                   fCDataBuf;
-    XMLBuffer                   fQNameBuf;
-    XMLBuffer                   fPrefixBuf;
-    XMLBuffer                   fURIBuf;
     GrammarResolver*            fGrammarResolver;
     Grammar*                    fGrammar;
     Grammar*                    fRootGrammar;
@@ -920,7 +924,15 @@ protected:
     XMLCh*                      fExternalSchemaLocation;
     XMLCh*                      fExternalNoNamespaceSchemaLocation;
     SecurityManager*            fSecurityManager;
-    XMLReader::XMLVersion       fXMLVersion;    
+    XMLReader::XMLVersion       fXMLVersion;
+    MemoryManager*              fMemoryManager;
+    XMLBufferMgr                fBufMgr;
+    XMLBuffer                   fAttNameBuf;
+    XMLBuffer                   fAttValueBuf;
+    XMLBuffer                   fCDataBuf;
+    XMLBuffer                   fQNameBuf;
+    XMLBuffer                   fPrefixBuf;
+    XMLBuffer                   fURIBuf;
 
 private :
     // -----------------------------------------------------------------------
@@ -1174,6 +1186,11 @@ inline XMLReader::XMLVersion XMLScanner::getXMLVersion() const
 	return fXMLVersion;
 }
 
+inline MemoryManager* XMLScanner::getMemoryManager() const
+{
+    return fMemoryManager;
+}
+
 // ---------------------------------------------------------------------------
 //  XMLScanner: Setter methods
 // ---------------------------------------------------------------------------
@@ -1253,32 +1270,32 @@ inline void XMLScanner::setHasNoDTD(const bool hasNoDTD)
 
 inline void XMLScanner::setRootElemName(XMLCh* rootElemName)
 {
-    delete [] fRootElemName;
-    fRootElemName = XMLString::replicate(rootElemName);
+    fMemoryManager->deallocate(fRootElemName);//delete [] fRootElemName;
+    fRootElemName = XMLString::replicate(rootElemName, fMemoryManager);
 }
 
 inline void XMLScanner::setExternalSchemaLocation(const XMLCh* const schemaLocation)
 {
-    delete [] fExternalSchemaLocation;
-    fExternalSchemaLocation = XMLString::replicate(schemaLocation);
+    fMemoryManager->deallocate(fExternalSchemaLocation);//delete [] fExternalSchemaLocation;
+    fExternalSchemaLocation = XMLString::replicate(schemaLocation, fMemoryManager);
 }
 
 inline void XMLScanner::setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation)
 {
-    delete [] fExternalNoNamespaceSchemaLocation;
-    fExternalNoNamespaceSchemaLocation = XMLString::replicate(noNamespaceSchemaLocation);
+    fMemoryManager->deallocate(fExternalNoNamespaceSchemaLocation);//delete [] fExternalNoNamespaceSchemaLocation;
+    fExternalNoNamespaceSchemaLocation = XMLString::replicate(noNamespaceSchemaLocation, fMemoryManager);
 }
 
 inline void XMLScanner::setExternalSchemaLocation(const char* const schemaLocation)
 {
-    delete [] fExternalSchemaLocation;
-    fExternalSchemaLocation = XMLString::transcode(schemaLocation);
+    fMemoryManager->deallocate(fExternalSchemaLocation);//delete [] fExternalSchemaLocation;
+    fExternalSchemaLocation = XMLString::transcode(schemaLocation, fMemoryManager);
 }
 
 inline void XMLScanner::setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation)
 {
-    delete [] fExternalNoNamespaceSchemaLocation;
-    fExternalNoNamespaceSchemaLocation = XMLString::transcode(noNamespaceSchemaLocation);
+    fMemoryManager->deallocate(fExternalNoNamespaceSchemaLocation);//delete [] fExternalNoNamespaceSchemaLocation;
+    fExternalNoNamespaceSchemaLocation = XMLString::transcode(noNamespaceSchemaLocation, fMemoryManager);
 }
 
 inline void XMLScanner::setSecurityManager(SecurityManager* const securityManager)
diff --git a/src/xercesc/internal/XMLScannerResolver.cpp b/src/xercesc/internal/XMLScannerResolver.cpp
index c5e83346c..8e8014834 100644
--- a/src/xercesc/internal/XMLScannerResolver.cpp
+++ b/src/xercesc/internal/XMLScannerResolver.cpp
@@ -74,44 +74,47 @@ XERCES_CPP_NAMESPACE_BEGIN
 //  XMLScannerResolver: Public static methods
 // ---------------------------------------------------------------------------
 XMLScanner*
-XMLScannerResolver::getDefaultScanner(XMLValidator* const valToAdopt)
+XMLScannerResolver::getDefaultScanner( XMLValidator* const  valToAdopt
+                                     , MemoryManager* const manager)
 {
-    return new IGXMLScanner(valToAdopt);
+    return new (manager) IGXMLScanner(valToAdopt, manager);
 }
 
 XMLScanner*
-XMLScannerResolver::resolveScanner(const XMLCh* const scannerName,
-                                   XMLValidator* const valToAdopt)
+XMLScannerResolver::resolveScanner( const XMLCh* const   scannerName
+                                  , XMLValidator* const  valToAdopt
+                                  , MemoryManager* const manager)
 {
     if (XMLString::equals(scannerName, XMLUni::fgWFXMLScanner))
-        return new WFXMLScanner(valToAdopt);
+        return new (manager) WFXMLScanner(valToAdopt, manager);
     else if (XMLString::equals(scannerName, XMLUni::fgIGXMLScanner))
-        return new IGXMLScanner(valToAdopt);
+        return new (manager) IGXMLScanner(valToAdopt, manager);
     else if (XMLString::equals(scannerName, XMLUni::fgSGXMLScanner))
-        return new SGXMLScanner(valToAdopt);
+        return new (manager) SGXMLScanner(valToAdopt, manager);
     else if (XMLString::equals(scannerName, XMLUni::fgDGXMLScanner))
-        return new DGXMLScanner(valToAdopt);
+        return new (manager) DGXMLScanner(valToAdopt, manager);
 
     // REVISIT: throw an exception or return a default one?
     return 0;
 }
 
 XMLScanner*
-XMLScannerResolver::resolveScanner(const XMLCh* const scannerName,
-                                   XMLDocumentHandler* const docHandler,
-                                   DocTypeHandler* const docTypeHandler,
-                                   XMLEntityHandler* const entityHandler,
-                                   XMLErrorReporter* const errReporter,
-                                   XMLValidator* const valToAdopt)
+XMLScannerResolver::resolveScanner( const XMLCh* const        scannerName
+                                  , XMLDocumentHandler* const docHandler
+                                  , DocTypeHandler* const     docTypeHandler
+                                  , XMLEntityHandler* const   entityHandler
+                                  , XMLErrorReporter* const   errReporter
+                                  , XMLValidator* const       valToAdopt
+                                  , MemoryManager* const      manager)
 {
     if (XMLString::equals(scannerName, XMLUni::fgWFXMLScanner))
-        return new WFXMLScanner(docHandler, docTypeHandler, entityHandler, errReporter, valToAdopt);
+        return new (manager) WFXMLScanner(docHandler, docTypeHandler, entityHandler, errReporter, valToAdopt, manager);
     else if (XMLString::equals(scannerName, XMLUni::fgIGXMLScanner))
-        return new IGXMLScanner(docHandler, docTypeHandler, entityHandler, errReporter, valToAdopt);
+        return new (manager) IGXMLScanner(docHandler, docTypeHandler, entityHandler, errReporter, valToAdopt, manager);
     else if (XMLString::equals(scannerName, XMLUni::fgSGXMLScanner))
-        return new SGXMLScanner(docHandler, docTypeHandler, entityHandler, errReporter, valToAdopt);
+        return new (manager) SGXMLScanner(docHandler, docTypeHandler, entityHandler, errReporter, valToAdopt, manager);
     else if (XMLString::equals(scannerName, XMLUni::fgDGXMLScanner))
-        return new DGXMLScanner(docHandler, docTypeHandler, entityHandler, errReporter, valToAdopt);
+        return new (manager) DGXMLScanner(docHandler, docTypeHandler, entityHandler, errReporter, valToAdopt, manager);
 
     // REVISIT: throw an exception or return a default one?
     return 0;
diff --git a/src/xercesc/internal/XMLScannerResolver.hpp b/src/xercesc/internal/XMLScannerResolver.hpp
index 28c7b3d09..36843d774 100644
--- a/src/xercesc/internal/XMLScannerResolver.hpp
+++ b/src/xercesc/internal/XMLScannerResolver.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.2  2003/05/15 18:26:29  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.1  2002/12/04 01:44:21  knoaman
  * Initial check-in.
  *
@@ -82,23 +85,26 @@ public:
     // -----------------------------------------------------------------------
     static XMLScanner* resolveScanner
     (
-        const XMLCh* const        scannerName
-        ,     XMLValidator* const valToAdopt
+          const XMLCh* const   scannerName
+        , XMLValidator* const  valToAdopt
+        , MemoryManager* const manager   
     );
 
     static XMLScanner* resolveScanner
     (
-        const XMLCh* const              scannerName
-        ,     XMLDocumentHandler* const docHandler
-        ,     DocTypeHandler* const     docTypeHandler
-        ,     XMLEntityHandler* const   entityHandler
-        ,     XMLErrorReporter* const   errReporter
-        ,     XMLValidator* const       valToAdopt
+          const XMLCh* const        scannerName
+        , XMLDocumentHandler* const docHandler
+        , DocTypeHandler* const     docTypeHandler
+        , XMLEntityHandler* const   entityHandler
+        , XMLErrorReporter* const   errReporter
+        , XMLValidator* const       valToAdopt
+        , MemoryManager* const      manager
     );
 
     static XMLScanner* getDefaultScanner
     (
-        XMLValidator* const valToAdopt
+          XMLValidator* const  valToAdopt
+        , MemoryManager* const manager
     );
 
 private :
diff --git a/src/xercesc/parsers/AbstractDOMParser.cpp b/src/xercesc/parsers/AbstractDOMParser.cpp
index 0bcc9c586..22bb08dd0 100644
--- a/src/xercesc/parsers/AbstractDOMParser.cpp
+++ b/src/xercesc/parsers/AbstractDOMParser.cpp
@@ -102,7 +102,8 @@ XERCES_CPP_NAMESPACE_BEGIN
 // ---------------------------------------------------------------------------
 //  AbstractDOMParser: Constructors and Destructor
 // ---------------------------------------------------------------------------
-AbstractDOMParser::AbstractDOMParser(XMLValidator* const valToAdopt) :
+AbstractDOMParser::AbstractDOMParser( XMLValidator* const valToAdopt
+                                    , MemoryManager* const manager) :
 
   fCreateEntityReferenceNodes(true)
 , fIncludeIgnorableWhitespace(true)
@@ -121,6 +122,8 @@ AbstractDOMParser::AbstractDOMParser(XMLValidator* const valToAdopt) :
 , fGrammarResolver(0)
 , fURIStringPool(0)
 , fValidator(valToAdopt)
+, fMemoryManager(manager)
+, fBufMgr(manager)
 , fInternalSubset(fBufMgr.bidOnBuffer())
 {
     try
@@ -146,18 +149,18 @@ AbstractDOMParser::~AbstractDOMParser()
 void AbstractDOMParser::initialize()
 {
     //  Create grammar resolver and 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<DOMNode*>(64);
+    fNodeStack = new (fMemoryManager) ValueStackOf<DOMNode*>(64);
     this->reset();
 }
 
@@ -187,7 +190,7 @@ void AbstractDOMParser::reset()
     if (fDocument && !fDocumentAdoptedByUser) {
         if (!fDocumentVector) {
             // allocate the vector if not exists yet
-            fDocumentVector  = new RefVectorOf<DOMDocumentImpl>(10, true) ;
+            fDocumentVector  = new (fMemoryManager) RefVectorOf<DOMDocumentImpl>(10, true) ;
         }
         fDocumentVector->addElement(fDocument);
     }
@@ -402,7 +405,12 @@ void AbstractDOMParser::setStandardUriConformant(const bool newState)
 
 void AbstractDOMParser::useScanner(const XMLCh* const scannerName)
 {
-    XMLScanner* tempScanner = XMLScannerResolver::resolveScanner(scannerName, fValidator);
+    XMLScanner* tempScanner = XMLScannerResolver::resolveScanner
+    (
+        scannerName
+        , fValidator
+        , fMemoryManager
+    );
 
     if (tempScanner) {
 
diff --git a/src/xercesc/parsers/AbstractDOMParser.hpp b/src/xercesc/parsers/AbstractDOMParser.hpp
index 7e36d44f0..8c58413bb 100644
--- a/src/xercesc/parsers/AbstractDOMParser.hpp
+++ b/src/xercesc/parsers/AbstractDOMParser.hpp
@@ -90,7 +90,8 @@ class GrammarResolver;
   */
 class PARSERS_EXPORT AbstractDOMParser :
 
-    public XMLDocumentHandler
+    public XMemory
+    , public XMLDocumentHandler
     , public XMLErrorReporter
     , public XMLEntityHandler
     , public DocTypeHandler
@@ -1307,7 +1308,11 @@ protected :
       * @param valToAdopt Pointer to the validator instance to use. The
       *                   parser is responsible for freeing the memory.
       */
-    AbstractDOMParser(XMLValidator* const valToAdopt = 0);
+    AbstractDOMParser
+    (
+          XMLValidator* const valToAdopt = 0
+        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
+    );
 
     //@}
 
@@ -1468,7 +1473,6 @@ private :
     bool                          fParseInProgress;
     bool                          fCreateCommentNodes;
     bool                          fDocumentAdoptedByUser;
-    XMLBufferMgr                  fBufMgr;
     XMLScanner*                   fScanner;
     DOMNode*                      fCurrentParent;
     DOMNode*                      fCurrentNode;
@@ -1480,6 +1484,8 @@ private :
     GrammarResolver*              fGrammarResolver;
     XMLStringPool*                fURIStringPool;
     XMLValidator*                 fValidator;
+    MemoryManager*                fMemoryManager;
+    XMLBufferMgr                  fBufMgr;
     XMLBuffer&                    fInternalSubset;
 };
 
diff --git a/src/xercesc/parsers/DOMBuilderImpl.cpp b/src/xercesc/parsers/DOMBuilderImpl.cpp
index 8eb36ecac..3fc262fdf 100644
--- a/src/xercesc/parsers/DOMBuilderImpl.cpp
+++ b/src/xercesc/parsers/DOMBuilderImpl.cpp
@@ -87,9 +87,10 @@ XERCES_CPP_NAMESPACE_BEGIN
 // ---------------------------------------------------------------------------
 //  DOMBuilderImpl: Constructors and Destructor
 // ---------------------------------------------------------------------------
-DOMBuilderImpl::DOMBuilderImpl(XMLValidator* const valToAdopt) :
+DOMBuilderImpl::DOMBuilderImpl( XMLValidator* const  valToAdopt
+                              , MemoryManager* const manager) :
 
-AbstractDOMParser(valToAdopt)
+AbstractDOMParser(valToAdopt, manager)
 , fAutoValidation(false)
 , fValidation(false)
 , fErrorHandler(0)
diff --git a/src/xercesc/parsers/DOMBuilderImpl.hpp b/src/xercesc/parsers/DOMBuilderImpl.hpp
index a5c505d3b..46bd98d69 100644
--- a/src/xercesc/parsers/DOMBuilderImpl.hpp
+++ b/src/xercesc/parsers/DOMBuilderImpl.hpp
@@ -96,7 +96,11 @@ public :
       * @param valToAdopt Pointer to the validator instance to use. The
       *                   parser is responsible for freeing the memory.
       */
-    DOMBuilderImpl(XMLValidator* const valToAdopt = 0);
+    DOMBuilderImpl
+    (
+          XMLValidator* const  valToAdopt = 0
+        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
+    );
 
     /**
       * Destructor
diff --git a/src/xercesc/parsers/SAX2XMLReaderImpl.cpp b/src/xercesc/parsers/SAX2XMLReaderImpl.cpp
index ef0d9762b..81c7952fd 100644
--- a/src/xercesc/parsers/SAX2XMLReaderImpl.cpp
+++ b/src/xercesc/parsers/SAX2XMLReaderImpl.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.18  2003/05/15 18:26:50  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.17  2003/04/17 21:58:50  neilg
  * Adding a new property,
  * http://apache.org/xml/properties/security-manager, with
@@ -280,7 +283,7 @@ const XMLCh gDTDEntityStr[] =
     chOpenSquare, chLatin_d, chLatin_t, chLatin_d, chCloseSquare, chNull
 };
 
-SAX2XMLReaderImpl::SAX2XMLReaderImpl() :
+SAX2XMLReaderImpl::SAX2XMLReaderImpl(MemoryManager* const manager) :
 
     fNamespacePrefix(false)
     , fAutoValidation(false)
@@ -304,6 +307,8 @@ SAX2XMLReaderImpl::SAX2XMLReaderImpl() :
     , fGrammarResolver(0)
     , fURIStringPool(0)
     , fValidator(0)
+    , fMemoryManager(manager)
+    , fStringBuffers(manager)
 {
     try
     {
@@ -327,17 +332,20 @@ SAX2XMLReaderImpl::~SAX2XMLReaderImpl()
 void SAX2XMLReaderImpl::initialize()
 {
     // Create grammar resolver and string pool that we 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(0);
+    fScanner = XMLScannerResolver::getDefaultScanner(0, fMemoryManager);
     fScanner->setGrammarResolver(fGrammarResolver);
     fScanner->setURIStringPool(fURIStringPool);
 
     // Create the initial advanced handler list array and zero it out
-    fAdvDHList = new XMLDocumentHandler*[fAdvDHListSize];
+    fAdvDHList = (XMLDocumentHandler**) fMemoryManager->allocate
+    (
+        fAdvDHListSize * sizeof(XMLDocumentHandler*)
+    );//new XMLDocumentHandler*[fAdvDHListSize];
     memset(fAdvDHList, 0, sizeof(void*) * fAdvDHListSize);
 	
 	// SAX2 default is for namespaces (feature http://xml.org/sax/features/namespaces) to be on
@@ -346,15 +354,15 @@ void SAX2XMLReaderImpl::initialize()
 	// default: schema is on
 	setDoSchema(true);
 	
-	fPrefixes    = new RefStackOf<XMLBuffer> (10, false) ;
-	fTempAttrVec  = new RefVectorOf<XMLAttr>  (10, false) ;
-	fPrefixCounts = new ValueStackOf<unsigned int>(10) ;
+	fPrefixes    = new (fMemoryManager) RefStackOf<XMLBuffer> (10, false) ;
+	fTempAttrVec  = new (fMemoryManager) RefVectorOf<XMLAttr>  (10, false) ;
+	fPrefixCounts = new (fMemoryManager) ValueStackOf<unsigned int>(10) ;
 }
 
 
 void SAX2XMLReaderImpl::cleanUp()
 {
-    delete [] fAdvDHList;
+    fMemoryManager->deallocate(fAdvDHList);//delete [] fAdvDHList;
     delete fScanner;
     delete fPrefixes;
     delete fTempAttrVec;
@@ -373,7 +381,10 @@ void SAX2XMLReaderImpl::installAdvDocHandler(XMLDocumentHandler* const toInstall
     {
         // Calc a new size and allocate the new temp buffer
         const unsigned int newSize = (unsigned int)(fAdvDHListSize * 1.5);
-        XMLDocumentHandler** newList = new XMLDocumentHandler*[newSize];
+        XMLDocumentHandler** newList = (XMLDocumentHandler**) fMemoryManager->allocate
+        (
+            newSize * sizeof(XMLDocumentHandler*)
+        );//new XMLDocumentHandler*[newSize];
 
         // Copy over the old data to the new list and zero out the rest
         memcpy(newList, fAdvDHList, sizeof(void*) * fAdvDHListSize);
@@ -385,7 +396,7 @@ void SAX2XMLReaderImpl::installAdvDocHandler(XMLDocumentHandler* const toInstall
         );
 
         // And now clean up the old array and store the new stuff
-        delete [] fAdvDHList;
+        fMemoryManager->deallocate(fAdvDHList);//delete [] fAdvDHList;
         fAdvDHList = newList;
         fAdvDHListSize = newSize;
     }
@@ -1226,9 +1237,12 @@ void SAX2XMLReaderImpl::entityDecl( const   DTDEntityDecl&  entityDecl
             if (isPEDecl) {
 
                 unsigned int nameLen = XMLString::stringLen(entityName);
-                XMLCh* tmpName = new XMLCh[nameLen + 2];
+                XMLCh* tmpName = (XMLCh*) fMemoryManager->allocate
+                (
+                    (nameLen + 2) * sizeof(XMLCh)
+                );//new XMLCh[nameLen + 2];
 
-                tmpNameJan.reset(tmpName);
+                tmpNameJan.reset(tmpName, fMemoryManager);
                 tmpName[0] = chPercent;
                 XMLString::copyString(tmpName + 1, entityName);
                 entityName = tmpName;
@@ -1522,7 +1536,12 @@ void SAX2XMLReaderImpl::setProperty(const XMLCh* const name, void* value)
 	}
     else if (XMLString::equals(name, XMLUni::fgXercesScannerName))
     {
-        XMLScanner* tempScanner = XMLScannerResolver::resolveScanner((const XMLCh*) value, fValidator);
+        XMLScanner* tempScanner = XMLScannerResolver::resolveScanner
+        (
+            (const XMLCh*) value
+            , fValidator
+            , fMemoryManager
+        );
 
         if (tempScanner) {
 
diff --git a/src/xercesc/parsers/SAX2XMLReaderImpl.hpp b/src/xercesc/parsers/SAX2XMLReaderImpl.hpp
index b6bbbc37d..e71038a40 100644
--- a/src/xercesc/parsers/SAX2XMLReaderImpl.hpp
+++ b/src/xercesc/parsers/SAX2XMLReaderImpl.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.20  2003/05/15 18:26:50  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.19  2003/04/17 21:58:50  neilg
  * Adding a new property,
  * http://apache.org/xml/properties/security-manager, with
@@ -253,7 +256,8 @@ class GrammarResolver;
   */
 
 class PARSERS_EXPORT SAX2XMLReaderImpl :
-	public SAX2XMLReader
+	public XMemory
+    , public SAX2XMLReader
     , public XMLDocumentHandler
     , public XMLErrorReporter
     , public XMLEntityHandler
@@ -266,7 +270,7 @@ public :
     /** @name Constructors and Destructor */
     //@{
     /** The default constructor */
-	SAX2XMLReaderImpl() ;
+	SAX2XMLReaderImpl(MemoryManager* const manager) ;
 
     /** The destructor */	
 	~SAX2XMLReaderImpl() ;
@@ -1783,7 +1787,6 @@ private :
     VecAttributesImpl		fAttrList ;
     ContentHandler*		fDocHandler ;
     RefVectorOf<XMLAttr>*       fTempAttrVec ;
-    XMLBufferMgr		fStringBuffers ;
     RefStackOf<XMLBuffer> *     fPrefixes ;
     ValueStackOf<unsigned int>* fPrefixCounts ;
     DTDHandler*                 fDTDHandler;
@@ -1796,6 +1799,8 @@ private :
     GrammarResolver*            fGrammarResolver;
     XMLStringPool*              fURIStringPool;
     XMLValidator*               fValidator;
+    MemoryManager*              fMemoryManager;
+    XMLBufferMgr		        fStringBuffers ;
 	
     // -----------------------------------------------------------------------
     // internal function used to set the state of the parser
diff --git a/src/xercesc/parsers/SAXParser.cpp b/src/xercesc/parsers/SAXParser.cpp
index 833fab16b..630cb9ded 100644
--- a/src/xercesc/parsers/SAXParser.cpp
+++ b/src/xercesc/parsers/SAXParser.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.17  2003/05/15 18:26:50  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.16  2003/04/17 21:58:50  neilg
  * Adding a new property,
  * http://apache.org/xml/properties/security-manager, with
@@ -242,7 +245,8 @@ XERCES_CPP_NAMESPACE_BEGIN
 // ---------------------------------------------------------------------------
 //  SAXParser: Constructors and Destructor
 // ---------------------------------------------------------------------------
-SAXParser::SAXParser(XMLValidator* const valToAdopt) :
+SAXParser::SAXParser( XMLValidator* const  valToAdopt
+                    , MemoryManager* const manager) :
 
     fParseInProgress(false)
     , fElemDepth(0)
@@ -257,6 +261,7 @@ SAXParser::SAXParser(XMLValidator* const valToAdopt) :
     , fGrammarResolver(0)
     , fURIStringPool(0)
     , fValidator(valToAdopt)
+    , fMemoryManager(manager)
 {
     try
     {
@@ -281,22 +286,25 @@ SAXParser::~SAXParser()
 void SAXParser::initialize()
 {
     // Create grammar resolver and string pool to pass to scanner
-    fGrammarResolver = new GrammarResolver();
-    fURIStringPool = new XMLStringPool();
+    fGrammarResolver = new (fMemoryManager) GrammarResolver(fMemoryManager);
+    fURIStringPool = new (fMemoryManager) XMLStringPool();
 
     // Create our scanner and tell it what validator to use
-    fScanner = XMLScannerResolver::getDefaultScanner(fValidator);
+    fScanner = XMLScannerResolver::getDefaultScanner(fValidator,fMemoryManager);
     fScanner->setGrammarResolver(fGrammarResolver);
     fScanner->setURIStringPool(fURIStringPool);
 
     // Create the initial advanced handler list array and zero it out
-    fAdvDHList = new XMLDocumentHandler*[fAdvDHListSize];
+    fAdvDHList = (XMLDocumentHandler**) fMemoryManager->allocate
+    (
+        fAdvDHListSize * sizeof(XMLDocumentHandler*)
+    );//new XMLDocumentHandler*[fAdvDHListSize];
     memset(fAdvDHList, 0, sizeof(void*) * fAdvDHListSize);
 }
 
 void SAXParser::cleanUp()
 {
-    delete [] fAdvDHList;
+    fMemoryManager->deallocate(fAdvDHList);//delete [] fAdvDHList;
     delete fScanner;
     delete fGrammarResolver;
     delete fURIStringPool;
@@ -316,7 +324,10 @@ void SAXParser::installAdvDocHandler(XMLDocumentHandler* const toInstall)
     {
         // Calc a new size and allocate the new temp buffer
         const unsigned int newSize = (unsigned int)(fAdvDHListSize * 1.5);
-        XMLDocumentHandler** newList = new XMLDocumentHandler*[newSize];
+        XMLDocumentHandler** newList = (XMLDocumentHandler**) fMemoryManager->allocate
+        (
+            newSize * sizeof(XMLDocumentHandler*)
+        );//new XMLDocumentHandler*[newSize];
 
         // Copy over the old data to the new list and zero out the rest
         memcpy(newList, fAdvDHList, sizeof(void*) * fAdvDHListSize);
@@ -328,7 +339,7 @@ void SAXParser::installAdvDocHandler(XMLDocumentHandler* const toInstall)
         );
 
         // And now clean up the old array and store the new stuff
-        delete [] fAdvDHList;
+        fMemoryManager->deallocate(fAdvDHList);//delete [] fAdvDHList;
         fAdvDHList = newList;
         fAdvDHListSize = newSize;
     }
@@ -608,7 +619,12 @@ void SAXParser::setStandardUriConformant(const bool newState)
 
 void SAXParser::useScanner(const XMLCh* const scannerName)
 {
-    XMLScanner* tempScanner = XMLScannerResolver::resolveScanner(scannerName, fValidator);
+    XMLScanner* tempScanner = XMLScannerResolver::resolveScanner
+    (
+        scannerName
+        , fValidator
+        , fMemoryManager
+    );
 
     if (tempScanner) {
 
diff --git a/src/xercesc/parsers/SAXParser.hpp b/src/xercesc/parsers/SAXParser.hpp
index 9e11111f9..4f60d8fa6 100644
--- a/src/xercesc/parsers/SAXParser.hpp
+++ b/src/xercesc/parsers/SAXParser.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.23  2003/05/15 18:26:50  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.22  2003/04/17 21:58:50  neilg
  * Adding a new property,
  * http://apache.org/xml/properties/security-manager, with
@@ -260,11 +263,12 @@ class GrammarResolver;
 
 class PARSERS_EXPORT SAXParser :
 
-    public Parser
+    public XMemory
+    , public Parser
     , public XMLDocumentHandler
     , public XMLErrorReporter
     , public XMLEntityHandler
-    , public DocTypeHandler
+    , public DocTypeHandler    
 {
 public :
     // -----------------------------------------------------------------------
@@ -296,7 +300,11 @@ public :
       * @param valToAdopt Pointer to the validator instance to use. The
       *                   parser is responsible for freeing the memory.
       */
-    SAXParser(XMLValidator* const valToAdopt = 0);
+    SAXParser
+    (
+          XMLValidator* const  valToAdopt = 0
+        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
+    );
 
     /**
       * Destructor
@@ -2017,6 +2025,7 @@ private:
     GrammarResolver*     fGrammarResolver;
     XMLStringPool*       fURIStringPool;
     XMLValidator*        fValidator;
+    MemoryManager*       fMemoryManager;
     XMLBuffer            fElemQNameBuf;
 };
 
diff --git a/src/xercesc/parsers/XercesDOMParser.cpp b/src/xercesc/parsers/XercesDOMParser.cpp
index f69902d9c..7a20e1ee6 100644
--- a/src/xercesc/parsers/XercesDOMParser.cpp
+++ b/src/xercesc/parsers/XercesDOMParser.cpp
@@ -83,9 +83,10 @@ XERCES_CPP_NAMESPACE_BEGIN
 // ---------------------------------------------------------------------------
 //  XercesDOMParser: Constructors and Destructor
 // ---------------------------------------------------------------------------
-XercesDOMParser::XercesDOMParser(XMLValidator* const valToAdopt) :
+XercesDOMParser::XercesDOMParser( XMLValidator* const  valToAdopt
+                                , MemoryManager* const manager) :
 
-AbstractDOMParser(valToAdopt)
+AbstractDOMParser(valToAdopt, manager)
 , fErrorHandler(0)
 , fEntityResolver(0)
 {
diff --git a/src/xercesc/parsers/XercesDOMParser.hpp b/src/xercesc/parsers/XercesDOMParser.hpp
index a8feab526..be3c7986b 100644
--- a/src/xercesc/parsers/XercesDOMParser.hpp
+++ b/src/xercesc/parsers/XercesDOMParser.hpp
@@ -101,7 +101,11 @@ public :
       * @param valToAdopt Pointer to the validator instance to use. The
       *                   parser is responsible for freeing the memory.
       */
-    XercesDOMParser(XMLValidator* const valToAdopt = 0);
+    XercesDOMParser
+    (
+          XMLValidator* const  valToAdopt = 0
+        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
+    );
 
     /**
       * Destructor
diff --git a/src/xercesc/sax/InputSource.cpp b/src/xercesc/sax/InputSource.cpp
index 4691efe0d..6af406f4e 100644
--- a/src/xercesc/sax/InputSource.cpp
+++ b/src/xercesc/sax/InputSource.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.4  2003/05/15 18:27:05  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.3  2003/04/21 21:07:38  knoaman
  * Use XMLString::release to prepare for configurable memory manager.
  *
@@ -92,8 +95,8 @@
 // ---------------------------------------------------------------------------
 //  Includes
 // ---------------------------------------------------------------------------
-#include    <xercesc/util/XMLString.hpp>
 #include    <xercesc/sax/InputSource.hpp>
+#include    <xercesc/util/XMLString.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -102,9 +105,9 @@ XERCES_CPP_NAMESPACE_BEGIN
 // ---------------------------------------------------------------------------
 InputSource::~InputSource()
 {
-    XMLString::release(&fEncoding);
-    XMLString::release(&fPublicId);
-    XMLString::release(&fSystemId);
+    fMemoryManager->deallocate(fEncoding);
+    fMemoryManager->deallocate(fPublicId);
+    fMemoryManager->deallocate(fSystemId);
 }
 
 
@@ -113,22 +116,22 @@ InputSource::~InputSource()
 // ---------------------------------------------------------------------------
 void InputSource::setEncoding(const XMLCh* const encodingStr)
 {
-    XMLString::release(&fEncoding);
-    fEncoding = XMLString::replicate(encodingStr);
+    fMemoryManager->deallocate(fEncoding);
+    fEncoding = XMLString::replicate(encodingStr, fMemoryManager);
 }
 
 
 void InputSource::setPublicId(const XMLCh* const publicId)
 {
-    XMLString::release(&fPublicId);
-    fPublicId = XMLString::replicate(publicId);
+    fMemoryManager->deallocate(fPublicId);
+    fPublicId = XMLString::replicate(publicId, fMemoryManager);
 }
 
 
 void InputSource::setSystemId(const XMLCh* const systemId)
 {
-    XMLString::release(&fSystemId);
-    fSystemId = XMLString::replicate(systemId);
+    fMemoryManager->deallocate(fSystemId);
+    fSystemId = XMLString::replicate(systemId, fMemoryManager);
 }
 
 
@@ -138,7 +141,8 @@ void InputSource::setSystemId(const XMLCh* const systemId)
 // ---------------------------------------------------------------------------
 InputSource::InputSource() :
 
-    fEncoding(0)
+    fMemoryManager(XMLPlatformUtils::fgMemoryManager)
+    , fEncoding(0)
     , fPublicId(0)
     , fSystemId(0)
     , fFatalErrorIfNotFound(true)
@@ -147,40 +151,50 @@ InputSource::InputSource() :
 
 InputSource::InputSource(const XMLCh* const systemId) :
 
-    fEncoding(0)
+    fMemoryManager(XMLPlatformUtils::fgMemoryManager)
+    , fEncoding(0)
     , fPublicId(0)
-    , fSystemId(XMLString::replicate(systemId))
+    , fSystemId(0)
     , fFatalErrorIfNotFound(true)
 {
+    fSystemId = XMLString::replicate(systemId, fMemoryManager);
 }
 
 InputSource::InputSource(const  XMLCh* const systemId
                         , const XMLCh* const publicId) :
 
-    fEncoding(0)
-    , fPublicId(XMLString::replicate(publicId))
-    , fSystemId(XMLString::replicate(systemId))
+    fMemoryManager(XMLPlatformUtils::fgMemoryManager)
+    , fEncoding(0)
+    , fPublicId(0)
+    , fSystemId(0)
     , fFatalErrorIfNotFound(true)
 {
+    fPublicId = XMLString::replicate(publicId, fMemoryManager);
+    fSystemId = XMLString::replicate(systemId, fMemoryManager);
 }
 
 InputSource::InputSource(const char* const systemId) :
 
-    fEncoding(0)
+    fMemoryManager(XMLPlatformUtils::fgMemoryManager)
+    , fEncoding(0)
     , fPublicId(0)
-    , fSystemId(XMLString::transcode(systemId))
+    , fSystemId(0)
     , fFatalErrorIfNotFound(true)
 {
+    fSystemId = XMLString::transcode(systemId, fMemoryManager);
 }
 
 InputSource::InputSource(const  char* const systemId
                         , const char* const publicId) :
 
-    fEncoding(0)
-    , fPublicId(XMLString::transcode(publicId))
-    , fSystemId(XMLString::transcode(systemId))
+    fMemoryManager(XMLPlatformUtils::fgMemoryManager)
+    , fEncoding(0)
+    , fPublicId(0)
+    , fSystemId(0)
     , fFatalErrorIfNotFound(true)
 {
+    fPublicId = XMLString::transcode(publicId, fMemoryManager);
+    fSystemId = XMLString::transcode(systemId, fMemoryManager);
 }
 
 XERCES_CPP_NAMESPACE_END
diff --git a/src/xercesc/sax/InputSource.hpp b/src/xercesc/sax/InputSource.hpp
index a36df7f38..abef0441b 100644
--- a/src/xercesc/sax/InputSource.hpp
+++ b/src/xercesc/sax/InputSource.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.6  2003/05/15 18:27:05  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.5  2003/03/07 18:10:06  tng
  * Return a reference instead of void for operator=
  *
@@ -113,7 +116,7 @@
 #ifndef INPUTSOURCE_HPP
 #define INPUTSOURCE_HPP
 
-#include <xercesc/util/XercesDefs.hpp>
+#include <xercesc/util/PlatformUtils.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -150,7 +153,7 @@ class BinInputStream;
   * @see Parser#parse
   * @see EntityResolver#resolveEntity
   */
-class SAX_EXPORT InputSource
+class SAX_EXPORT InputSource : public XMemory
 {
 public:
     // -----------------------------------------------------------------------
@@ -228,6 +231,8 @@ public:
     */
     virtual const bool getIssueFatalErrorIfNotFound() const;
 
+    MemoryManager* getMemoryManager() const;
+
     //@}
 
 
@@ -365,10 +370,11 @@ private:
     //
     //  fFatalErrorIfNotFound
     // -----------------------------------------------------------------------
-    XMLCh*  fEncoding;
-    XMLCh*  fPublicId;
-    XMLCh*  fSystemId;
-    bool    fFatalErrorIfNotFound;
+    MemoryManager* fMemoryManager;
+    XMLCh*         fEncoding;
+    XMLCh*         fPublicId;
+    XMLCh*         fSystemId;
+    bool           fFatalErrorIfNotFound;
 };
 
 
@@ -395,6 +401,11 @@ inline const bool InputSource::getIssueFatalErrorIfNotFound() const
     return fFatalErrorIfNotFound;
 }
 
+inline MemoryManager* InputSource::getMemoryManager() const
+{
+    return fMemoryManager;
+}
+
 // ---------------------------------------------------------------------------
 //  InputSource: Setter methods
 // ---------------------------------------------------------------------------
diff --git a/src/xercesc/sax/SAXException.hpp b/src/xercesc/sax/SAXException.hpp
index 02a507607..b15472cac 100644
--- a/src/xercesc/sax/SAXException.hpp
+++ b/src/xercesc/sax/SAXException.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.4  2003/05/15 18:27:05  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.3  2002/12/06 13:17:29  tng
  * [Bug 9083] Make SAXNotSupportedException and SAXNotRecognizedException to be exportable
  *
@@ -104,6 +107,7 @@
 
 #include <xercesc/util/XMLString.hpp>
 #include <xercesc/util/XMLUni.hpp>
+#include <xercesc/util/XMemory.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -127,7 +131,7 @@ XERCES_CPP_NAMESPACE_BEGIN
   *
   * @see SAXParseException#SAXParseException
   */
-class SAX_EXPORT SAXException
+class SAX_EXPORT SAXException : public XMemory
 {
 public:
     /** @name Constructors and Destructor */
diff --git a/src/xercesc/sax/SAXParseException.hpp b/src/xercesc/sax/SAXParseException.hpp
index c09b7400c..4f5b1f4c8 100644
--- a/src/xercesc/sax/SAXParseException.hpp
+++ b/src/xercesc/sax/SAXParseException.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.4  2003/05/15 18:27:05  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.3  2002/11/04 14:56:26  tng
  * C++ Namespace Support.
  *
@@ -89,7 +92,7 @@
 #ifndef SAXPARSEEXCEPTION_HPP
 #define SAXPARSEEXCEPTION_HPP
 
-#include    <xercesc/sax/SAXException.hpp>
+#include <xercesc/sax/SAXException.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
diff --git a/src/xercesc/sax2/XMLReaderFactory.hpp b/src/xercesc/sax2/XMLReaderFactory.hpp
index 6deb535fe..6c7a5fc79 100644
--- a/src/xercesc/sax2/XMLReaderFactory.hpp
+++ b/src/xercesc/sax2/XMLReaderFactory.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.4  2003/05/15 18:27:11  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.3  2002/11/04 14:55:45  tng
  * C++ Namespace Support.
  *
@@ -87,6 +90,8 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
+class MemoryManager;
+
 /**
   * Creates a SAX2 parser (SAX2XMLReader).
   *
@@ -103,14 +108,14 @@ protected:                // really should be private, but that causes compiler
 	~XMLReaderFactory() ;
 
 public:
-	static SAX2XMLReader * createXMLReader() ;
+	static SAX2XMLReader * createXMLReader(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) ;
 	static SAX2XMLReader * createXMLReader(const XMLCh* className)  ;
 };
 
 
-inline SAX2XMLReader * XMLReaderFactory::createXMLReader()
+inline SAX2XMLReader * XMLReaderFactory::createXMLReader(MemoryManager* const manager)
 {
-	return (SAX2XMLReader*)(new SAX2XMLReaderImpl());
+	return (SAX2XMLReader*)(new (manager) SAX2XMLReaderImpl(manager));
 }
 
 inline SAX2XMLReader * XMLReaderFactory::createXMLReader(const XMLCh * className)
diff --git a/src/xercesc/util/MsgLoaders/ICU/ICUMsgLoader.cpp b/src/xercesc/util/MsgLoaders/ICU/ICUMsgLoader.cpp
index 140bc1570..4acad0d93 100644
--- a/src/xercesc/util/MsgLoaders/ICU/ICUMsgLoader.cpp
+++ b/src/xercesc/util/MsgLoaders/ICU/ICUMsgLoader.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.17  2003/05/15 18:29:48  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.16  2003/03/17 19:28:05  peiyongz
  * Build versioned XercesMessages on Windows
  *
@@ -226,8 +229,8 @@ ICUMsgLoader::ICUMsgLoader(const XMLCh* const  msgDomain)
 	Resolve domainName
     ***/
     int     index = XMLString::lastIndexOf(msgDomain, chForwardSlash);
-    char*   domainName = XMLString::transcode(&(msgDomain[index + 1]));
-    ArrayJanitor<char> jan1(domainName);
+    char*   domainName = XMLString::transcode(&(msgDomain[index + 1]), XMLPlatformUtils::fgMemoryManager);
+    ArrayJanitor<char> jan1(domainName, XMLPlatformUtils::fgMemoryManager);
 
     /***
         Location resolution priority
@@ -406,24 +409,24 @@ bool ICUMsgLoader::loadMsg( const   XMLMsgLoader::XMLMsgId  msgToLoad
 
     bool bRet = false;
     if (repText1)
-        tmp1 = XMLString::transcode(repText1);
+        tmp1 = XMLString::transcode(repText1, XMLPlatformUtils::fgMemoryManager);
     if (repText2)
-        tmp2 = XMLString::transcode(repText2);
+        tmp2 = XMLString::transcode(repText2, XMLPlatformUtils::fgMemoryManager);
     if (repText3)
-        tmp3 = XMLString::transcode(repText3);
+        tmp3 = XMLString::transcode(repText3, XMLPlatformUtils::fgMemoryManager);
     if (repText4)
-        tmp4 = XMLString::transcode(repText4);
+        tmp4 = XMLString::transcode(repText4, XMLPlatformUtils::fgMemoryManager);
 
     bRet = loadMsg(msgToLoad, toFill, maxChars, tmp1, tmp2, tmp3, tmp4);
 
     if (tmp1)
-        delete [] tmp1;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp1);//delete [] tmp1;
     if (tmp2)
-        delete [] tmp2;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp2);//delete [] tmp2;
     if (tmp3)
-        delete [] tmp3;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp3);//delete [] tmp3;
     if (tmp4)
-        delete [] tmp4;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp4);//delete [] tmp4;
 
     return bRet;
 }
diff --git a/src/xercesc/util/MsgLoaders/ICU/ICUMsgLoader.hpp b/src/xercesc/util/MsgLoaders/ICU/ICUMsgLoader.hpp
index db2303663..bfc77545c 100644
--- a/src/xercesc/util/MsgLoaders/ICU/ICUMsgLoader.hpp
+++ b/src/xercesc/util/MsgLoaders/ICU/ICUMsgLoader.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.6  2003/05/15 18:29:48  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.5  2003/03/07 18:15:44  tng
  * Return a reference instead of void for operator=
  *
@@ -101,7 +104,6 @@
 #if !defined(ICUMSGLOADER_HPP)
 #define ICUMSGLOADER_HPP
 
-#include <xercesc/util/XercesDefs.hpp>
 #include <xercesc/util/XMLMsgLoader.hpp>
 #include "unicode/ures.h"
 
diff --git a/src/xercesc/util/MsgLoaders/InMemory/InMemMsgLoader.cpp b/src/xercesc/util/MsgLoaders/InMemory/InMemMsgLoader.cpp
index 82e31a2b8..3c2d69676 100644
--- a/src/xercesc/util/MsgLoaders/InMemory/InMemMsgLoader.cpp
+++ b/src/xercesc/util/MsgLoaders/InMemory/InMemMsgLoader.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.8  2003/05/15 18:29:49  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.7  2003/03/09 16:41:40  peiyongz
  * PanicHandler
  *
@@ -104,7 +107,6 @@
 // ---------------------------------------------------------------------------
 //  Includes
 // ---------------------------------------------------------------------------
-#include <xercesc/util/XercesDefs.hpp>
 #include <xercesc/util/BitOps.hpp>
 #include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/XMLMsgLoader.hpp>
@@ -129,12 +131,12 @@ InMemMsgLoader::InMemMsgLoader(const XMLCh* const msgDomain)
         XMLPlatformUtils::panic(PanicHandler::Panic_UnknownMsgDomain);
     }
 
-    fMsgDomain = XMLString::replicate(msgDomain);
+    fMsgDomain = XMLString::replicate(msgDomain, XMLPlatformUtils::fgMemoryManager);
 }
 
 InMemMsgLoader::~InMemMsgLoader()
 {
-    delete [] fMsgDomain;
+    XMLPlatformUtils::fgMemoryManager->deallocate(fMsgDomain);//delete [] fMsgDomain;
 }
 
 
@@ -232,24 +234,24 @@ bool InMemMsgLoader::loadMsg(const  XMLMsgLoader::XMLMsgId  msgToLoad
 
     bool bRet = false;
     if (repText1)
-        tmp1 = XMLString::transcode(repText1);
+        tmp1 = XMLString::transcode(repText1, XMLPlatformUtils::fgMemoryManager);
     if (repText2)
-        tmp2 = XMLString::transcode(repText2);
+        tmp2 = XMLString::transcode(repText2, XMLPlatformUtils::fgMemoryManager);
     if (repText3)
-        tmp3 = XMLString::transcode(repText3);
+        tmp3 = XMLString::transcode(repText3, XMLPlatformUtils::fgMemoryManager);
     if (repText4)
-        tmp4 = XMLString::transcode(repText4);
+        tmp4 = XMLString::transcode(repText4, XMLPlatformUtils::fgMemoryManager);
 
     bRet = loadMsg(msgToLoad, toFill, maxChars, tmp1, tmp2, tmp3, tmp4);
 
     if (tmp1)
-        delete [] tmp1;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp1);//delete [] tmp1;
     if (tmp2)
-        delete [] tmp2;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp2);//delete [] tmp2;
     if (tmp3)
-        delete [] tmp3;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp3);//delete [] tmp3;
     if (tmp4)
-        delete [] tmp4;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp4);//delete [] tmp4;
 
     return bRet;
 }
diff --git a/src/xercesc/util/MsgLoaders/MsgCatalog/MsgCatalogLoader.cpp b/src/xercesc/util/MsgLoaders/MsgCatalog/MsgCatalogLoader.cpp
index c438f95c0..e5961f5a7 100644
--- a/src/xercesc/util/MsgLoaders/MsgCatalog/MsgCatalogLoader.cpp
+++ b/src/xercesc/util/MsgLoaders/MsgCatalog/MsgCatalogLoader.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.14  2003/05/15 18:29:49  knoaman
+ * Partial implementation of the configurable memory manager.
+ *
  * Revision 1.13  2003/03/09 16:42:05  peiyongz
  * PanicHandler
  *
@@ -289,24 +292,24 @@ bool MsgCatalogLoader::loadMsg(const  XMLMsgLoader::XMLMsgId  msgToLoad
 
     bool bRet = false;
     if (repText1)
-        tmp1 = XMLString::transcode(repText1);
+        tmp1 = XMLString::transcode(repText1, XMLPlatformUtils::fgMemoryManager);
     if (repText2)
-        tmp2 = XMLString::transcode(repText2);
+        tmp2 = XMLString::transcode(repText2, XMLPlatformUtils::fgMemoryManager);
     if (repText3)
-        tmp3 = XMLString::transcode(repText3);
+        tmp3 = XMLString::transcode(repText3, XMLPlatformUtils::fgMemoryManager);
     if (repText4)
-        tmp4 = XMLString::transcode(repText4);
+        tmp4 = XMLString::transcode(repText4, XMLPlatformUtils::fgMemoryManager);
 
     bRet = loadMsg(msgToLoad, toFill, maxChars, tmp1, tmp2, tmp3, tmp4);
 
     if (tmp1)
-        delete [] tmp1;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp1);//delete [] tmp1;
     if (tmp2)
-        delete [] tmp2;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp2);//delete [] tmp2;
     if (tmp3)
-        delete [] tmp3;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp3);//delete [] tmp3;
     if (tmp4)
-        delete [] tmp4;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp4);//delete [] tmp4;
 
     return bRet;
 }
diff --git a/src/xercesc/util/MsgLoaders/MsgFile/MsgLoader.cpp b/src/xercesc/util/MsgLoaders/MsgFile/MsgLoader.cpp
index cb9e1627d..e3fea7a6c 100644
--- a/src/xercesc/util/MsgLoaders/MsgFile/MsgLoader.cpp
+++ b/src/xercesc/util/MsgLoaders/MsgFile/MsgLoader.cpp
@@ -86,13 +86,13 @@ MsgCatalogLoader::MsgCatalogLoader(const XMLCh* const msgDomain) :
     , fMsgDomain(0)
 {
 
-    fMsgDomain = XMLString::replicate(msgDomain);
+    fMsgDomain = XMLString::replicate(msgDomain, XMLPlatformUtils::fgMemoryManager);
 }
 
 MsgCatalogLoader::~MsgCatalogLoader()
 {
 
-    delete fMsgDomain;
+    XMLPlatformUtils::fgMemoryManager->deallocate(fMsgDomain);//delete[] fMsgDomain;
 }
 
 
@@ -278,24 +278,24 @@ bool MsgCatalogLoader::loadMsg(const  XMLMsgLoader::XMLMsgId  msgToLoad
 
     bool bRet = false;
     if (repText1)
-        tmp1 = XMLString::transcode(repText1);
+        tmp1 = XMLString::transcode(repText1, XMLPlatformUtils::fgMemoryManager);
     if (repText2)
-        tmp2 = XMLString::transcode(repText2);
+        tmp2 = XMLString::transcode(repText2, XMLPlatformUtils::fgMemoryManager);
     if (repText3)
-        tmp3 = XMLString::transcode(repText3);
+        tmp3 = XMLString::transcode(repText3, XMLPlatformUtils::fgMemoryManager);
     if (repText4)
-        tmp4 = XMLString::transcode(repText4);
+        tmp4 = XMLString::transcode(repText4, XMLPlatformUtils::fgMemoryManager);
 
     bRet = loadMsg(msgToLoad, toFill, maxChars, tmp1, tmp2, tmp3, tmp4);
 
     if (tmp1)
-        delete [] tmp1;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp1);//delete [] tmp1;
     if (tmp2)
-        delete [] tmp2;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp2);//delete [] tmp2;
     if (tmp3)
-        delete [] tmp3;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp3);//delete [] tmp3;
     if (tmp4)
-        delete [] tmp4;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp4);//delete [] tmp4;
 
     return bRet;
 }
diff --git a/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.cpp b/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.cpp
index b57a0878e..3a6e10be6 100644
--- a/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.cpp
+++ b/src/xercesc/util/MsgLoaders/Win32/Win32MsgLoader.cpp
@@ -131,7 +131,7 @@ Win32MsgLoader::Win32MsgLoader(const XMLCh* const msgDomain) :
     }
 
     // Store the domain name
-    fMsgDomain = XMLString::replicate(msgDomain);
+    fMsgDomain = XMLString::replicate(msgDomain, XMLPlatformUtils::fgMemoryManager);
 
     // And precalc the id offset we use for this domain
     if (XMLString::equals(fMsgDomain, XMLUni::fgXMLErrDomain))
@@ -148,7 +148,7 @@ Win32MsgLoader::Win32MsgLoader(const XMLCh* const msgDomain) :
 
 Win32MsgLoader::~Win32MsgLoader()
 {
-    delete [] fMsgDomain;
+    XMLPlatformUtils::fgMemoryManager->deallocate(fMsgDomain);//delete [] fMsgDomain;
 }
 
 
@@ -256,24 +256,24 @@ bool Win32MsgLoader::loadMsg(const  XMLMsgLoader::XMLMsgId  msgToLoad
 
     bool bRet = false;
     if (repText1)
-        tmp1 = XMLString::transcode(repText1);
+        tmp1 = XMLString::transcode(repText1, XMLPlatformUtils::fgMemoryManager);
     if (repText2)
-        tmp2 = XMLString::transcode(repText2);
+        tmp2 = XMLString::transcode(repText2, XMLPlatformUtils::fgMemoryManager);
     if (repText3)
-        tmp3 = XMLString::transcode(repText3);
+        tmp3 = XMLString::transcode(repText3, XMLPlatformUtils::fgMemoryManager);
     if (repText4)
-        tmp4 = XMLString::transcode(repText4);
+        tmp4 = XMLString::transcode(repText4, XMLPlatformUtils::fgMemoryManager);
 
     bRet = loadMsg(msgToLoad, toFill, maxChars, tmp1, tmp2, tmp3, tmp4);
 
     if (tmp1)
-        delete [] tmp1;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp1);//delete [] tmp1;
     if (tmp2)
-        delete [] tmp2;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp2);//delete [] tmp2;
     if (tmp3)
-        delete [] tmp3;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp3);//delete [] tmp3;
     if (tmp4)
-        delete [] tmp4;
+        XMLPlatformUtils::fgMemoryManager->deallocate(tmp4);//delete [] tmp4;
 
     return bRet;
 }
-- 
GitLab