diff --git a/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp b/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp index ca76991dfae2ba830b88693552d404594e815852..96e4180ca61b827619fe53e6c404e007d6514440 100644 --- a/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp +++ b/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp @@ -75,7 +75,6 @@ DOMDocumentTypeImpl::DOMDocumentTypeImpl(DOMDocument *ownerDoc, publicId(0), systemId(0), name(0), - internalSubset(0), //DOM Level 2 intSubsetReading(false), entities(0), notations(0), @@ -108,7 +107,6 @@ DOMDocumentTypeImpl::DOMDocumentTypeImpl(DOMDocument *ownerDoc, publicId(0), systemId(0), name(0), - internalSubset(0), //DOM Level 2 intSubsetReading(false), entities(0), notations(0), @@ -145,7 +143,6 @@ DOMDocumentTypeImpl::DOMDocumentTypeImpl(const DOMDocumentTypeImpl &other, bool publicId(0), systemId(0), name(0), - internalSubset(0), //DOM Level 2 intSubsetReading(other.intSubsetReading), entities(0), notations(0), @@ -159,15 +156,14 @@ DOMDocumentTypeImpl::DOMDocumentTypeImpl(const DOMDocumentTypeImpl &other, bool //DOM Level 2 publicId = other.publicId; systemId = other.systemId; - internalSubset = other.internalSubset; } else { name = XMLString::replicate(other.name); publicId = XMLString::replicate(other.publicId); systemId = XMLString::replicate(other.systemId); - internalSubset = XMLString::replicate(other.internalSubset); } + internalSubset.set(other.internalSubset.getRawBuffer()); entities = ((DOMNamedNodeMapImpl *)other.entities)->cloneMap(this); notations= ((DOMNamedNodeMapImpl *)other.notations)->cloneMap(this); elements = ((DOMNamedNodeMapImpl *)other.elements)->cloneMap(this); @@ -187,9 +183,6 @@ DOMDocumentTypeImpl::~DOMDocumentTypeImpl() temp = (XMLCh*) systemId; delete [] temp; - temp = (XMLCh*) internalSubset; - delete [] temp; - delete entities; delete notations; delete elements; @@ -230,10 +223,6 @@ void DOMDocumentTypeImpl::setOwnerDocument(DOMDocument *doc) { systemId = docImpl->cloneString(systemId); delete [] temp; - temp = (XMLCh*) internalSubset; // cast off const - internalSubset = docImpl->cloneString(internalSubset); - delete [] temp; - temp = (XMLCh*) name; // cast off const name = docImpl->cloneString(name); delete [] temp; @@ -325,7 +314,7 @@ const XMLCh * DOMDocumentTypeImpl::getSystemId() const const XMLCh * DOMDocumentTypeImpl::getInternalSubset() const { - return internalSubset; + return internalSubset.getRawBuffer(); } bool DOMDocumentTypeImpl::isIntSubsetReading() const @@ -370,13 +359,15 @@ void DOMDocumentTypeImpl::setInternalSubset(const XMLCh *value) if (value == 0) return; - if ((DOMDocumentImpl *)castToNodeImpl(this)->getOwnerDocument()) - internalSubset = ((DOMDocumentImpl *)castToNodeImpl(this)->getOwnerDocument())->getPooledString(value); - else { - XMLCh* temp = (XMLCh*) internalSubset; // cast off const - delete [] temp; - internalSubset = XMLString::replicate(value); - } + internalSubset.set(value); +} + +void DOMDocumentTypeImpl::appendInternalSubset(const XMLCh *value) +{ + if (value == 0) + return; + + internalSubset.append(value); } void DOMDocumentTypeImpl::release() diff --git a/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp b/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp index ebeea47a84dc1f8144c325ce61206bae38038fad..131cb11ffdb7cd8fb2ded8dea5cb2351edf20238 100644 --- a/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp +++ b/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp @@ -73,6 +73,7 @@ #include <xercesc/util/XercesDefs.hpp> +#include <xercesc/framework/XMLBuffer.hpp> #include <xercesc/dom/DOMDocumentType.hpp> #include "DOMNodeImpl.hpp" #include "DOMChildNode.hpp" @@ -94,7 +95,7 @@ private: DOMNamedNodeMap* elements; const XMLCh * publicId; const XMLCh * systemId; - const XMLCh * internalSubset; + XMLBuffer internalSubset; bool intSubsetReading; bool fIsCreatedFromHeap; @@ -102,6 +103,7 @@ private: virtual void setPublicId(const XMLCh * value); virtual void setSystemId(const XMLCh * value); virtual void setInternalSubset(const XMLCh *value); + void appendInternalSubset(const XMLCh *value); bool isIntSubsetReading() const; friend class AbstractDOMParser; diff --git a/src/xercesc/parsers/AbstractDOMParser.cpp b/src/xercesc/parsers/AbstractDOMParser.cpp index 4bdff439ef6a74e2c51a3a05e2ac1e6ac8427d13..42af94de3e6f4dad437e011261bd82d394b07be6 100644 --- a/src/xercesc/parsers/AbstractDOMParser.cpp +++ b/src/xercesc/parsers/AbstractDOMParser.cpp @@ -903,7 +903,7 @@ void AbstractDOMParser::attDef } attString.append(chCloseAngle); - fDocumentType->setInternalSubset(attString.getRawBuffer()); + fDocumentType->appendInternalSubset(attString.getRawBuffer()); } } } @@ -927,7 +927,7 @@ void AbstractDOMParser::doctypeComment comString.append(chDash); comString.append(chDash); comString.append(chCloseAngle); - fDocumentType->setInternalSubset(comString.getRawBuffer()); + fDocumentType->appendInternalSubset(comString.getRawBuffer()); } } } @@ -964,7 +964,7 @@ void AbstractDOMParser::doctypePI pi.append(chQuestion); pi.append(chCloseAngle); - fDocumentType->setInternalSubset(pi.getRawBuffer()); + fDocumentType->appendInternalSubset(pi.getRawBuffer()); } } @@ -977,7 +977,7 @@ void AbstractDOMParser::doctypeWhitespace ) { if (fDocumentType->isIntSubsetReading()) - fDocumentType->setInternalSubset(chars); + fDocumentType->appendInternalSubset(chars); } void AbstractDOMParser::elementDecl @@ -1005,7 +1005,7 @@ void AbstractDOMParser::elementDecl } elemDecl.append(chCloseAngle); - fDocumentType->setInternalSubset(elemDecl.getRawBuffer()); + fDocumentType->appendInternalSubset(elemDecl.getRawBuffer()); } } @@ -1178,7 +1178,7 @@ void AbstractDOMParser::entityDecl } entityName.append(chCloseAngle); - fDocumentType->setInternalSubset(entityName.getRawBuffer()); + fDocumentType->appendInternalSubset(entityName.getRawBuffer()); } }