tng 2002/07/26 13:31:23 Modified: c/src/xercesc/dom/impl DOMDocumentTypeImpl.cpp DOMDocumentTypeImpl.hpp Log: Memory Leak in DOMDocumentTypeImpl Revision Changes Path 1.10 +23 -21 xml-xerces/c/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp Index: DOMDocumentTypeImpl.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMDocumentTypeImpl.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- DOMDocumentTypeImpl.cpp 16 Jul 2002 16:08:27 -0000 1.9 +++ DOMDocumentTypeImpl.cpp 26 Jul 2002 20:31:23 -0000 1.10 @@ -79,6 +79,7 @@ entities(0), notations(0), elements(0), + internalSubset(0), fIsCreatedFromHeap(heap) { if (ownerDoc) { @@ -111,6 +112,7 @@ entities(0), notations(0), elements(0), + internalSubset(0), fIsCreatedFromHeap(heap) { if (DOMDocumentImpl::indexofQualifiedName(qualifiedName) < 0) @@ -120,6 +122,7 @@ DOMDocumentImpl *docImpl = (DOMDocumentImpl *)ownerDoc; publicId = docImpl->cloneString(pubId); systemId = docImpl->cloneString(sysId); + internalSubset = docImpl->cloneString(internalSubset); name = ((DOMDocumentImpl *)ownerDoc)->getPooledString(qualifiedName); entities = new (ownerDoc) DOMNamedNodeMapImpl(this); notations= new (ownerDoc) DOMNamedNodeMapImpl(this); @@ -128,6 +131,7 @@ else { publicId = XMLString::replicate(pubId); systemId = XMLString::replicate(sysId); + internalSubset = XMLString::replicate(internalSubset); name = XMLString::replicate(qualifiedName); entities = new DOMNamedNodeMapImpl(this); notations= new DOMNamedNodeMapImpl(this); @@ -147,6 +151,7 @@ entities(0), notations(0), elements(0), + internalSubset(0), fIsCreatedFromHeap(heap) { if ((DOMDocumentImpl *)this->fNode.getOwnerDocument()) { @@ -156,14 +161,15 @@ //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); @@ -183,6 +189,9 @@ temp = (XMLCh*) systemId; delete [] temp; + temp = (XMLCh*) internalSubset; + delete [] temp; + delete entities; delete notations; delete elements; @@ -223,6 +232,10 @@ systemId = docImpl->cloneString(systemId); delete [] temp; + temp = (XMLCh*) internalSubset; // cast off const + systemId = docImpl->cloneString(internalSubset); + delete [] temp; + temp = (XMLCh*) name; // cast off const name = docImpl->cloneString(name); delete [] temp; @@ -314,11 +327,7 @@ const XMLCh * DOMDocumentTypeImpl::getInternalSubset() const { - const XMLCh* subset = internalSubset.getRawBuffer(); - if (!XMLString::stringLen(subset)) - return 0; - else - return subset; + return internalSubset; } bool DOMDocumentTypeImpl::isIntSubsetReading() const @@ -363,20 +372,13 @@ if (value == 0) return; - internalSubset.set(value); -} - -void DOMDocumentTypeImpl::appendInternalSubset(const XMLCh *value) -{ - if (value == 0) - return; - - internalSubset.append(value); -} - -void DOMDocumentTypeImpl::appendInternalSubset(const XMLCh toAppend) -{ - internalSubset.append(toAppend); + 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); + } } void DOMDocumentTypeImpl::release() 1.6 +2 -4 xml-xerces/c/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp Index: DOMDocumentTypeImpl.hpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- DOMDocumentTypeImpl.hpp 16 Jul 2002 15:35:44 -0000 1.5 +++ DOMDocumentTypeImpl.hpp 26 Jul 2002 20:31:23 -0000 1.6 @@ -95,7 +95,7 @@ DOMNamedNodeMap* elements; const XMLCh * publicId; const XMLCh * systemId; - XMLBuffer internalSubset; + const XMLCh * internalSubset; bool intSubsetReading; bool fIsCreatedFromHeap; @@ -103,8 +103,6 @@ virtual void setPublicId(const XMLCh * value); virtual void setSystemId(const XMLCh * value); virtual void setInternalSubset(const XMLCh *value); - void appendInternalSubset(const XMLCh *value); - void appendInternalSubset(const XMLCh toAppend); bool isIntSubsetReading() const; friend class AbstractDOMParser;
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]