From 414792dd0b6138a636dc8267651afe0c7ba70cb6 Mon Sep 17 00:00:00 2001 From: Khaled Noaman <knoaman@apache.org> Date: Fri, 16 May 2003 21:37:00 +0000 Subject: [PATCH] Memory manager implementation: Modify constructors to pass in the memory manager. git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174997 13f79535-47bb-0310-9956-ffa450edef68 --- src/xercesc/dom/deprecated/DOMParser.cpp | 4 +- src/xercesc/dom/impl/DOMAttrImpl.cpp | 2 +- src/xercesc/dom/impl/DOMNormalizer.cpp | 12 +- src/xercesc/dom/impl/DOMNormalizer.hpp | 2 +- src/xercesc/dom/impl/DOMRangeImpl.cpp | 2 +- src/xercesc/dom/impl/DOMWriterImpl.cpp | 5 +- .../framework/LocalFileFormatTarget.cpp | 13 +- .../framework/LocalFileFormatTarget.hpp | 17 +- .../framework/LocalFileInputSource.cpp | 8 +- .../framework/LocalFileInputSource.hpp | 11 +- src/xercesc/framework/MemBufFormatTarget.cpp | 8 +- src/xercesc/framework/MemBufFormatTarget.hpp | 9 +- src/xercesc/framework/MemBufInputSource.cpp | 25 ++- src/xercesc/framework/MemBufInputSource.hpp | 7 +- src/xercesc/framework/StdInInputSource.hpp | 9 +- src/xercesc/framework/URLInputSource.cpp | 39 ++-- src/xercesc/framework/URLInputSource.hpp | 13 +- .../framework/Wrapper4DOMInputSource.cpp | 9 +- .../framework/Wrapper4DOMInputSource.hpp | 8 +- src/xercesc/framework/XMLAttDef.cpp | 18 +- src/xercesc/framework/XMLAttDef.hpp | 9 +- src/xercesc/framework/XMLAttDefList.hpp | 5 +- src/xercesc/framework/XMLAttr.hpp | 15 +- src/xercesc/framework/XMLBuffer.hpp | 7 +- src/xercesc/framework/XMLBufferMgr.hpp | 5 +- src/xercesc/framework/XMLElementDecl.hpp | 5 +- src/xercesc/framework/XMLEntityDecl.cpp | 21 +- src/xercesc/framework/XMLEntityDecl.hpp | 8 +- src/xercesc/framework/XMLFormatter.cpp | 10 +- src/xercesc/framework/XMLFormatter.hpp | 5 + src/xercesc/framework/XMLNotationDecl.cpp | 18 +- src/xercesc/framework/XMLNotationDecl.hpp | 6 +- src/xercesc/framework/XMLRefInfo.hpp | 19 +- src/xercesc/internal/DGXMLScanner.cpp | 9 +- src/xercesc/internal/ElemStack.cpp | 11 +- src/xercesc/internal/ElemStack.hpp | 7 +- src/xercesc/internal/IGXMLScanner.cpp | 10 +- src/xercesc/internal/IGXMLScanner2.cpp | 10 +- src/xercesc/internal/ReaderMgr.cpp | 13 +- src/xercesc/internal/ReaderMgr.hpp | 7 +- src/xercesc/internal/SGXMLScanner.cpp | 16 +- src/xercesc/internal/SGXMLScanner.hpp | 19 +- src/xercesc/internal/VecAttributesImpl.cpp | 5 +- src/xercesc/internal/WFXMLScanner.cpp | 2 + src/xercesc/internal/WFXMLScanner.hpp | 19 +- src/xercesc/internal/XMLReader.cpp | 67 +++--- src/xercesc/internal/XMLReader.hpp | 64 +++--- src/xercesc/internal/XMLScanner.cpp | 18 +- src/xercesc/internal/XMLScanner.hpp | 7 +- src/xercesc/internal/XMLScannerResolver.hpp | 9 +- src/xercesc/parsers/AbstractDOMParser.hpp | 6 + src/xercesc/parsers/DOMBuilderImpl.cpp | 6 +- src/xercesc/parsers/SAX2XMLReaderImpl.cpp | 5 +- src/xercesc/parsers/SAXParser.cpp | 4 + src/xercesc/sax/InputSource.cpp | 29 ++- src/xercesc/sax/InputSource.hpp | 17 +- src/xercesc/util/BaseRefVectorOf.c | 6 + src/xercesc/util/BaseRefVectorOf.hpp | 1 + src/xercesc/util/QName.hpp | 10 + src/xercesc/util/RefHashTableOf.c | 9 + src/xercesc/util/RefHashTableOf.hpp | 4 + .../util/Transcoders/ICU/ICUTransService.cpp | 201 +++++++++++++++++- .../IconvFBSD/IconvFBSDTransService.cpp | 181 ++++++++++++++++ .../IconvGNU/IconvGNUTransService.cpp | 118 ++++++++++ src/xercesc/util/ValueVectorOf.c | 9 +- src/xercesc/util/ValueVectorOf.hpp | 4 + src/xercesc/util/regx/RangeToken.cpp | 60 ++++-- src/xercesc/util/regx/RangeToken.hpp | 4 +- src/xercesc/util/regx/RegularExpression.cpp | 7 +- src/xercesc/util/regx/StringToken.hpp | 4 +- src/xercesc/util/regx/TokenFactory.cpp | 7 +- src/xercesc/util/regx/TokenFactory.hpp | 6 + src/xercesc/util/regx/UnionToken.cpp | 7 +- 73 files changed, 1074 insertions(+), 278 deletions(-) diff --git a/src/xercesc/dom/deprecated/DOMParser.cpp b/src/xercesc/dom/deprecated/DOMParser.cpp index dca308692..4d19a78af 100644 --- a/src/xercesc/dom/deprecated/DOMParser.cpp +++ b/src/xercesc/dom/deprecated/DOMParser.cpp @@ -744,7 +744,7 @@ void DOMParser::startElement(const XMLElementDecl& elemDecl DocumentImpl *docImpl = (DocumentImpl *)fDocument.fImpl; if (fScanner -> getDoNamespaces()) { //DOM Level 2, doNamespaces on - XMLBuffer buf; + XMLBuffer buf(1023, fMemoryManager); DOMString namespaceURI = 0; DOMString elemQName = 0; if (urlId != fScanner->getEmptyNamespaceId()) { //TagName has a prefix @@ -1146,7 +1146,7 @@ void DOMParser::endAttList DOMString qualifiedName = attr->getFullName(); int index = DocumentImpl::indexofQualifiedName(qualifiedName); - XMLBuffer buf; + XMLBuffer buf(1023, fMemoryManager); static const XMLCh XMLNS[] = { chLatin_x, chLatin_m, chLatin_l, chLatin_n, chLatin_s, chNull}; diff --git a/src/xercesc/dom/impl/DOMAttrImpl.cpp b/src/xercesc/dom/impl/DOMAttrImpl.cpp index c03092d08..30c004954 100644 --- a/src/xercesc/dom/impl/DOMAttrImpl.cpp +++ b/src/xercesc/dom/impl/DOMAttrImpl.cpp @@ -162,7 +162,7 @@ const XMLCh * DOMAttrImpl::getValue() const // In such case, we have to visit each child to retrieve the text // - XMLBuffer buf; + XMLBuffer buf(1023, ((DOMDocumentImpl *)this->getOwnerDocument())->getMemoryManager()); getTextValue(fParent.fFirstChild, buf); return (XMLCh*) ((DOMDocumentImpl *)this->getOwnerDocument())->getPooledString(buf.getRawBuffer()); diff --git a/src/xercesc/dom/impl/DOMNormalizer.cpp b/src/xercesc/dom/impl/DOMNormalizer.cpp index e6700881b..a2de9c89a 100644 --- a/src/xercesc/dom/impl/DOMNormalizer.cpp +++ b/src/xercesc/dom/impl/DOMNormalizer.cpp @@ -160,7 +160,11 @@ static XMLMsgLoader& gNormalizerMsgLoader() } -DOMNormalizer::DOMNormalizer() : fDocument(0), fNewNamespaceCount(1) { +DOMNormalizer::DOMNormalizer() + : fDocument(0) + , fNewNamespaceCount(1) + , fMemoryManager(XMLPlatformUtils::fgMemoryManager) +{ fNSScope = new InScopeNamespaces(); }; @@ -399,7 +403,7 @@ void DOMNormalizer::addOrChangeNamespaceDecl(const XMLCh* prefix, const XMLCh* u if (XMLString::equals(prefix, XMLUni::fgZeroLenString)) { element->setAttributeNS(XMLUni::fgXMLNSURIName, XMLUni::fgXMLNSString, uri); } else { - XMLBuffer buf; + XMLBuffer buf(1023, fMemoryManager); buf.set(XMLUni::fgXMLNSString); buf.append(chColon); buf.append(prefix); @@ -408,7 +412,7 @@ void DOMNormalizer::addOrChangeNamespaceDecl(const XMLCh* prefix, const XMLCh* u } const XMLCh* DOMNormalizer::addCustomNamespaceDecl(const XMLCh* uri, DOMElementImpl *element) const { - XMLBuffer preBuf; + XMLBuffer preBuf(1023, fMemoryManager); preBuf.append(chLatin_N); preBuf.append(chLatin_S); preBuf.append(integerToXMLCh(fNewNamespaceCount)); @@ -422,7 +426,7 @@ const XMLCh* DOMNormalizer::addCustomNamespaceDecl(const XMLCh* uri, DOMElementI ((DOMNormalizer *)this)->fNewNamespaceCount++; } - XMLBuffer buf; + XMLBuffer buf(1023, fMemoryManager); buf.set(XMLUni::fgXMLNSString); buf.append(chColon); buf.append(preBuf.getRawBuffer()); diff --git a/src/xercesc/dom/impl/DOMNormalizer.hpp b/src/xercesc/dom/impl/DOMNormalizer.hpp index dc19aaa76..da0241e40 100644 --- a/src/xercesc/dom/impl/DOMNormalizer.hpp +++ b/src/xercesc/dom/impl/DOMNormalizer.hpp @@ -185,7 +185,7 @@ private: DOMErrorHandler *fErrorHandler; InScopeNamespaces *fNSScope; unsigned int fNewNamespaceCount; - + MemoryManager* fMemoryManager; }; diff --git a/src/xercesc/dom/impl/DOMRangeImpl.cpp b/src/xercesc/dom/impl/DOMRangeImpl.cpp index 29ffc753d..c5619a8a7 100644 --- a/src/xercesc/dom/impl/DOMRangeImpl.cpp +++ b/src/xercesc/dom/impl/DOMRangeImpl.cpp @@ -863,7 +863,7 @@ const XMLCh* DOMRangeImpl::toString() const DOMNode* node = fStartContainer; DOMNode* stopNode = fEndContainer; - XMLBuffer retStringBuf; + XMLBuffer retStringBuf(1023, ((DOMDocumentImpl *)fDocument)->getMemoryManager()); short type = fStartContainer->getNodeType(); if((type == DOMNode::TEXT_NODE || type == DOMNode::CDATA_SECTION_NODE diff --git a/src/xercesc/dom/impl/DOMWriterImpl.cpp b/src/xercesc/dom/impl/DOMWriterImpl.cpp index cfce2e586..0d9821a63 100644 --- a/src/xercesc/dom/impl/DOMWriterImpl.cpp +++ b/src/xercesc/dom/impl/DOMWriterImpl.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.38 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.37 2003/05/15 18:25:54 knoaman * Partial implementation of the configurable memory manager. * @@ -657,7 +660,7 @@ bool DOMWriterImpl::writeNode(XMLFormatTarget* const destination // XMLCh* DOMWriterImpl::writeToString(const DOMNode &nodeToWrite) { - MemBufFormatTarget destination; + MemBufFormatTarget destination(1023, fMemoryManager); bool retVal; // XMLCh is unicode, assume fEncoding as UTF-16 diff --git a/src/xercesc/framework/LocalFileFormatTarget.cpp b/src/xercesc/framework/LocalFileFormatTarget.cpp index 620fbf482..9112ea705 100644 --- a/src/xercesc/framework/LocalFileFormatTarget.cpp +++ b/src/xercesc/framework/LocalFileFormatTarget.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.6 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -85,12 +88,13 @@ XERCES_CPP_NAMESPACE_BEGIN -LocalFileFormatTarget::LocalFileFormatTarget(const XMLCh* const fileName) +LocalFileFormatTarget::LocalFileFormatTarget( const XMLCh* const fileName + , MemoryManager* const manager) : fSource(0) , fDataBuf(0) , fIndex(0) , fCapacity(1023) -, fMemoryManager(XMLPlatformUtils::fgMemoryManager) +, fMemoryManager(manager) { fSource = XMLPlatformUtils::openFileToWrite(fileName); @@ -108,12 +112,13 @@ LocalFileFormatTarget::LocalFileFormatTarget(const XMLCh* const fileName) } -LocalFileFormatTarget::LocalFileFormatTarget(const char* const fileName) +LocalFileFormatTarget::LocalFileFormatTarget( const char* const fileName + , MemoryManager* const manager) : fSource(0) , fDataBuf(0) , fIndex(0) , fCapacity(1023) -, fMemoryManager(XMLPlatformUtils::fgMemoryManager) +, fMemoryManager(manager) { fSource = XMLPlatformUtils::openFileToWrite(fileName); diff --git a/src/xercesc/framework/LocalFileFormatTarget.hpp b/src/xercesc/framework/LocalFileFormatTarget.hpp index 90c9b5c79..81f577155 100644 --- a/src/xercesc/framework/LocalFileFormatTarget.hpp +++ b/src/xercesc/framework/LocalFileFormatTarget.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.6 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.5 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -87,9 +90,17 @@ public: /** @name constructors and destructor */ //@{ - LocalFileFormatTarget(const XMLCh* const); - - LocalFileFormatTarget(const char* const); + LocalFileFormatTarget + ( + const XMLCh* const + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); + + LocalFileFormatTarget + ( + const char* const + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); ~LocalFileFormatTarget(); //@} diff --git a/src/xercesc/framework/LocalFileInputSource.cpp b/src/xercesc/framework/LocalFileInputSource.cpp index 039b680f2..b3ea62a64 100644 --- a/src/xercesc/framework/LocalFileInputSource.cpp +++ b/src/xercesc/framework/LocalFileInputSource.cpp @@ -120,7 +120,9 @@ XERCES_CPP_NAMESPACE_BEGIN // LocalFileInputSource: Constructors and Destructor // --------------------------------------------------------------------------- LocalFileInputSource::LocalFileInputSource( const XMLCh* const basePath - , const XMLCh* const relativePath) + , const XMLCh* const relativePath + , MemoryManager* const manager) + : InputSource(manager) { // // If the relative part is really relative, then weave it together @@ -143,7 +145,9 @@ LocalFileInputSource::LocalFileInputSource( const XMLCh* const basePath } -LocalFileInputSource::LocalFileInputSource(const XMLCh* const filePath) +LocalFileInputSource::LocalFileInputSource(const XMLCh* const filePath, + MemoryManager* const manager) + : InputSource(manager) { // diff --git a/src/xercesc/framework/LocalFileInputSource.hpp b/src/xercesc/framework/LocalFileInputSource.hpp index 156e22009..7ae2b7978 100644 --- a/src/xercesc/framework/LocalFileInputSource.hpp +++ b/src/xercesc/framework/LocalFileInputSource.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.3 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.2 2002/11/04 15:00:21 tng * C++ Namespace Support. * @@ -157,8 +160,9 @@ public : */ LocalFileInputSource ( - const XMLCh* const basePath - , const XMLCh* const relativePath + const XMLCh* const basePath + , const XMLCh* const relativePath + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -178,7 +182,8 @@ public : */ LocalFileInputSource ( - const XMLCh* const filePath + const XMLCh* const filePath + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} diff --git a/src/xercesc/framework/MemBufFormatTarget.cpp b/src/xercesc/framework/MemBufFormatTarget.cpp index fe3c70121..612096243 100644 --- a/src/xercesc/framework/MemBufFormatTarget.cpp +++ b/src/xercesc/framework/MemBufFormatTarget.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.6 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -84,8 +87,9 @@ XERCES_CPP_NAMESPACE_BEGIN -MemBufFormatTarget::MemBufFormatTarget(int initCapacity) - : fMemoryManager(XMLPlatformUtils::fgMemoryManager) +MemBufFormatTarget::MemBufFormatTarget( int initCapacity + , MemoryManager* const manager) + : fMemoryManager(manager) , fDataBuf(0) , fIndex(0) , fCapacity(initCapacity) diff --git a/src/xercesc/framework/MemBufFormatTarget.hpp b/src/xercesc/framework/MemBufFormatTarget.hpp index 648306af0..605bca543 100644 --- a/src/xercesc/framework/MemBufFormatTarget.hpp +++ b/src/xercesc/framework/MemBufFormatTarget.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.7 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.6 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -106,7 +109,11 @@ public: /** @name constructors and destructor */ //@{ - MemBufFormatTarget(int initCapacity = 1023) ; + MemBufFormatTarget + ( + int initCapacity = 1023 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ) ; ~MemBufFormatTarget(); //@} diff --git a/src/xercesc/framework/MemBufInputSource.cpp b/src/xercesc/framework/MemBufInputSource.cpp index 7c2d72b8e..5dcb70ecb 100644 --- a/src/xercesc/framework/MemBufInputSource.cpp +++ b/src/xercesc/framework/MemBufInputSource.cpp @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.5 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.4 2003/05/16 03:11:30 knoaman * Partial implementation of the configurable memory manager. * @@ -95,11 +98,12 @@ XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // MemBufInputSource: Constructors and Destructor // --------------------------------------------------------------------------- -MemBufInputSource::MemBufInputSource( const XMLByte* const srcDocBytes - , const unsigned int byteCount - , const XMLCh* const bufId - , const bool adoptBuffer) : - InputSource(bufId) +MemBufInputSource::MemBufInputSource( const XMLByte* const srcDocBytes + , const unsigned int byteCount + , const XMLCh* const bufId + , const bool adoptBuffer + , MemoryManager* const manager) : + InputSource(bufId, manager) , fAdopted(adoptBuffer) , fByteCount(byteCount) , fCopyBufToStream(true) @@ -107,11 +111,12 @@ MemBufInputSource::MemBufInputSource( const XMLByte* const srcDocBytes { } -MemBufInputSource::MemBufInputSource( const XMLByte* const srcDocBytes - , const unsigned int byteCount - , const char* const bufId - , const bool adoptBuffer) : - InputSource(bufId) +MemBufInputSource::MemBufInputSource( const XMLByte* const srcDocBytes + , const unsigned int byteCount + , const char* const bufId + , const bool adoptBuffer + , MemoryManager* const manager) : + InputSource(bufId, manager) , fAdopted(adoptBuffer) , fByteCount(byteCount) , fCopyBufToStream(true) diff --git a/src/xercesc/framework/MemBufInputSource.hpp b/src/xercesc/framework/MemBufInputSource.hpp index 7893c8f3c..3aade8c5e 100644 --- a/src/xercesc/framework/MemBufInputSource.hpp +++ b/src/xercesc/framework/MemBufInputSource.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.3 2002/11/04 15:00:21 tng * C++ Namespace Support. * @@ -165,7 +168,8 @@ public : const XMLByte* const srcDocBytes , const unsigned int byteCount , const XMLCh* const bufId - , const bool adoptBuffer = false + , const bool adoptBuffer// = false + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -178,6 +182,7 @@ public : , const unsigned int byteCount , const char* const bufId , const bool adoptBuffer = false + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} diff --git a/src/xercesc/framework/StdInInputSource.hpp b/src/xercesc/framework/StdInInputSource.hpp index f288e70b3..a748f0ec5 100644 --- a/src/xercesc/framework/StdInInputSource.hpp +++ b/src/xercesc/framework/StdInInputSource.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.3 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.2 2002/11/04 15:00:21 tng * C++ Namespace Support. * @@ -126,7 +129,7 @@ public : * input source as file, a new handleof which it gives to each new stream * it creates. */ - StdInInputSource(); + StdInInputSource(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); //@} /** @name Destructor */ @@ -155,9 +158,9 @@ public : //@} }; -inline StdInInputSource::StdInInputSource() : +inline StdInInputSource::StdInInputSource(MemoryManager* const manager) : - InputSource("stdin") + InputSource("stdin", manager) { } diff --git a/src/xercesc/framework/URLInputSource.cpp b/src/xercesc/framework/URLInputSource.cpp index 2bc482c8f..463f5ad04 100644 --- a/src/xercesc/framework/URLInputSource.cpp +++ b/src/xercesc/framework/URLInputSource.cpp @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.4 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.3 2002/11/04 15:00:21 tng * C++ Namespace Support. * @@ -103,41 +106,49 @@ XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // URLInputSource: Constructors and Destructor // --------------------------------------------------------------------------- -URLInputSource::URLInputSource(const XMLURL& urlId) : +URLInputSource::URLInputSource( const XMLURL& urlId + , MemoryManager* const manager) : - fURL(urlId) + InputSource(manager) + , fURL(urlId) { setSystemId(fURL.getURLText()); } -URLInputSource::URLInputSource( const XMLCh* const baseId - , const XMLCh* const systemId) : - fURL(baseId, systemId) +URLInputSource::URLInputSource( const XMLCh* const baseId + , const XMLCh* const systemId + , MemoryManager* const manager) : + InputSource(manager) + , fURL(baseId, systemId) { // Create a URL that will build up the full URL and store as the system id setSystemId(fURL.getURLText()); } -URLInputSource::URLInputSource( const XMLCh* const baseId - , const XMLCh* const systemId - , const XMLCh* const publicId) : - InputSource(0, publicId) +URLInputSource::URLInputSource( const XMLCh* const baseId + , const XMLCh* const systemId + , const XMLCh* const publicId + , MemoryManager* const manager) : + InputSource(0, publicId, manager) , fURL(baseId, systemId) { setSystemId(fURL.getURLText()); } -URLInputSource::URLInputSource( const XMLCh* const baseId - , const char* const systemId) : - fURL(baseId, systemId) +URLInputSource::URLInputSource( const XMLCh* const baseId + , const char* const systemId + , MemoryManager* const manager) : + InputSource(manager) + , fURL(baseId, systemId) { setSystemId(fURL.getURLText()); } URLInputSource::URLInputSource( const XMLCh* const baseId , const char* const systemId - , const char* const publicId) : - InputSource(0, publicId) + , const char* const publicId + , MemoryManager* const manager) : + InputSource(0, publicId, manager) , fURL(baseId, systemId) { setSystemId(fURL.getURLText()); diff --git a/src/xercesc/framework/URLInputSource.hpp b/src/xercesc/framework/URLInputSource.hpp index b64d5a43e..696e61ef4 100644 --- a/src/xercesc/framework/URLInputSource.hpp +++ b/src/xercesc/framework/URLInputSource.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.3 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.2 2002/11/04 15:00:21 tng * C++ Namespace Support. * @@ -144,7 +147,11 @@ public : * @param urlId The URL which holds the system id of the entity * to parse. */ - URLInputSource(const XMLURL& urlId); + URLInputSource + ( + const XMLURL& urlId + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); /** @@ -163,6 +170,7 @@ public : ( const XMLCh* const baseId , const XMLCh* const systemId + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -183,6 +191,7 @@ public : const XMLCh* const baseId , const XMLCh* const systemId , const XMLCh* const publicId + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); @@ -201,6 +210,7 @@ public : ( const XMLCh* const baseId , const char* const systemId + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -223,6 +233,7 @@ public : const XMLCh* const baseId , const char* const systemId , const char* const publicId + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} diff --git a/src/xercesc/framework/Wrapper4DOMInputSource.cpp b/src/xercesc/framework/Wrapper4DOMInputSource.cpp index cf3ec54f9..ac9624958 100644 --- a/src/xercesc/framework/Wrapper4DOMInputSource.cpp +++ b/src/xercesc/framework/Wrapper4DOMInputSource.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.3 2002/11/04 15:00:21 tng * C++ Namespace Support. * @@ -82,8 +85,10 @@ XERCES_CPP_NAMESPACE_BEGIN // Wrapper4DOMInputSource: Constructor and Destructor // --------------------------------------------------------------------------- Wrapper4DOMInputSource::Wrapper4DOMInputSource(DOMInputSource* const inputSource, - const bool adoptFlag) : - fAdoptInputSource(adoptFlag) + const bool adoptFlag, + MemoryManager* const manager) : + InputSource(manager) + , fAdoptInputSource(adoptFlag) , fInputSource(inputSource) { if (!inputSource) diff --git a/src/xercesc/framework/Wrapper4DOMInputSource.hpp b/src/xercesc/framework/Wrapper4DOMInputSource.hpp index 5d3e063f8..e604a2637 100644 --- a/src/xercesc/framework/Wrapper4DOMInputSource.hpp +++ b/src/xercesc/framework/Wrapper4DOMInputSource.hpp @@ -88,8 +88,12 @@ public: * @param adoptFlag Indicates if the wrapper should adopt the wrapped * DOMInputSource. Default is true. */ - Wrapper4DOMInputSource(DOMInputSource* const inputSource, - const bool adoptFlag = true); + Wrapper4DOMInputSource + ( + DOMInputSource* const inputSource + , const bool adoptFlag = true + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager + ); /** * Destructor diff --git a/src/xercesc/framework/XMLAttDef.cpp b/src/xercesc/framework/XMLAttDef.cpp index 96f9cc98a..49de355ca 100644 --- a/src/xercesc/framework/XMLAttDef.cpp +++ b/src/xercesc/framework/XMLAttDef.cpp @@ -151,8 +151,9 @@ XMLAttDef::~XMLAttDef() // --------------------------------------------------------------------------- // XMLAttDef: Hidden constructors // --------------------------------------------------------------------------- -XMLAttDef::XMLAttDef(const XMLAttDef::AttTypes type - , const XMLAttDef::DefAttTypes defType) : +XMLAttDef::XMLAttDef( const XMLAttDef::AttTypes type + , const XMLAttDef::DefAttTypes defType + , MemoryManager* const manager) : fDefaultType(defType) , fType(type) @@ -162,14 +163,15 @@ XMLAttDef::XMLAttDef(const XMLAttDef::AttTypes type , fId(XMLAttDef::fgInvalidAttrId) , fValue(0) , fEnumeration(0) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { } -XMLAttDef::XMLAttDef(const XMLCh* const attrValue - , const XMLAttDef::AttTypes type - , const XMLAttDef::DefAttTypes defType - , const XMLCh* const enumValues) : +XMLAttDef::XMLAttDef( const XMLCh* const attrValue + , const XMLAttDef::AttTypes type + , const XMLAttDef::DefAttTypes defType + , const XMLCh* const enumValues + , MemoryManager* const manager) : fDefaultType(defType) , fType(type) @@ -179,7 +181,7 @@ XMLAttDef::XMLAttDef(const XMLCh* const attrValue , fId(XMLAttDef::fgInvalidAttrId) , fValue(0) , fEnumeration(0) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { try { diff --git a/src/xercesc/framework/XMLAttDef.hpp b/src/xercesc/framework/XMLAttDef.hpp index e41d375d2..13c7af747 100644 --- a/src/xercesc/framework/XMLAttDef.hpp +++ b/src/xercesc/framework/XMLAttDef.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.8 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -511,8 +514,9 @@ protected : // ----------------------------------------------------------------------- XMLAttDef ( - const AttTypes type = CData - , const DefAttTypes defType = Implied + const AttTypes type = CData + , const DefAttTypes defType= Implied + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); XMLAttDef ( @@ -520,6 +524,7 @@ protected : , const AttTypes type , const DefAttTypes defType , const XMLCh* const enumValues = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); diff --git a/src/xercesc/framework/XMLAttDefList.hpp b/src/xercesc/framework/XMLAttDefList.hpp index 5f93c026c..6f8105c7e 100644 --- a/src/xercesc/framework/XMLAttDefList.hpp +++ b/src/xercesc/framework/XMLAttDefList.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.3 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -107,7 +110,7 @@ class XMLAttDef; * there are portability issues with deriving from a template class in a * DLL. It does though provide a similar enumerator interface. */ -class XMLPARSER_EXPORT XMLAttDefList +class XMLPARSER_EXPORT XMLAttDefList : public XMemory { public: // ----------------------------------------------------------------------- diff --git a/src/xercesc/framework/XMLAttr.hpp b/src/xercesc/framework/XMLAttr.hpp index 41bc9f590..f679b7c34 100644 --- a/src/xercesc/framework/XMLAttr.hpp +++ b/src/xercesc/framework/XMLAttr.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.5 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -188,9 +191,9 @@ public: , const XMLCh* const attrName , const XMLCh* const attrPrefix , const XMLCh* const attrValue - , const XMLAttDef::AttTypes type// = XMLAttDef::CData - , const bool specified// = true - , MemoryManager* const manager //= XMLPlatformUtils::fgMemoryManager + , const XMLAttDef::AttTypes type = XMLAttDef::CData + , const bool specified = true + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -222,9 +225,9 @@ public: const unsigned int uriId , const XMLCh* const rawName , const XMLCh* const attrValue - , const XMLAttDef::AttTypes type// = XMLAttDef::CData - , const bool specified// = true - , MemoryManager* const manager //= XMLPlatformUtils::fgMemoryManager + , const XMLAttDef::AttTypes type = XMLAttDef::CData + , const bool specified = true + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} diff --git a/src/xercesc/framework/XMLBuffer.hpp b/src/xercesc/framework/XMLBuffer.hpp index 2d1289c73..613e452d6 100644 --- a/src/xercesc/framework/XMLBuffer.hpp +++ b/src/xercesc/framework/XMLBuffer.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.4 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -122,8 +125,8 @@ public : /** @name Constructor */ //@{ - XMLBuffer(int capacity = 1023, - MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) : + XMLBuffer(int capacity = 1023 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager) : fUsed(false) , fIndex(0) diff --git a/src/xercesc/framework/XMLBufferMgr.hpp b/src/xercesc/framework/XMLBufferMgr.hpp index e82065def..756160cf2 100644 --- a/src/xercesc/framework/XMLBufferMgr.hpp +++ b/src/xercesc/framework/XMLBufferMgr.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.5 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -120,7 +123,7 @@ public : /** @name Constructor */ //@{ - XMLBufferMgr(MemoryManager* const manager/* = XMLPlatformUtils::fgMemoryManager*/); + XMLBufferMgr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); //@} /** @name Destructor */ diff --git a/src/xercesc/framework/XMLElementDecl.hpp b/src/xercesc/framework/XMLElementDecl.hpp index 2b87daa3d..fba5a147c 100644 --- a/src/xercesc/framework/XMLElementDecl.hpp +++ b/src/xercesc/framework/XMLElementDecl.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.6 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -589,7 +592,7 @@ protected : // ----------------------------------------------------------------------- // Hidden constructors // ----------------------------------------------------------------------- - XMLElementDecl(MemoryManager* const manager /*= XMLPlatformUtils::fgMemoryManager*/); + XMLElementDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); private : // ----------------------------------------------------------------------- diff --git a/src/xercesc/framework/XMLEntityDecl.cpp b/src/xercesc/framework/XMLEntityDecl.cpp index 368d496e8..b70c84f68 100644 --- a/src/xercesc/framework/XMLEntityDecl.cpp +++ b/src/xercesc/framework/XMLEntityDecl.cpp @@ -71,7 +71,7 @@ XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // XMLEntityDecl: Constructors and Destructor // --------------------------------------------------------------------------- -XMLEntityDecl::XMLEntityDecl() : +XMLEntityDecl::XMLEntityDecl(MemoryManager* const manager) : fId(0) , fValueLen(0) @@ -81,11 +81,12 @@ XMLEntityDecl::XMLEntityDecl() : , fPublicId(0) , fSystemId(0) , fBaseURI(0) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { } -XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName) : +XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName, + MemoryManager* const manager) : fId(0) , fValueLen(0) @@ -95,13 +96,14 @@ XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName) : , fPublicId(0) , fSystemId(0) , fBaseURI(0) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { fName = XMLString::replicate(entName, fMemoryManager); } -XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName - , const XMLCh* const value) : +XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName + , const XMLCh* const value + , MemoryManager* const manager) : fId(0) , fValueLen(XMLString::stringLen(value)) , fValue(0) @@ -110,7 +112,7 @@ XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName , fPublicId(0) , fSystemId(0) , fBaseURI(0) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { try { @@ -123,8 +125,9 @@ XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName } } -XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName - , const XMLCh value) : +XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName + , const XMLCh value + , MemoryManager* const manager) : fId(0) , fValueLen(1) , fValue(0) diff --git a/src/xercesc/framework/XMLEntityDecl.hpp b/src/xercesc/framework/XMLEntityDecl.hpp index 1c47d88f1..984091b8e 100644 --- a/src/xercesc/framework/XMLEntityDecl.hpp +++ b/src/xercesc/framework/XMLEntityDecl.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.6 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -137,7 +140,7 @@ public: /** * Deafult Constructor */ - XMLEntityDecl(); + XMLEntityDecl(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** Constructor with a const entity name * @@ -146,6 +149,7 @@ public: XMLEntityDecl ( const XMLCh* const entName + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -158,6 +162,7 @@ public: ( const XMLCh* const entName , const XMLCh* const value + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** @@ -170,6 +175,7 @@ public: ( const XMLCh* const entName , const XMLCh value + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} diff --git a/src/xercesc/framework/XMLFormatter.cpp b/src/xercesc/framework/XMLFormatter.cpp index 4f3731e2d..3f6131202 100644 --- a/src/xercesc/framework/XMLFormatter.cpp +++ b/src/xercesc/framework/XMLFormatter.cpp @@ -182,7 +182,8 @@ XMLFormatter::XMLFormatter( const char* const outEncoding , const char* const docVersion , XMLFormatTarget* const target , const EscapeFlags escapeFlags - , const UnRepFlags unrepFlags) + , const UnRepFlags unrepFlags + , MemoryManager* const manager) : fEscapeFlags(escapeFlags) , fOutEncoding(0) , fTarget(target) @@ -199,7 +200,7 @@ XMLFormatter::XMLFormatter( const char* const outEncoding , fQuoteRef(0) , fQuoteLen(0) , fIsXML11(false) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { // Transcode the encoding string fOutEncoding = XMLString::transcode(outEncoding, fMemoryManager); @@ -235,7 +236,8 @@ XMLFormatter::XMLFormatter( const XMLCh* const outEncoding , const XMLCh* const docVersion , XMLFormatTarget* const target , const EscapeFlags escapeFlags - , const UnRepFlags unrepFlags) + , const UnRepFlags unrepFlags + , MemoryManager* const manager) : fEscapeFlags(escapeFlags) , fOutEncoding(0) , fTarget(target) @@ -252,7 +254,7 @@ XMLFormatter::XMLFormatter( const XMLCh* const outEncoding , fQuoteRef(0) , fQuoteLen(0) , fIsXML11(false) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { // Try to create a transcoder for this encoding XMLTransService::Codes resCode; diff --git a/src/xercesc/framework/XMLFormatter.hpp b/src/xercesc/framework/XMLFormatter.hpp index 69b1d2d5d..ff849cc6f 100644 --- a/src/xercesc/framework/XMLFormatter.hpp +++ b/src/xercesc/framework/XMLFormatter.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.14 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.13 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -286,6 +289,7 @@ public: , XMLFormatTarget* const target , const EscapeFlags escapeFlags = NoEscapes , const UnRepFlags unrepFlags = UnRep_Fail + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); XMLFormatter @@ -295,6 +299,7 @@ public: , XMLFormatTarget* const target , const EscapeFlags escapeFlags = NoEscapes , const UnRepFlags unrepFlags = UnRep_Fail + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); ~XMLFormatter(); diff --git a/src/xercesc/framework/XMLNotationDecl.cpp b/src/xercesc/framework/XMLNotationDecl.cpp index 646a00a20..4c451b836 100644 --- a/src/xercesc/framework/XMLNotationDecl.cpp +++ b/src/xercesc/framework/XMLNotationDecl.cpp @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.6 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.5 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -93,27 +96,28 @@ XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // XMLNotationDecl: Constructors and operators // --------------------------------------------------------------------------- -XMLNotationDecl::XMLNotationDecl() : +XMLNotationDecl::XMLNotationDecl(MemoryManager* const manager) : fId(0) , fName(0) , fPublicId(0) , fSystemId(0) , fBaseURI(0) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { } -XMLNotationDecl::XMLNotationDecl( const XMLCh* const notName - , const XMLCh* const pubId - , const XMLCh* const sysId - , const XMLCh* const baseURI) : +XMLNotationDecl::XMLNotationDecl( const XMLCh* const notName + , const XMLCh* const pubId + , const XMLCh* const sysId + , const XMLCh* const baseURI + , MemoryManager* const manager) : fId(0) , fName(0) , fPublicId(0) , fSystemId(0) , fBaseURI(0) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { try { diff --git a/src/xercesc/framework/XMLNotationDecl.hpp b/src/xercesc/framework/XMLNotationDecl.hpp index 12120b9b6..a5643f517 100644 --- a/src/xercesc/framework/XMLNotationDecl.hpp +++ b/src/xercesc/framework/XMLNotationDecl.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.6 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -123,13 +126,14 @@ public: /** @name Constructors */ //@{ - XMLNotationDecl(); + XMLNotationDecl(MemoryManager* const manager); XMLNotationDecl ( const XMLCh* const notName , const XMLCh* const pubId , const XMLCh* const sysId , const XMLCh* const baseURI = 0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} diff --git a/src/xercesc/framework/XMLRefInfo.hpp b/src/xercesc/framework/XMLRefInfo.hpp index 0bc62bb9a..def55087f 100644 --- a/src/xercesc/framework/XMLRefInfo.hpp +++ b/src/xercesc/framework/XMLRefInfo.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/05/16 21:36:55 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.6 2003/05/15 18:26:07 knoaman * Partial implementation of the configurable memory manager. * @@ -129,9 +132,10 @@ public : //@{ XMLRefInfo ( - const XMLCh* const refName - , const bool fDeclared = false - , const bool fUsed = false + const XMLCh* const refName + , const bool fDeclared = false + , const bool fUsed = false + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} @@ -190,13 +194,14 @@ private : // --------------------------------------------------------------------------- // XMLRefInfo: Constructors and Destructor // --------------------------------------------------------------------------- -inline XMLRefInfo::XMLRefInfo( const XMLCh* const refName - , const bool declared - , const bool used) : +inline XMLRefInfo::XMLRefInfo( const XMLCh* const refName + , const bool declared + , const bool used + , MemoryManager* const manager) : fDeclared(declared) , fUsed(used) , fRefName(0) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { fRefName = XMLString::replicate(refName, fMemoryManager); } diff --git a/src/xercesc/internal/DGXMLScanner.cpp b/src/xercesc/internal/DGXMLScanner.cpp index 100eaf995..c627c030b 100644 --- a/src/xercesc/internal/DGXMLScanner.cpp +++ b/src/xercesc/internal/DGXMLScanner.cpp @@ -85,6 +85,7 @@ XERCES_CPP_NAMESPACE_BEGIN DGXMLScanner::DGXMLScanner(XMLValidator* const valToAdopt, MemoryManager* const manager) : XMLScanner(valToAdopt, manager) + , fElemStack(manager) , fAttrNSList(0) , fDTDValidator(0) , fDTDGrammar(0) @@ -118,6 +119,7 @@ DGXMLScanner::DGXMLScanner( XMLDocumentHandler* const docHandler , MemoryManager* const manager) : XMLScanner(docHandler, docTypeHandler, entityHandler, errHandler, valToAdopt, manager) + , fElemStack(manager) , fAttrNSList(0) , fDTDValidator(0) , fDTDGrammar(0) @@ -981,7 +983,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 (fMemoryManager) DTDEntityDecl(gDTDStr); + DTDEntityDecl* declDTD = new (fMemoryManager) DTDEntityDecl(gDTDStr, false, fMemoryManager); declDTD->setSystemId(sysId); Janitor<DTDEntityDecl> janDecl(declDTD); @@ -1723,7 +1725,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 (fMemoryManager) DTDEntityDecl(gDTDStr); + DTDEntityDecl* declDTD = new (fMemoryManager) DTDEntityDecl(gDTDStr, false, fMemoryManager); declDTD->setSystemId(src.getSystemId()); Janitor<DTDEntityDecl> janDecl(declDTD); @@ -2316,7 +2318,7 @@ InputSource* DGXMLScanner::resolveSystemId(const XMLCh* const sysId) else { if (fStandardUriConformant && urlTmp.hasInvalidChar()) ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); - srcToFill = new (fMemoryManager) URLInputSource(urlTmp); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } catch(const MalformedURLException& e) @@ -2327,6 +2329,7 @@ InputSource* DGXMLScanner::resolveSystemId(const XMLCh* const sysId) ( lastInfo.systemId , expSysId.getRawBuffer() + , fMemoryManager ); else throw e; diff --git a/src/xercesc/internal/ElemStack.cpp b/src/xercesc/internal/ElemStack.cpp index 6fbc251bc..60134d88e 100644 --- a/src/xercesc/internal/ElemStack.cpp +++ b/src/xercesc/internal/ElemStack.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/05/16 21:36:57 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.5 2003/05/15 18:26:29 knoaman * Partial implementation of the configurable memory manager. * @@ -146,7 +149,7 @@ XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- // ElemStack: Constructors and Destructor // --------------------------------------------------------------------------- -ElemStack::ElemStack() : +ElemStack::ElemStack(MemoryManager* const manager) : fEmptyNamespaceId(0) , fGlobalPoolId(0) @@ -158,7 +161,7 @@ ElemStack::ElemStack() : , fXMLPoolId(0) , fXMLNSNamespaceId(0) , fXMLNSPoolId(0) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { // Do an initial allocation of the stack and zero it out fStack = (StackElem**) fMemoryManager->allocate @@ -554,7 +557,7 @@ void ElemStack::expandStack() // --------------------------------------------------------------------------- // WFElemStack: Constructors and Destructor // --------------------------------------------------------------------------- -WFElemStack::WFElemStack() : +WFElemStack::WFElemStack(MemoryManager* const manager) : fEmptyNamespaceId(0) , fGlobalPoolId(0) @@ -568,7 +571,7 @@ WFElemStack::WFElemStack() : , fMapCapacity(0) , fMap(0) , fStack(0) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { // Do an initial allocation of the stack and zero it out fStack = (StackElem**) fMemoryManager->allocate diff --git a/src/xercesc/internal/ElemStack.hpp b/src/xercesc/internal/ElemStack.hpp index 1db473488..ee33a6e68 100644 --- a/src/xercesc/internal/ElemStack.hpp +++ b/src/xercesc/internal/ElemStack.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/05/16 21:36:57 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.5 2003/05/15 18:26:29 knoaman * Partial implementation of the configurable memory manager. * @@ -216,7 +219,7 @@ public : // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- - ElemStack(); + ElemStack(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~ElemStack(); @@ -402,7 +405,7 @@ public : // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- - WFElemStack(); + WFElemStack(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~WFElemStack(); diff --git a/src/xercesc/internal/IGXMLScanner.cpp b/src/xercesc/internal/IGXMLScanner.cpp index ee63cd197..f3eeea486 100644 --- a/src/xercesc/internal/IGXMLScanner.cpp +++ b/src/xercesc/internal/IGXMLScanner.cpp @@ -94,6 +94,8 @@ IGXMLScanner::IGXMLScanner( XMLValidator* const valToAdopt , fSeeXsi(false) , fElemStateSize(16) , fElemState(0) + , fElemStack(manager) + , fContent(1023, manager) , fRawAttrList(0) , fDTDValidator(0) , fSchemaValidator(0) @@ -128,6 +130,8 @@ IGXMLScanner::IGXMLScanner( XMLDocumentHandler* const docHandler , fSeeXsi(false) , fElemStateSize(16) , fElemState(0) + , fElemStack(manager) + , fContent(1023, manager) , fRawAttrList(0) , fDTDValidator(0) , fSchemaValidator(0) @@ -1385,7 +1389,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 (fMemoryManager) DTDEntityDecl(gDTDStr); + DTDEntityDecl* declDTD = new (fMemoryManager) DTDEntityDecl(gDTDStr, false, fMemoryManager); declDTD->setSystemId(sysId); Janitor<DTDEntityDecl> janDecl(declDTD); @@ -2376,7 +2380,7 @@ bool IGXMLScanner::scanStartTagNS(bool& gotData) if (!XMLString::startsWith(typeName, poundStr)) { const int comma = XMLString::indexOf(typeName, chComma); if (comma > 0) { - XMLBuffer prefixBuf(comma+1); + XMLBuffer prefixBuf(comma+1, fMemoryManager); prefixBuf.append(typeName, comma); const XMLCh* uriStr = prefixBuf.getRawBuffer(); @@ -2892,7 +2896,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 (fMemoryManager) DTDEntityDecl(gDTDStr); + DTDEntityDecl* declDTD = new (fMemoryManager) DTDEntityDecl(gDTDStr, false, fMemoryManager); declDTD->setSystemId(src.getSystemId()); Janitor<DTDEntityDecl> janDecl(declDTD); diff --git a/src/xercesc/internal/IGXMLScanner2.cpp b/src/xercesc/internal/IGXMLScanner2.cpp index 6369b6cd8..dc1e1c4eb 100644 --- a/src/xercesc/internal/IGXMLScanner2.cpp +++ b/src/xercesc/internal/IGXMLScanner2.cpp @@ -1026,7 +1026,7 @@ void IGXMLScanner::sendCharData(XMLBuffer& toSend) // The normalized data can only be as large as the // original size, so this will avoid allocating way // too much or too little memory. - XMLBuffer toFill(len+1); + XMLBuffer toFill(len+1, fMemoryManager); toFill.set(rawBuf); if (fNormalizeData) { @@ -1068,7 +1068,7 @@ void IGXMLScanner::sendCharData(XMLBuffer& toSend) // The normalized data can only be as large as the // original size, so this will avoid allocating way // too much or too little memory. - XMLBuffer toFill(len+1); + XMLBuffer toFill(len+1, fMemoryManager); toFill.set(rawBuf); if (fNormalizeData) { @@ -1346,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 (fMemoryManager) URLInputSource(urlTmp); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } @@ -1358,6 +1358,7 @@ void IGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con ( lastInfo.systemId , expSysId.getRawBuffer() + , fMemoryManager ); else throw e; @@ -1516,7 +1517,7 @@ InputSource* IGXMLScanner::resolveSystemId(const XMLCh* const sysId) else { if (fStandardUriConformant && urlTmp.hasInvalidChar()) ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); - srcToFill = new (fMemoryManager) URLInputSource(urlTmp); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } catch(const MalformedURLException& e) @@ -1527,6 +1528,7 @@ InputSource* IGXMLScanner::resolveSystemId(const XMLCh* const sysId) ( lastInfo.systemId , expSysId.getRawBuffer() + , fMemoryManager ); else throw e; diff --git a/src/xercesc/internal/ReaderMgr.cpp b/src/xercesc/internal/ReaderMgr.cpp index 06bb4f061..45f23d755 100644 --- a/src/xercesc/internal/ReaderMgr.cpp +++ b/src/xercesc/internal/ReaderMgr.cpp @@ -454,6 +454,7 @@ XMLReader* ReaderMgr::createReader( const InputSource& src , false , calcSrcOfs , fXMLVersion + , fMemoryManager ); } else @@ -469,6 +470,7 @@ XMLReader* ReaderMgr::createReader( const InputSource& src , false , calcSrcOfs , fXMLVersion + , fMemoryManager ); } } @@ -501,7 +503,7 @@ XMLReader* ReaderMgr::createReader( const XMLCh* const sysId , const bool calcSrcOfs) { // Create a buffer for expanding the system id - XMLBuffer expSysId; + XMLBuffer expSysId(1023, fMemoryManager); // // Allow the entity handler to expand the system id if they choose @@ -551,7 +553,7 @@ XMLReader* ReaderMgr::createReader( const XMLCh* const sysId else { if (fStandardUriConformant && urlTmp.hasInvalidChar()) ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); - srcToFill = new (fMemoryManager) URLInputSource(urlTmp); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } @@ -563,6 +565,7 @@ XMLReader* ReaderMgr::createReader( const XMLCh* const sysId ( lastInfo.systemId , expSysId.getRawBuffer() + , fMemoryManager ); else throw e; @@ -610,7 +613,7 @@ XMLReader* ReaderMgr::createReader( const XMLCh* const baseURI , const bool calcSrcOfs) { // Create a buffer for expanding the system id - XMLBuffer expSysId; + XMLBuffer expSysId(1023, fMemoryManager); // // Allow the entity handler to expand the system id if they choose @@ -661,7 +664,7 @@ XMLReader* ReaderMgr::createReader( const XMLCh* const baseURI else { if (fStandardUriConformant && urlTmp.hasInvalidChar()) ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); - srcToFill = new (fMemoryManager) URLInputSource(urlTmp); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } @@ -673,6 +676,7 @@ XMLReader* ReaderMgr::createReader( const XMLCh* const baseURI ( lastInfo.systemId , expSysId.getRawBuffer() + , fMemoryManager ); else throw e; @@ -749,6 +753,7 @@ ReaderMgr::createIntEntReader( const XMLCh* const sysId , false , calcSrcOfs , fXMLVersion + , fMemoryManager ); // If it failed for any reason, then return zero. diff --git a/src/xercesc/internal/ReaderMgr.hpp b/src/xercesc/internal/ReaderMgr.hpp index b14c9db4e..14925dda0 100644 --- a/src/xercesc/internal/ReaderMgr.hpp +++ b/src/xercesc/internal/ReaderMgr.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/05/16 21:36:57 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.8 2003/05/15 18:26:29 knoaman * Partial implementation of the configurable memory manager. * @@ -172,7 +175,7 @@ public : // ----------------------------------------------------------------------- // Class specific types // ----------------------------------------------------------------------- - struct LastExtEntityInfo + struct LastExtEntityInfo : public XMemory { const XMLCh* systemId; const XMLCh* publicId; @@ -184,7 +187,7 @@ public : // ----------------------------------------------------------------------- // Constructors and Destructor // ----------------------------------------------------------------------- - ReaderMgr(MemoryManager* const manager /*= XMLPlatformUtils::fgMemoryManager*/); + ReaderMgr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); ~ReaderMgr(); diff --git a/src/xercesc/internal/SGXMLScanner.cpp b/src/xercesc/internal/SGXMLScanner.cpp index a41ff62d3..bb62d4ef4 100644 --- a/src/xercesc/internal/SGXMLScanner.cpp +++ b/src/xercesc/internal/SGXMLScanner.cpp @@ -95,6 +95,8 @@ SGXMLScanner::SGXMLScanner( XMLValidator* const valToAdopt , fSeeXsi(false) , fElemStateSize(16) , fElemState(0) + , fElemStack(manager) + , fContent(1023, manager) , fEntityTable(0) , fRawAttrList(0) , fSchemaValidator(0) @@ -134,6 +136,8 @@ SGXMLScanner::SGXMLScanner( XMLDocumentHandler* const docHandler , fSeeXsi(false) , fElemStateSize(16) , fElemState(0) + , fElemStack(manager) + , fContent(1023, manager) , fEntityTable(0) , fRawAttrList(0) , fSchemaValidator(0) @@ -1463,7 +1467,7 @@ bool SGXMLScanner::scanStartTag(bool& gotData) if (!XMLString::startsWith(typeName, poundStr)) { const int comma = XMLString::indexOf(typeName, chComma); if (comma > 0) { - XMLBuffer prefixBuf(comma+1); + XMLBuffer prefixBuf(comma+1, fMemoryManager); prefixBuf.append(typeName, comma); const XMLCh* uriStr = prefixBuf.getRawBuffer(); @@ -2802,7 +2806,7 @@ void SGXMLScanner::sendCharData(XMLBuffer& toSend) // The normalized data can only be as large as the // original size, so this will avoid allocating way // too much or too little memory. - XMLBuffer toFill(len+1); + XMLBuffer toFill(len+1, fMemoryManager); toFill.set(rawBuf); if (fNormalizeData) { @@ -2836,7 +2840,7 @@ void SGXMLScanner::sendCharData(XMLBuffer& toSend) // The normalized data can only be as large as the // original size, so this will avoid allocating way // too much or too little memory. - XMLBuffer toFill(len+1); + XMLBuffer toFill(len+1, fMemoryManager); toFill.set(rawBuf); if (fNormalizeData) { @@ -3109,7 +3113,7 @@ void SGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con else { if (fStandardUriConformant && urlTmp.hasInvalidChar()) ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); - srcToFill = new (fMemoryManager) URLInputSource(urlTmp); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } @@ -3121,6 +3125,7 @@ void SGXMLScanner::resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* con ( lastInfo.systemId , expSysId.getRawBuffer() + , fMemoryManager ); else throw e; @@ -3256,7 +3261,7 @@ InputSource* SGXMLScanner::resolveSystemId(const XMLCh* const sysId) else { if (fStandardUriConformant && urlTmp.hasInvalidChar()) ThrowXML(MalformedURLException, XMLExcepts::URL_MalformedURL); - srcToFill = new (fMemoryManager) URLInputSource(urlTmp); + srcToFill = new (fMemoryManager) URLInputSource(urlTmp, fMemoryManager); } } catch(const MalformedURLException& e) @@ -3267,6 +3272,7 @@ InputSource* SGXMLScanner::resolveSystemId(const XMLCh* const sysId) ( lastInfo.systemId , expSysId.getRawBuffer() + , fMemoryManager ); else throw e; diff --git a/src/xercesc/internal/SGXMLScanner.hpp b/src/xercesc/internal/SGXMLScanner.hpp index e88f291c0..ea336ae0e 100644 --- a/src/xercesc/internal/SGXMLScanner.hpp +++ b/src/xercesc/internal/SGXMLScanner.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/05/16 21:36:57 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.6 2003/05/15 18:26:29 knoaman * Partial implementation of the configurable memory manager. * @@ -108,17 +111,17 @@ public : // ----------------------------------------------------------------------- SGXMLScanner ( - XMLValidator* const valToAdopt - , MemoryManager* const manager + XMLValidator* const valToAdopt + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); SGXMLScanner ( - XMLDocumentHandler* const docHandler - , DocTypeHandler* const docTypeHandler - , XMLEntityHandler* const entityHandler - , XMLErrorReporter* const errReporter - , XMLValidator* const valToAdopt - , MemoryManager* const manager + XMLDocumentHandler* const docHandler + , DocTypeHandler* const docTypeHandler + , XMLEntityHandler* const entityHandler + , XMLErrorReporter* const errReporter + , XMLValidator* const valToAdopt + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~SGXMLScanner(); diff --git a/src/xercesc/internal/VecAttributesImpl.cpp b/src/xercesc/internal/VecAttributesImpl.cpp index 22e503b09..eabbef022 100644 --- a/src/xercesc/internal/VecAttributesImpl.cpp +++ b/src/xercesc/internal/VecAttributesImpl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.4 2003/05/16 21:36:57 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.3 2002/11/04 14:58:18 tng * C++ Namespace Support. * @@ -188,7 +191,7 @@ int VecAttributesImpl::getIndex(const XMLCh* const uri, const XMLCh* const local // Search the vector for the attribute with the given name and return // its type. // - XMLBuffer uriBuffer ; + XMLBuffer uriBuffer(1023, fVector->getMemoryManager()) ; for (unsigned int index = 0; index < fCount; index++) { const XMLAttr* curElem = fVector->elementAt(index); diff --git a/src/xercesc/internal/WFXMLScanner.cpp b/src/xercesc/internal/WFXMLScanner.cpp index cd7cb2b65..d423e1ff9 100644 --- a/src/xercesc/internal/WFXMLScanner.cpp +++ b/src/xercesc/internal/WFXMLScanner.cpp @@ -89,6 +89,7 @@ WFXMLScanner::WFXMLScanner( XMLValidator* const valToAdopt , fAttrNameHashList(0) , fAttrNSList(0) , fElementLookup(0) + , fElemStack(manager) { try { @@ -115,6 +116,7 @@ WFXMLScanner::WFXMLScanner( XMLDocumentHandler* const docHandler , fAttrNameHashList(0) , fAttrNSList(0) , fElementLookup(0) + , fElemStack(manager) { try { diff --git a/src/xercesc/internal/WFXMLScanner.hpp b/src/xercesc/internal/WFXMLScanner.hpp index 42830832e..674473a6f 100644 --- a/src/xercesc/internal/WFXMLScanner.hpp +++ b/src/xercesc/internal/WFXMLScanner.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/05/16 21:36:57 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.5 2003/05/15 18:26:29 knoaman * Partial implementation of the configurable memory manager. * @@ -96,17 +99,17 @@ public : // ----------------------------------------------------------------------- WFXMLScanner ( - XMLValidator* const valToAdopt - , MemoryManager* const manager + XMLValidator* const valToAdopt + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); WFXMLScanner ( - XMLDocumentHandler* const docHandler - , DocTypeHandler* const docTypeHandler - , XMLEntityHandler* const entityHandler - , XMLErrorReporter* const errReporter - , XMLValidator* const valToAdopt - , MemoryManager* const manager + XMLDocumentHandler* const docHandler + , DocTypeHandler* const docTypeHandler + , XMLEntityHandler* const entityHandler + , XMLErrorReporter* const errReporter + , XMLValidator* const valToAdopt + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~WFXMLScanner(); diff --git a/src/xercesc/internal/XMLReader.cpp b/src/xercesc/internal/XMLReader.cpp index 546331504..aea97d447 100644 --- a/src/xercesc/internal/XMLReader.cpp +++ b/src/xercesc/internal/XMLReader.cpp @@ -125,15 +125,16 @@ bool XMLReader::isPublicIdChar(const XMLCh toCheck) // --------------------------------------------------------------------------- // XMLReader: Constructors and Destructor // --------------------------------------------------------------------------- -XMLReader::XMLReader(const XMLCh* const pubId - , const XMLCh* const sysId - , BinInputStream* const streamToAdopt - , const RefFrom from - , const Types type - , const Sources source - , const bool throwAtEnd - , const bool calculateSrcOfs - , const XMLVersion version) : +XMLReader::XMLReader(const XMLCh* const pubId + , const XMLCh* const sysId + , BinInputStream* const streamToAdopt + , const RefFrom from + , const Types type + , const Sources source + , const bool throwAtEnd + , const bool calculateSrcOfs + , const XMLVersion version + , MemoryManager* const manager) : fCharIndex(0) , fCharsAvail(0) , fCurCol(1) @@ -157,7 +158,7 @@ XMLReader::XMLReader(const XMLCh* const pubId , fThrowAtEnd(throwAtEnd) , fTranscoder(0) , fType(type) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { setXMLVersion(version); @@ -203,16 +204,17 @@ XMLReader::XMLReader(const XMLCh* const pubId } -XMLReader::XMLReader(const XMLCh* const pubId - , const XMLCh* const sysId - , BinInputStream* const streamToAdopt - , const XMLCh* const encodingStr - , const RefFrom from - , const Types type - , const Sources source - , const bool throwAtEnd - , const bool calculateSrcOfs - , const XMLVersion version) : +XMLReader::XMLReader(const XMLCh* const pubId + , const XMLCh* const sysId + , BinInputStream* const streamToAdopt + , const XMLCh* const encodingStr + , const RefFrom from + , const Types type + , const Sources source + , const bool throwAtEnd + , const bool calculateSrcOfs + , const XMLVersion version + , MemoryManager* const manager) : fCharIndex(0) , fCharsAvail(0) , fCurCol(1) @@ -237,7 +239,7 @@ XMLReader::XMLReader(const XMLCh* const pubId , fThrowAtEnd(throwAtEnd) , fTranscoder(0) , fType(type) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { setXMLVersion(version); @@ -322,16 +324,17 @@ XMLReader::XMLReader(const XMLCh* const pubId } -XMLReader::XMLReader(const XMLCh* const pubId - , const XMLCh* const sysId - , BinInputStream* const streamToAdopt - , XMLRecognizer::Encodings encodingEnum - , const RefFrom from - , const Types type - , const Sources source - , const bool throwAtEnd - , const bool calculateSrcOfs - , const XMLVersion version) : +XMLReader::XMLReader(const XMLCh* const pubId + , const XMLCh* const sysId + , BinInputStream* const streamToAdopt + , XMLRecognizer::Encodings encodingEnum + , const RefFrom from + , const Types type + , const Sources source + , const bool throwAtEnd + , const bool calculateSrcOfs + , const XMLVersion version + , MemoryManager* const manager) : fCharIndex(0) , fCharsAvail(0) , fCurCol(1) @@ -356,7 +359,7 @@ XMLReader::XMLReader(const XMLCh* const pubId , fThrowAtEnd(throwAtEnd) , fTranscoder(0) , fType(type) - , fMemoryManager(XMLPlatformUtils::fgMemoryManager) + , fMemoryManager(manager) { setXMLVersion(version); diff --git a/src/xercesc/internal/XMLReader.hpp b/src/xercesc/internal/XMLReader.hpp index c80074f66..cdd11d708 100644 --- a/src/xercesc/internal/XMLReader.hpp +++ b/src/xercesc/internal/XMLReader.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.14 2003/05/16 21:36:58 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.13 2003/05/15 18:26:29 knoaman * Partial implementation of the configurable memory manager. * @@ -258,43 +261,46 @@ public: // ----------------------------------------------------------------------- XMLReader ( - const XMLCh* const pubId - , const XMLCh* const sysId - , BinInputStream* const streamToAdopt - , const RefFrom from - , const Types type - , const Sources source - , const bool throwAtEnd = false - , const bool calculateSrcOfs = true - , const XMLVersion xmlVersion = XMLV1_0 + const XMLCh* const pubId + , const XMLCh* const sysId + , BinInputStream* const streamToAdopt + , const RefFrom from + , const Types type + , const Sources source + , const bool throwAtEnd = false + , const bool calculateSrcOfs = true + , const XMLVersion xmlVersion = XMLV1_0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); XMLReader ( - const XMLCh* const pubId - , const XMLCh* const sysId - , BinInputStream* const streamToAdopt - , const XMLCh* const encodingStr - , const RefFrom from - , const Types type - , const Sources source - , const bool throwAtEnd = false - , const bool calculateSrcOfs = true - , const XMLVersion xmlVersion = XMLV1_0 + const XMLCh* const pubId + , const XMLCh* const sysId + , BinInputStream* const streamToAdopt + , const XMLCh* const encodingStr + , const RefFrom from + , const Types type + , const Sources source + , const bool throwAtEnd = false + , const bool calculateSrcOfs = true + , const XMLVersion xmlVersion = XMLV1_0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); XMLReader ( - const XMLCh* const pubId - , const XMLCh* const sysId - , BinInputStream* const streamToAdopt - , XMLRecognizer::Encodings encodingEnum - , const RefFrom from - , const Types type - , const Sources source - , const bool throwAtEnd = false - , const bool calculateSrcOfs = true - , const XMLVersion xmlVersion = XMLV1_0 + const XMLCh* const pubId + , const XMLCh* const sysId + , BinInputStream* const streamToAdopt + , XMLRecognizer::Encodings encodingEnum + , const RefFrom from + , const Types type + , const Sources source + , const bool throwAtEnd = false + , const bool calculateSrcOfs = true + , const XMLVersion xmlVersion = XMLV1_0 + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); ~XMLReader(); diff --git a/src/xercesc/internal/XMLScanner.cpp b/src/xercesc/internal/XMLScanner.cpp index 429fb9999..f96c50345 100644 --- a/src/xercesc/internal/XMLScanner.cpp +++ b/src/xercesc/internal/XMLScanner.cpp @@ -330,7 +330,7 @@ void XMLScanner::scanDocument( const XMLCh* const systemId) XMLURL tmpURL(systemId, fMemoryManager); if (tmpURL.isRelative()) { if (!fStandardUriConformant) - srcToUse = new (fMemoryManager) LocalFileInputSource(systemId); + srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { // since this is the top of the try/catch, cannot call ThrowXML // emit the error directly @@ -358,14 +358,14 @@ void XMLScanner::scanDocument( const XMLCh* const systemId) ); return; } - srcToUse = new (fMemoryManager) URLInputSource(tmpURL); + srcToUse = new (fMemoryManager) URLInputSource(tmpURL, fMemoryManager); } } catch(const MalformedURLException& e) { if (!fStandardUriConformant) - srcToUse = new (fMemoryManager) LocalFileInputSource(systemId); + srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { // since this is the top of the try/catch, cannot call ThrowXML // emit the error directly @@ -447,7 +447,7 @@ bool XMLScanner::scanFirst( const XMLCh* const systemId XMLURL tmpURL(systemId, fMemoryManager); if (tmpURL.isRelative()) { if (!fStandardUriConformant) - srcToUse = new (fMemoryManager) LocalFileInputSource(systemId); + srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { // since this is the top of the try/catch, cannot call ThrowXML // emit the error directly @@ -475,13 +475,13 @@ bool XMLScanner::scanFirst( const XMLCh* const systemId ); return false; } - srcToUse = new (fMemoryManager) URLInputSource(tmpURL); + srcToUse = new (fMemoryManager) URLInputSource(tmpURL, fMemoryManager); } } catch(const MalformedURLException& e) { if (!fStandardUriConformant) - srcToUse = new (fMemoryManager) LocalFileInputSource(systemId); + srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { // since this is the top of the try/catch, cannot call ThrowXML // emit the error directly @@ -1575,7 +1575,7 @@ Grammar* XMLScanner::loadGrammar(const XMLCh* const systemId if (tmpURL.isRelative()) { if (!fStandardUriConformant) - srcToUse = new (fMemoryManager) LocalFileInputSource(systemId); + srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { // since this is the top of the try/catch, cannot call ThrowXML // emit the error directly @@ -1603,13 +1603,13 @@ Grammar* XMLScanner::loadGrammar(const XMLCh* const systemId ); return 0; } - srcToUse = new (fMemoryManager) URLInputSource(tmpURL); + srcToUse = new (fMemoryManager) URLInputSource(tmpURL, fMemoryManager); } } catch(const MalformedURLException& e) { if (!fStandardUriConformant) - srcToUse = new (fMemoryManager) LocalFileInputSource(systemId); + srcToUse = new (fMemoryManager) LocalFileInputSource(systemId, fMemoryManager); else { // since this is the top of the try/catch, cannot call ThrowXML // emit the error directly diff --git a/src/xercesc/internal/XMLScanner.hpp b/src/xercesc/internal/XMLScanner.hpp index 76daf3df3..7d784a9ff 100644 --- a/src/xercesc/internal/XMLScanner.hpp +++ b/src/xercesc/internal/XMLScanner.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.22 2003/05/16 21:36:58 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.21 2003/05/15 18:26:29 knoaman * Partial implementation of the configurable memory manager. * @@ -365,7 +368,7 @@ public : XMLScanner ( XMLValidator* const valToAdopt - , MemoryManager* const manager// = XMLPlatformUtils::fgMemoryManager + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); XMLScanner ( @@ -374,7 +377,7 @@ public : , XMLEntityHandler* const entityHandler , XMLErrorReporter* const errReporter , XMLValidator* const valToAdopt - , MemoryManager* const manager// = XMLPlatformUtils::fgMemoryManager + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); virtual ~XMLScanner(); diff --git a/src/xercesc/internal/XMLScannerResolver.hpp b/src/xercesc/internal/XMLScannerResolver.hpp index 36843d774..ede432748 100644 --- a/src/xercesc/internal/XMLScannerResolver.hpp +++ b/src/xercesc/internal/XMLScannerResolver.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.3 2003/05/16 21:36:58 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.2 2003/05/15 18:26:29 knoaman * Partial implementation of the configurable memory manager. * @@ -87,7 +90,7 @@ public: ( const XMLCh* const scannerName , XMLValidator* const valToAdopt - , MemoryManager* const manager + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); static XMLScanner* resolveScanner @@ -98,13 +101,13 @@ public: , XMLEntityHandler* const entityHandler , XMLErrorReporter* const errReporter , XMLValidator* const valToAdopt - , MemoryManager* const manager + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); static XMLScanner* getDefaultScanner ( XMLValidator* const valToAdopt - , MemoryManager* const manager + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); private : diff --git a/src/xercesc/parsers/AbstractDOMParser.hpp b/src/xercesc/parsers/AbstractDOMParser.hpp index 8c58413bb..c45bbe76a 100644 --- a/src/xercesc/parsers/AbstractDOMParser.hpp +++ b/src/xercesc/parsers/AbstractDOMParser.hpp @@ -1347,6 +1347,8 @@ protected : */ bool getParseInProgress() const; + MemoryManager* getMemoryManager() const; + //@} @@ -1560,6 +1562,10 @@ inline DOMNode* AbstractDOMParser::getCurrentNode() return fCurrentNode; } +inline MemoryManager* AbstractDOMParser::getMemoryManager() const +{ + return fMemoryManager; +} // --------------------------------------------------------------------------- // AbstractDOMParser: Protected setter methods diff --git a/src/xercesc/parsers/DOMBuilderImpl.cpp b/src/xercesc/parsers/DOMBuilderImpl.cpp index 3fc262fdf..38d51875c 100644 --- a/src/xercesc/parsers/DOMBuilderImpl.cpp +++ b/src/xercesc/parsers/DOMBuilderImpl.cpp @@ -433,7 +433,7 @@ void DOMBuilderImpl::resetDocumentPool() // --------------------------------------------------------------------------- DOMDocument* DOMBuilderImpl::parse(const DOMInputSource& source) { - Wrapper4DOMInputSource isWrapper((DOMInputSource*) &source, false); + Wrapper4DOMInputSource isWrapper((DOMInputSource*) &source, false, getMemoryManager()); AbstractDOMParser::parse(isWrapper); if (fUserAdoptsDocument) @@ -520,7 +520,7 @@ DOMBuilderImpl::resolveEntity(const XMLCh* const publicId, DOMInputSource* is = fEntityResolver->resolveEntity(publicId, systemId, baseURI); if (is) - return new Wrapper4DOMInputSource(is); + return new Wrapper4DOMInputSource(is, true, getMemoryManager()); } return 0; @@ -602,7 +602,7 @@ Grammar* DOMBuilderImpl::loadGrammar(const DOMInputSource& source, Grammar* grammar = 0; try { - Wrapper4DOMInputSource isWrapper((DOMInputSource*) &source, false); + Wrapper4DOMInputSource isWrapper((DOMInputSource*) &source, false, getMemoryManager()); setParseInProgress(true); grammar = getScanner()->loadGrammar(isWrapper, grammarType, toCache); diff --git a/src/xercesc/parsers/SAX2XMLReaderImpl.cpp b/src/xercesc/parsers/SAX2XMLReaderImpl.cpp index 63bd471ca..d926d3f1d 100644 --- a/src/xercesc/parsers/SAX2XMLReaderImpl.cpp +++ b/src/xercesc/parsers/SAX2XMLReaderImpl.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.20 2003/05/16 21:36:59 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.19 2003/05/16 06:01:52 knoaman * Partial implementation of the configurable memory manager. * @@ -1089,7 +1092,7 @@ void SAX2XMLReaderImpl::attDef( const DTDElementDecl& elemDecl XMLAttDef::DefAttTypes defAttType = attDef.getDefaultType(); const XMLCh* defAttTypeStr = XMLUni::fgNullString; bool isEnumeration = (attType == XMLAttDef::Notation || attType == XMLAttDef::Enumeration); - XMLBuffer enumBuf(128); + XMLBuffer enumBuf(128, fMemoryManager); if (defAttType == XMLAttDef::Fixed || defAttType == XMLAttDef::Implied || diff --git a/src/xercesc/parsers/SAXParser.cpp b/src/xercesc/parsers/SAXParser.cpp index 630cb9ded..9a5ad9bc0 100644 --- a/src/xercesc/parsers/SAXParser.cpp +++ b/src/xercesc/parsers/SAXParser.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.18 2003/05/16 21:36:59 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.17 2003/05/15 18:26:50 knoaman * Partial implementation of the configurable memory manager. * @@ -262,6 +265,7 @@ SAXParser::SAXParser( XMLValidator* const valToAdopt , fURIStringPool(0) , fValidator(valToAdopt) , fMemoryManager(manager) + , fElemQNameBuf(1023, manager) { try { diff --git a/src/xercesc/sax/InputSource.cpp b/src/xercesc/sax/InputSource.cpp index 6af406f4e..91079a3d0 100644 --- a/src/xercesc/sax/InputSource.cpp +++ b/src/xercesc/sax/InputSource.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2003/05/16 21:36:59 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.4 2003/05/15 18:27:05 knoaman * Partial implementation of the configurable memory manager. * @@ -139,9 +142,9 @@ void InputSource::setSystemId(const XMLCh* const systemId) // --------------------------------------------------------------------------- // InputSource: Hidden Constructors // --------------------------------------------------------------------------- -InputSource::InputSource() : +InputSource::InputSource(MemoryManager* const manager) : - fMemoryManager(XMLPlatformUtils::fgMemoryManager) + fMemoryManager(manager) , fEncoding(0) , fPublicId(0) , fSystemId(0) @@ -149,9 +152,10 @@ InputSource::InputSource() : { } -InputSource::InputSource(const XMLCh* const systemId) : +InputSource::InputSource(const XMLCh* const systemId, + MemoryManager* const manager) : - fMemoryManager(XMLPlatformUtils::fgMemoryManager) + fMemoryManager(manager) , fEncoding(0) , fPublicId(0) , fSystemId(0) @@ -160,10 +164,11 @@ InputSource::InputSource(const XMLCh* const systemId) : fSystemId = XMLString::replicate(systemId, fMemoryManager); } -InputSource::InputSource(const XMLCh* const systemId - , const XMLCh* const publicId) : +InputSource::InputSource(const XMLCh* const systemId + , const XMLCh* const publicId + , MemoryManager* const manager) : - fMemoryManager(XMLPlatformUtils::fgMemoryManager) + fMemoryManager(manager) , fEncoding(0) , fPublicId(0) , fSystemId(0) @@ -173,9 +178,10 @@ InputSource::InputSource(const XMLCh* const systemId fSystemId = XMLString::replicate(systemId, fMemoryManager); } -InputSource::InputSource(const char* const systemId) : +InputSource::InputSource(const char* const systemId, + MemoryManager* const manager) : - fMemoryManager(XMLPlatformUtils::fgMemoryManager) + fMemoryManager(manager) , fEncoding(0) , fPublicId(0) , fSystemId(0) @@ -185,9 +191,10 @@ InputSource::InputSource(const char* const systemId) : } InputSource::InputSource(const char* const systemId - , const char* const publicId) : + , const char* const publicId + , MemoryManager* const manager) : - fMemoryManager(XMLPlatformUtils::fgMemoryManager) + fMemoryManager(manager) , fEncoding(0) , fPublicId(0) , fSystemId(0) diff --git a/src/xercesc/sax/InputSource.hpp b/src/xercesc/sax/InputSource.hpp index abef0441b..833d4110b 100644 --- a/src/xercesc/sax/InputSource.hpp +++ b/src/xercesc/sax/InputSource.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/05/16 21:36:59 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.6 2003/05/15 18:27:05 knoaman * Partial implementation of the configurable memory manager. * @@ -306,12 +309,13 @@ protected : /** @name Constructors and Destructor */ //@{ /** Default constructor */ - InputSource(); + InputSource(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** Constructor with a system identifier as XMLCh type. * @param systemId The system identifier (URI). */ - InputSource(const XMLCh* const systemId); + InputSource(const XMLCh* const systemId, + MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** Constructor with a system and public identifiers * @param systemId The system identifier (URI). @@ -319,14 +323,16 @@ protected : */ InputSource ( - const XMLCh* const systemId - , const XMLCh* const publicId + const XMLCh* const systemId + , const XMLCh* const publicId + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); /** Constructor witha system identifier as string * @param systemId The system identifier (URI). */ - InputSource(const char* const systemId); + InputSource(const char* const systemId, + MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); /** Constructor witha system and public identifiers. Both as string * @param systemId The system identifier (URI). @@ -336,6 +342,7 @@ protected : ( const char* const systemId , const char* const publicId + , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager ); //@} diff --git a/src/xercesc/util/BaseRefVectorOf.c b/src/xercesc/util/BaseRefVectorOf.c index 03d5e05ea..b07b03ca9 100644 --- a/src/xercesc/util/BaseRefVectorOf.c +++ b/src/xercesc/util/BaseRefVectorOf.c @@ -259,6 +259,12 @@ template <class TElem> void BaseRefVectorOf<TElem>::reinitialize() } +template <class TElem> +MemoryManager* BaseRefVectorOf<TElem>::getMemoryManager() const +{ + return fMemoryManager; +} + // --------------------------------------------------------------------------- // BaseRefVectorOf: Getter methods diff --git a/src/xercesc/util/BaseRefVectorOf.hpp b/src/xercesc/util/BaseRefVectorOf.hpp index 352184bf7..f7360d07b 100644 --- a/src/xercesc/util/BaseRefVectorOf.hpp +++ b/src/xercesc/util/BaseRefVectorOf.hpp @@ -107,6 +107,7 @@ public : const TElem* elementAt(const unsigned int getAt) const; TElem* elementAt(const unsigned int getAt); unsigned int size() const; + MemoryManager* getMemoryManager() const; // ----------------------------------------------------------------------- diff --git a/src/xercesc/util/QName.hpp b/src/xercesc/util/QName.hpp index e259d37f6..9ed324545 100644 --- a/src/xercesc/util/QName.hpp +++ b/src/xercesc/util/QName.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/05/16 21:36:59 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.7 2003/05/16 06:01:52 knoaman * Partial implementation of the configurable memory manager. * @@ -161,6 +164,8 @@ public : const XMLCh* getRawName() const; XMLCh* getRawName(); + MemoryManager* getMemoryManager() const; + // ----------------------------------------------------------------------- // Setters // ----------------------------------------------------------------------- @@ -263,6 +268,11 @@ inline unsigned int QName::getURI() const return fURIId; } +inline MemoryManager* QName::getMemoryManager() const +{ + return fMemoryManager; +} + // --------------------------------------------------------------------------- // QName: Setter methods // --------------------------------------------------------------------------- diff --git a/src/xercesc/util/RefHashTableOf.c b/src/xercesc/util/RefHashTableOf.c index 5c541521d..f288725bc 100644 --- a/src/xercesc/util/RefHashTableOf.c +++ b/src/xercesc/util/RefHashTableOf.c @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.9 2003/05/16 21:36:59 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.8 2003/05/15 19:04:35 knoaman * Partial implementation of the configurable memory manager. * @@ -399,6 +402,12 @@ get(const void* const key) const return findIt->fData; } +template <class TVal> +MemoryManager* RefHashTableOf<TVal>::getMemoryManager() const +{ + return fMemoryManager; +} + // --------------------------------------------------------------------------- // RefHashTableOf: Getters diff --git a/src/xercesc/util/RefHashTableOf.hpp b/src/xercesc/util/RefHashTableOf.hpp index 531dfab20..63e102c1e 100644 --- a/src/xercesc/util/RefHashTableOf.hpp +++ b/src/xercesc/util/RefHashTableOf.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.9 2003/05/16 21:36:59 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.8 2003/05/15 19:04:35 knoaman * Partial implementation of the configurable memory manager. * @@ -196,6 +199,7 @@ public: // ----------------------------------------------------------------------- TVal* get(const void* const key); const TVal* get(const void* const key) const; + MemoryManager* getMemoryManager() const; // ----------------------------------------------------------------------- // Setters diff --git a/src/xercesc/util/Transcoders/ICU/ICUTransService.cpp b/src/xercesc/util/Transcoders/ICU/ICUTransService.cpp index 28d582a2c..39c342361 100644 --- a/src/xercesc/util/Transcoders/ICU/ICUTransService.cpp +++ b/src/xercesc/util/Transcoders/ICU/ICUTransService.cpp @@ -106,13 +106,16 @@ static const XMLCh gMyServiceId[] = // When XMLCh and ICU's UChar are not the same size, we have to do a temp // conversion of all strings. These local helper methods make that easier. // -static UChar* convertToUChar( const XMLCh* const toConvert - , const unsigned int srcLen = 0) +static UChar* convertToUChar( const XMLCh* const toConvert + , const unsigned int srcLen = 0 + , MemoryManager* const manager = 0) { const unsigned int actualLen = srcLen ? srcLen : XMLString::stringLen(toConvert); - UChar* tmpBuf = new UChar[actualLen + 1]; + UChar* tmpBuf = (manager) + ? (UChar*) manager->allocate((actualLen + 1) * sizeof(UChar)) + : new UChar[actualLen + 1]; const XMLCh* srcPtr = toConvert; UChar* outPtr = tmpBuf; while (*srcPtr) @@ -928,6 +931,109 @@ char* ICULCPTranscoder::transcode(const XMLCh* const toTranscode) return retBuf; } +char* ICULCPTranscoder::transcode(const XMLCh* const toTranscode, + MemoryManager* const manager) +{ + char* retBuf = 0; + + // Check for a couple of special cases + if (!toTranscode) + return retBuf; + + if (!*toTranscode) + { + retBuf = new char[1]; + retBuf[0] = 0; + return retBuf; + } + + // + // Get the length of the source string since we'll have to use it in + // a couple places below. + // + const unsigned int srcLen = XMLString::stringLen(toTranscode); + + // + // If XMLCh and UChar are not the same size, then we have to make a + // temp copy of the text to pass to ICU. + // + const UChar* actualSrc; + UChar* ncActual = 0; + if (sizeof(XMLCh) == sizeof(UChar)) + { + actualSrc = (const UChar*)toTranscode; + } + else + { + // Allocate a non-const temp buf, but store it also in the actual + ncActual = convertToUChar(toTranscode); + actualSrc = ncActual; + } + + // Insure that the temp buffer, if any, gets cleaned up via the nc pointer + ArrayJanitor<UChar> janTmp(ncActual); + + // Caculate a return buffer size not too big, but less likely to overflow + int32_t targetLen = (int32_t)(srcLen * 1.25); + + // Allocate the return buffer + retBuf = new char[targetLen + 1]; + + // + // Lock now while we call the converter. Use a faux block to do the + // lock so that it unlocks immediately afterwards. + // + UErrorCode err = U_ZERO_ERROR; + int32_t targetCap; + { + XMLMutexLock lockConverter(&fMutex); + + targetCap = ucnv_fromUChars + ( + fConverter + , retBuf + , targetLen + 1 + , actualSrc + , -1 + , &err + ); + } + + // If targetLen is not enough then buffer overflow might occur + if (err == U_BUFFER_OVERFLOW_ERROR) + { + // + // Reset the error, delete the old buffer, allocate a new one, + // and try again. + // + err = U_ZERO_ERROR; + delete [] retBuf; + retBuf = new char[targetCap + 1]; + + // Lock again before we retry + XMLMutexLock lockConverter(&fMutex); + targetCap = ucnv_fromUChars + ( + fConverter + , retBuf + , targetCap + , actualSrc + , -1 + , &err + ); + } + + if (U_FAILURE(err)) + { + delete [] retBuf; + return 0; + } + + // Cap it off and return + retBuf[targetCap] = 0; + return retBuf; +} + XMLCh* ICULCPTranscoder::transcode(const char* const toTranscode) { // Watch for a few pyscho corner cases @@ -1016,6 +1122,95 @@ XMLCh* ICULCPTranscoder::transcode(const char* const toTranscode) return actualRet; } +XMLCh* ICULCPTranscoder::transcode(const char* const toTranscode, + MemoryManager* const manager) +{ + // Watch for a few pyscho corner cases + if (!toTranscode) + return 0; + + if (!*toTranscode) + { + XMLCh* retVal = new XMLCh[1]; + retVal[0] = 0; + return retVal; + } + + // + // Get the length of the string to transcode. The Unicode string will + // almost always be no more chars than were in the source, so this is + // the best guess as to the storage needed. + // + const int32_t srcLen = (int32_t)strlen(toTranscode); + + // We need a target buffer of UChars to fill in + UChar* targetBuf = 0; + + // Now lock while we do these calculations + UErrorCode err = U_ZERO_ERROR; + int32_t targetCap; + { + XMLMutexLock lockConverter(&fMutex); + + // + // Here we don't know what the target length will be so use 0 and + // expect an U_BUFFER_OVERFLOW_ERROR in which case it'd get resolved + // by the correct capacity value. + // + targetCap = ucnv_toUChars + ( + fConverter + , 0 + , 0 + , toTranscode + , srcLen + , &err + ); + + if (err != U_BUFFER_OVERFLOW_ERROR) + return 0; + + err = U_ZERO_ERROR; + targetBuf = new UChar[targetCap + 1]; + ucnv_toUChars + ( + fConverter + , targetBuf + , targetCap + , toTranscode + , srcLen + , &err + ); + } + + if (U_FAILURE(err)) + { + // Clean up if we got anything allocated + delete [] targetBuf; + return 0; + } + + // Cap it off to make sure + targetBuf[targetCap] = 0; + + // + // If XMLCh and UChar are the same size, then we can return retVal + // as is. Else, we have to allocate another buffer and copy the data + // over to it. + // + XMLCh* actualRet; + if (sizeof(XMLCh) == sizeof(UChar)) + { + actualRet = (XMLCh*)targetBuf; + } + else + { + actualRet = convertToXMLCh(targetBuf); + delete [] targetBuf; + } + return actualRet; +} + bool ICULCPTranscoder::transcode(const char* const toTranscode , XMLCh* const toFill diff --git a/src/xercesc/util/Transcoders/IconvFBSD/IconvFBSDTransService.cpp b/src/xercesc/util/Transcoders/IconvFBSD/IconvFBSDTransService.cpp index 17f084fc0..1ab965b0c 100644 --- a/src/xercesc/util/Transcoders/IconvFBSD/IconvFBSDTransService.cpp +++ b/src/xercesc/util/Transcoders/IconvFBSD/IconvFBSDTransService.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.13 2003/05/16 21:37:00 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.12 2003/05/15 18:47:04 knoaman * Partial implementation of the configurable memory manager. * @@ -1139,6 +1142,98 @@ char* IconvFBSDLCPTranscoder::transcode(const XMLCh* const toTranscode) return retVal; } +char* IconvFBSDLCPTranscoder::transcode(const XMLCh* const toTranscode, + MemoryManager* const manager) +{ + if (!toTranscode) + return 0; + + char* retVal = 0; + if (*toTranscode) { + unsigned int wLent = getWideCharLength(toTranscode); + +#ifndef XML_USE_LIBICONV + + wchar_t tmpWideCharArr[gTempBuffArraySize]; + wchar_t* allocatedArray = 0; + wchar_t* wideCharBuf = 0; + + if (wLent >= gTempBuffArraySize) + wideCharBuf = allocatedArray = new wchar_t[wLent + 1]; + else + wideCharBuf = tmpWideCharArr; + + for (unsigned int i = 0; i < wLent; i++) + wideCharBuf[i] = toTranscode[i]; + wideCharBuf[wLent] = 0x00; + + // Calc the needed size. + const size_t neededLen = fbsd_wcstombs(NULL, wideCharBuf, 0); + if (neededLen == -1) { + if (allocatedArray) + delete [] allocatedArray; + return 0; + } + + retVal = new char[neededLen + 1]; + fbsd_wcstombs(retVal, wideCharBuf, neededLen); + if (allocatedArray) + delete [] allocatedArray; + retVal[neededLen] = 0; + +#else /* XML_USE_LIBICONV */ + + // Calc needed size. + const size_t neededLen = calcRequiredSize (toTranscode); + if (neededLen == 0) + return 0; + // allocate output buffer + retVal = new char[neededLen + 1]; + if (retVal == NULL) + return 0; + // prepare the original + char tmpWBuff[gTempBuffArraySize]; + char *wideCharBuf = 0; + char *wBufPtr = 0; + size_t len = wLent * uChSize(); + + if (uChSize() != sizeof(XMLCh) || UBO() != BYTE_ORDER) { + if (len > gTempBuffArraySize) { + wBufPtr = new char[len]; + if (wBufPtr == NULL) + return 0; + wideCharBuf = wBufPtr; + } else + wideCharBuf = tmpWBuff; + xmlToMbs (toTranscode, wLent, wideCharBuf, wLent); + } else + wideCharBuf = (char *) toTranscode; + + // perform conversion + wLent *= uChSize(); + char *ptr = retVal; + size_t tmpwLent = wLent; + size_t rc = iconvTo(wideCharBuf, &tmpwLent, &ptr, neededLen); + if (rc == (size_t)-1) { + if (wBufPtr) + delete [] wBufPtr; + return 0; + } + if (wBufPtr) + delete [] wBufPtr; + retVal[neededLen] = 0; + +#endif /* !XML_USE_LIBICONV */ + + } else { + retVal = new char[1]; + if (retVal == NULL) + return 0; + retVal[0] = 0; + } + return retVal; +} + bool IconvFBSDLCPTranscoder::transcode( const XMLCh* const toTranscode , char* const toFill @@ -1312,6 +1407,92 @@ XMLCh* IconvFBSDLCPTranscoder::transcode(const char* const toTranscode) return retVal; } +XMLCh* IconvFBSDLCPTranscoder::transcode(const char* const toTranscode, + MemoryManager* const manager) +{ + if (!toTranscode) + return 0; + + XMLCh* retVal = 0; + if (*toTranscode) { + const unsigned int wLent = calcRequiredSize(toTranscode); + if (wLent == 0) { + retVal = new XMLCh[1]; + retVal[0] = 0; + return retVal; + } + +#ifndef XML_USE_LIBICONV + + wchar_t tmpWideCharArr[gTempBuffArraySize]; + wchar_t* allocatedArray = 0; + wchar_t* wideCharBuf = 0; + + if (wLent >= gTempBuffArraySize) + wideCharBuf = allocatedArray = new wchar_t[wLent + 1]; + else + wideCharBuf = tmpWideCharArr; + + fbsd_mbstowcs(wideCharBuf, toTranscode, wLent); + retVal = new XMLCh[wLent + 1]; + if (retVal == NULL) { + if (allocatedArray) + delete [] allocatedArray; + return NULL; + } + for (unsigned int i = 0; i < wLent; i++) + retVal[i] = (XMLCh) wideCharBuf[i]; + retVal[wLent] = 0x00; + if (allocatedArray) + delete [] allocatedArray; + +#else /* XML_USE_LIBICONV */ + + char tmpWBuff[gTempBuffArraySize]; + char *wideCharBuf = 0; + char *wBufPtr = 0; + size_t len = wLent * uChSize(); + + retVal = new XMLCh[wLent + 1]; + if (retVal == NULL) + return NULL; + if (uChSize() != sizeof(XMLCh) || UBO() != BYTE_ORDER) { + if (len > gTempBuffArraySize) { + wBufPtr = new char[len]; + if (wBufPtr == NULL) + return 0; + wideCharBuf = wBufPtr; + } else + wideCharBuf = tmpWBuff; + } else + wideCharBuf = (char *) retVal; + + size_t flen = strlen(toTranscode); + char *ptr = wideCharBuf; + size_t rc = iconvFrom(toTranscode, &flen, &ptr, len); + if (rc == (size_t) -1) { + if (wBufPtr) + delete [] wBufPtr; + return NULL; + } + if (uChSize() != sizeof(XMLCh) || UBO() != BYTE_ORDER) + mbsToXML (wideCharBuf, wLent, retVal, wLent); + if (wBufPtr) + delete [] wBufPtr; + retVal[wLent] = 0x00; + +#endif /* !XML_USE_LIBICONV */ + + } + else { + retVal = new XMLCh[1]; + if (retVal == NULL ) + return 0; + retVal[0] = 0; + } + return retVal; +} + bool IconvFBSDLCPTranscoder::transcode(const char* const toTranscode , XMLCh* const toFill diff --git a/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp b/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp index 78e541ae5..d7f3925a8 100644 --- a/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp +++ b/src/xercesc/util/Transcoders/IconvGNU/IconvGNUTransService.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/05/16 21:37:00 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.7 2003/05/15 18:47:05 knoaman * Partial implementation of the configurable memory manager. * @@ -860,6 +863,64 @@ char* IconvGNULCPTranscoder::transcode(const XMLCh* const toTranscode) return retVal; } +char* IconvGNULCPTranscoder::transcode(const XMLCh* const toTranscode, + MemoryManager* const manager) +{ + if (!toTranscode) + return 0; + + char* retVal = 0; + if (*toTranscode) { + unsigned int wLent = getWideCharLength(toTranscode); + + // Calc needed size. + const size_t neededLen = calcRequiredSize (toTranscode); + if (neededLen == 0) + return 0; + // allocate output buffer + retVal = new char[neededLen + 1]; + if (retVal == NULL) + return 0; + // prepare the original + char tmpWBuff[gTempBuffArraySize]; + char *wideCharBuf = 0; + char *wBufPtr = 0; + size_t len = wLent * uChSize(); + + if (uChSize() != sizeof(XMLCh) || UBO() != BYTE_ORDER) { + if (len > gTempBuffArraySize) { + wBufPtr = new char[len]; + if (wBufPtr == NULL) + return 0; + wideCharBuf = wBufPtr; + } else + wideCharBuf = tmpWBuff; + xmlToMbs (toTranscode, wLent, wideCharBuf, wLent); + } else + wideCharBuf = (char *) toTranscode; + + // perform conversion + wLent *= uChSize(); + char *ptr = retVal; + size_t rc = iconvTo(wideCharBuf, (size_t *) &wLent, &ptr, neededLen); + if (rc == (size_t)-1) { + if (wBufPtr) + delete [] wBufPtr; + return 0; + } + if (wBufPtr) + delete [] wBufPtr; + retVal[neededLen] = 0; + + } else { + retVal = new char[1]; + if (retVal == NULL) + return 0; + retVal[0] = 0; + } + return retVal; +} + bool IconvGNULCPTranscoder::transcode( const XMLCh* const toTranscode , char* const toFill @@ -971,6 +1032,63 @@ XMLCh* IconvGNULCPTranscoder::transcode(const char* const toTranscode) return retVal; } +XMLCh* IconvGNULCPTranscoder::transcode(const char* const toTranscode, + MemoryManager* const manager) +{ + if (!toTranscode) + return 0; + + XMLCh* retVal = 0; + if (*toTranscode) { + const unsigned int wLent = calcRequiredSize(toTranscode); + if (wLent == 0) { + retVal = new XMLCh[1]; + retVal[0] = 0; + return retVal; + } + + char tmpWBuff[gTempBuffArraySize]; + char *wideCharBuf = 0; + char *wBufPtr = 0; + size_t len = wLent * uChSize(); + + retVal = new XMLCh[wLent + 1]; + if (retVal == NULL) + return NULL; + if (uChSize() != sizeof(XMLCh) || UBO() != BYTE_ORDER) { + if (len > gTempBuffArraySize) { + wBufPtr = new char[len]; + if (wBufPtr == NULL) + return 0; + wideCharBuf = wBufPtr; + } else + wideCharBuf = tmpWBuff; + } else + wideCharBuf = (char *) retVal; + + size_t flen = strlen(toTranscode); + char *ptr = wideCharBuf; + size_t rc = iconvFrom(toTranscode, &flen, &ptr, len); + if (rc == (size_t) -1) { + if (wBufPtr) + delete [] wBufPtr; + return NULL; + } + if (uChSize() != sizeof(XMLCh) || UBO() != BYTE_ORDER) + mbsToXML (wideCharBuf, wLent, retVal, wLent); + if (wBufPtr) + delete [] wBufPtr; + retVal[wLent] = 0x00; + } + else { + retVal = new XMLCh[1]; + if (retVal == NULL ) + return 0; + retVal[0] = 0; + } + return retVal; +} + bool IconvGNULCPTranscoder::transcode(const char* const toTranscode , XMLCh* const toFill diff --git a/src/xercesc/util/ValueVectorOf.c b/src/xercesc/util/ValueVectorOf.c index e2826267c..3465e9f4e 100644 --- a/src/xercesc/util/ValueVectorOf.c +++ b/src/xercesc/util/ValueVectorOf.c @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.5 2003/05/16 21:37:00 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.4 2003/05/16 06:01:52 knoaman * Partial implementation of the configurable memory manager. * @@ -276,7 +279,11 @@ template <class TElem> unsigned int ValueVectorOf<TElem>::size() const return fCurCount; } - +template <class TElem> +MemoryManager* ValueVectorOf<TElem>::getMemoryManager() const +{ + return fMemoryManager; +} // --------------------------------------------------------------------------- // ValueVectorOf: Miscellaneous diff --git a/src/xercesc/util/ValueVectorOf.hpp b/src/xercesc/util/ValueVectorOf.hpp index bd57e81ed..93f9b09d3 100644 --- a/src/xercesc/util/ValueVectorOf.hpp +++ b/src/xercesc/util/ValueVectorOf.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.6 2003/05/16 21:37:00 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.5 2003/05/16 06:01:52 knoaman * Partial implementation of the configurable memory manager. * @@ -146,6 +149,7 @@ public : TElem& elementAt(const unsigned int getAt); unsigned int curCapacity() const; unsigned int size() const; + MemoryManager* getMemoryManager() const; // ----------------------------------------------------------------------- diff --git a/src/xercesc/util/regx/RangeToken.cpp b/src/xercesc/util/regx/RangeToken.cpp index 2c603cbfd..0446b5132 100644 --- a/src/xercesc/util/regx/RangeToken.cpp +++ b/src/xercesc/util/regx/RangeToken.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.8 2003/05/16 21:37:00 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.7 2003/05/15 21:46:47 knoaman * Add missing include. * @@ -121,7 +124,9 @@ const unsigned int RangeToken::INITIALSIZE = 16; // --------------------------------------------------------------------------- // RangeToken: Constructors and Destructors // --------------------------------------------------------------------------- -RangeToken::RangeToken(const unsigned short tokType) : Token(tokType) +RangeToken::RangeToken(const unsigned short tokType, + MemoryManager* const manager) + : Token(tokType) , fSorted(false) , fCompacted(false) , fNonMapIndex(0) @@ -130,14 +135,15 @@ RangeToken::RangeToken(const unsigned short tokType) : Token(tokType) , fMap(0) , fRanges(0) , fCaseIToken(0) + , fMemoryManager(manager) { } RangeToken::~RangeToken() { - delete [] fMap; - delete[] fRanges; + fMemoryManager->deallocate(fMap);//delete [] fMap; + fMemoryManager->deallocate(fRanges);//delete[] fRanges; } @@ -169,12 +175,12 @@ void RangeToken::setRangeValues(XMLInt32* const rangeValues, const unsigned int if (fRanges) { if (fMap) { - delete [] fMap; + fMemoryManager->deallocate(fMap);//delete [] fMap; fMap = 0; } fElemCount = 0; - delete [] fRanges; + fMemoryManager->deallocate(fRanges);//delete [] fRanges; fRanges = 0; } @@ -204,7 +210,10 @@ void RangeToken::addRange(const XMLInt32 start, const XMLInt32 end) { if (fRanges == 0) { - fRanges = new XMLInt32[fMaxCount]; + fRanges = (XMLInt32*) fMemoryManager->allocate + ( + fMaxCount * sizeof(XMLInt32) + );//new XMLInt32[fMaxCount]; fRanges[0] = val1; fRanges[1] = val2; fElemCount = 2; @@ -327,7 +336,10 @@ void RangeToken::mergeRanges(const Token *const tok) { if (fRanges == 0) { fMaxCount = rangeTok->fMaxCount; - fRanges = new XMLInt32[fMaxCount]; + fRanges = (XMLInt32*) fMemoryManager->allocate + ( + fMaxCount * sizeof(XMLInt32) + );//new XMLInt32[fMaxCount]; for (unsigned int index = 0; index < rangeTok->fElemCount; index++) { fRanges[index] = rangeTok->fRanges[index]; } @@ -338,7 +350,10 @@ void RangeToken::mergeRanges(const Token *const tok) { unsigned int newMaxCount = (fElemCount + rangeTok->fElemCount >= fMaxCount) ? fMaxCount + rangeTok->fMaxCount : fMaxCount; - XMLInt32* result = new XMLInt32[newMaxCount]; + XMLInt32* result = (XMLInt32*) fMemoryManager->allocate + ( + newMaxCount * sizeof(XMLInt32) + );//new XMLInt32[newMaxCount]; for (unsigned int i=0, j=0, k=0; i < fElemCount || j < rangeTok->fElemCount;) { @@ -371,7 +386,7 @@ void RangeToken::mergeRanges(const Token *const tok) { } } - delete [] fRanges; + fMemoryManager->deallocate(fRanges);//delete [] fRanges; fElemCount += rangeTok->fElemCount; fRanges = result; fMaxCount = newMaxCount; @@ -396,7 +411,10 @@ void RangeToken::subtractRanges(RangeToken* const tok) { unsigned int newMax = (fElemCount + tok->fElemCount >= fMaxCount) ? fMaxCount + tok->fMaxCount : fMaxCount; - XMLInt32* result = new XMLInt32[newMax]; + XMLInt32* result = (XMLInt32*) fMemoryManager->allocate + ( + newMax * sizeof(XMLInt32) + );//new XMLInt32[newMax]; unsigned int newElemCount = 0; unsigned int srcCount = 0; unsigned int subCount = 0; @@ -441,7 +459,7 @@ void RangeToken::subtractRanges(RangeToken* const tok) { subCount += 2; } else { - delete [] result; + fMemoryManager->deallocate(result);//delete [] result; ThrowXML(RuntimeException, XMLExcepts::Regex_SubtractRangesError); } } //end while @@ -452,7 +470,7 @@ void RangeToken::subtractRanges(RangeToken* const tok) { result[newElemCount++] = fRanges[srcCount++]; } - delete [] fRanges; + fMemoryManager->deallocate(fRanges);//delete [] fRanges; fRanges = result; fElemCount = newElemCount; fMaxCount = newMax; @@ -474,7 +492,10 @@ void RangeToken::intersectRanges(RangeToken* const tok) { unsigned int newMax = (fElemCount + tok->fElemCount >= fMaxCount) ? fMaxCount + tok->fMaxCount : fMaxCount; - XMLInt32* result = new XMLInt32[newMax]; + XMLInt32* result = (XMLInt32*) fMemoryManager->allocate + ( + newMax * sizeof(XMLInt32) + );//new XMLInt32[newMax]; unsigned int newElemCount = 0; unsigned int srcCount = 0; unsigned int tokCount = 0; @@ -534,12 +555,12 @@ void RangeToken::intersectRanges(RangeToken* const tok) { } else { - delete [] result; + fMemoryManager->deallocate(result);//delete [] result; ThrowXML(RuntimeException, XMLExcepts::Regex_IntersectRangesError); } } //end while - delete [] fRanges; + fMemoryManager->deallocate(fRanges);//delete [] fRanges; fRanges = result; fElemCount = newElemCount; fMaxCount = newMax; @@ -631,11 +652,14 @@ void RangeToken::expand(const unsigned int length) { if (newMax < minNewMax) newMax = minNewMax; - XMLInt32* newList = new XMLInt32[newMax]; + XMLInt32* newList = (XMLInt32*) fMemoryManager->allocate + ( + newMax * sizeof(XMLInt32) + );//new XMLInt32[newMax]; for (unsigned int index = 0; index < fElemCount; index++) newList[index] = fRanges[index]; - delete [] fRanges; + fMemoryManager->deallocate(fRanges);//delete [] fRanges; fRanges = newList; fMaxCount = newMax; } @@ -643,7 +667,7 @@ void RangeToken::expand(const unsigned int length) { void RangeToken::createMap() { int asize = MAPSIZE/32; - fMap = new int[asize]; + fMap = (int*) fMemoryManager->allocate(asize * sizeof(int));//new int[asize]; fNonMapIndex = fElemCount; for (int i = 0; i < asize; i++) { diff --git a/src/xercesc/util/regx/RangeToken.hpp b/src/xercesc/util/regx/RangeToken.hpp index c1d080850..f9f6a8c71 100644 --- a/src/xercesc/util/regx/RangeToken.hpp +++ b/src/xercesc/util/regx/RangeToken.hpp @@ -79,7 +79,8 @@ public: // ----------------------------------------------------------------------- // Public Constructors and Destructor // ----------------------------------------------------------------------- - RangeToken(const unsigned short tokType); + RangeToken(const unsigned short tokType, + MemoryManager* const manager); ~RangeToken(); // ----------------------------------------------------------------------- @@ -139,6 +140,7 @@ private: int* fMap; XMLInt32* fRanges; RangeToken* fCaseIToken; + MemoryManager* fMemoryManager; }; XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/util/regx/RegularExpression.cpp b/src/xercesc/util/regx/RegularExpression.cpp index 2f55bca05..18b4ae2cc 100644 --- a/src/xercesc/util/regx/RegularExpression.cpp +++ b/src/xercesc/util/regx/RegularExpression.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.11 2003/05/16 21:37:00 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.10 2003/05/16 06:01:57 knoaman * Partial implementation of the configurable memory manager. * @@ -874,7 +877,7 @@ XMLCh* RegularExpression::replace(const XMLCh* const matchString, RefArrayVectorOf<XMLCh>* tokenStack = tokenize(matchString, start, end, subEx); Janitor<RefArrayVectorOf<XMLCh> > janTokStack(tokenStack); - XMLBuffer result; + XMLBuffer result(1023, fMemoryManager); int numSubEx = 0; @@ -1487,7 +1490,7 @@ const XMLCh* RegularExpression::subInExp(const XMLCh* const repString, bool notEscaped = true; - XMLBuffer newString; + XMLBuffer newString(1023, fMemoryManager); XMLCh indexStr[2]; //holds the string rep of a diff --git a/src/xercesc/util/regx/StringToken.hpp b/src/xercesc/util/regx/StringToken.hpp index 2a3f08105..909ac639c 100644 --- a/src/xercesc/util/regx/StringToken.hpp +++ b/src/xercesc/util/regx/StringToken.hpp @@ -123,8 +123,8 @@ inline const XMLCh* StringToken::getString() const { // --------------------------------------------------------------------------- inline void StringToken::setString(const XMLCh* const literal) { - delete [] fString; - fString = XMLString::replicate(literal); + fMemoryManager->deallocate(fString);//delete [] fString; + fString = XMLString::replicate(literal, fMemoryManager); } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/util/regx/TokenFactory.cpp b/src/xercesc/util/regx/TokenFactory.cpp index 2f9cb9bac..dc1e7361c 100644 --- a/src/xercesc/util/regx/TokenFactory.cpp +++ b/src/xercesc/util/regx/TokenFactory.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/05/16 21:37:00 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.6 2003/05/16 00:03:10 knoaman * Partial implementation of the configurable memory manager. * @@ -218,8 +221,8 @@ UnionToken* TokenFactory::createUnion(const bool isConcat) { RangeToken* TokenFactory::createRange(const bool isNegRange){ - RangeToken* tmpTok = isNegRange ? new (fMemoryManager) RangeToken(Token::T_NRANGE) - : new (fMemoryManager) RangeToken(Token::T_RANGE); + RangeToken* tmpTok = isNegRange ? new (fMemoryManager) RangeToken(Token::T_NRANGE, fMemoryManager) + : new (fMemoryManager) RangeToken(Token::T_RANGE, fMemoryManager); fTokens->addElement(tmpTok); return tmpTok; diff --git a/src/xercesc/util/regx/TokenFactory.hpp b/src/xercesc/util/regx/TokenFactory.hpp index 697d00b2b..8e2b7237b 100644 --- a/src/xercesc/util/regx/TokenFactory.hpp +++ b/src/xercesc/util/regx/TokenFactory.hpp @@ -136,6 +136,7 @@ public: Token* getDot(); Token* getCombiningCharacterSequence(); Token* getGraphemePattern(); + MemoryManager* getMemoryManager() const; private: // ----------------------------------------------------------------------- @@ -184,6 +185,11 @@ private: MemoryManager* fMemoryManager; }; +inline MemoryManager* TokenFactory::getMemoryManager() const +{ + return fMemoryManager; +} + XERCES_CPP_NAMESPACE_END #endif diff --git a/src/xercesc/util/regx/UnionToken.cpp b/src/xercesc/util/regx/UnionToken.cpp index adda82f91..75f9fa202 100644 --- a/src/xercesc/util/regx/UnionToken.cpp +++ b/src/xercesc/util/regx/UnionToken.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2003/05/16 21:37:00 knoaman + * Memory manager implementation: Modify constructors to pass in the memory manager. + * * Revision 1.4 2003/05/16 00:03:10 knoaman * Partial implementation of the configurable memory manager. * @@ -135,7 +138,7 @@ void UnionToken::addChild(Token* const child, TokenFactory* const tokFactory) { return; if (fChildren == 0) - fChildren = new RefVectorOf<Token>(INITIALSIZE, false); + fChildren = new (tokFactory->getMemoryManager()) RefVectorOf<Token>(INITIALSIZE, false); if (getTokenType() == T_UNION) { @@ -174,7 +177,7 @@ void UnionToken::addChild(Token* const child, TokenFactory* const tokFactory) { } // Continue - XMLBuffer stringBuf; + XMLBuffer stringBuf(1023, tokFactory->getMemoryManager()); if (previousType == T_CHAR) { -- GitLab