You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2010/10/27 17:09:39 UTC
svn commit: r1027995 - in /xerces/c/branches/xerces-3.1:
src/xercesc/dom/impl/DOMCDATASectionImpl.cpp
src/xercesc/dom/impl/DOMTextImpl.cpp
tests/src/MemHandlerTest/MemoryMonitor.cpp
Author: amassari
Date: Wed Oct 27 15:09:39 2010
New Revision: 1027995
URL: http://svn.apache.org/viewvc?rev=1027995&view=rev
Log:
Use the DOMDocument's pool to allocate the return value of getWholeText (XERCESC-1949)
Modified:
xerces/c/branches/xerces-3.1/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp
xerces/c/branches/xerces-3.1/src/xercesc/dom/impl/DOMTextImpl.cpp
xerces/c/branches/xerces-3.1/tests/src/MemHandlerTest/MemoryMonitor.cpp
Modified: xerces/c/branches/xerces-3.1/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-3.1/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp?rev=1027995&r1=1027994&r2=1027995&view=diff
==============================================================================
--- xerces/c/branches/xerces-3.1/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp (original)
+++ xerces/c/branches/xerces-3.1/src/xercesc/dom/impl/DOMCDATASectionImpl.cpp Wed Oct 27 15:09:39 2010
@@ -135,7 +135,12 @@ bool DOMCDATASectionImpl::getIsElementCo
const XMLCh* DOMCDATASectionImpl::getWholeText() const
{
DOMDocument *doc = getOwnerDocument();
- DOMTreeWalker* pWalker=doc->createTreeWalker(doc->getDocumentElement(), DOMNodeFilter::SHOW_ALL, NULL, true);
+ if (!doc) {
+ throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, GetDOMNodeMemoryManager);
+ return 0;
+ }
+ DOMNode* root=doc->getDocumentElement();
+ DOMTreeWalker* pWalker=doc->createTreeWalker(root!=NULL?root:(DOMNode*)this, DOMNodeFilter::SHOW_ALL, NULL, true);
pWalker->setCurrentNode((DOMNode*)this);
// Logically-adjacent text nodes are Text or CDATASection nodes that can be visited sequentially in document order or in
// reversed document order without entering, exiting, or passing over Element, Comment, or ProcessingInstruction nodes.
@@ -156,7 +161,7 @@ const XMLCh* DOMCDATASectionImpl::getWho
}
pWalker->release();
- XMLCh* wholeString = (XMLCh*) (GetDOMNodeMemoryManager->allocate((buff.getLen()+1)*sizeof(XMLCh)));
+ XMLCh* wholeString = (XMLCh*)((DOMDocumentImpl*)doc)->allocate((buff.getLen()+1) * sizeof(XMLCh));
XMLString::copyString(wholeString, buff.getRawBuffer());
return wholeString;
}
Modified: xerces/c/branches/xerces-3.1/src/xercesc/dom/impl/DOMTextImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-3.1/src/xercesc/dom/impl/DOMTextImpl.cpp?rev=1027995&r1=1027994&r2=1027995&view=diff
==============================================================================
--- xerces/c/branches/xerces-3.1/src/xercesc/dom/impl/DOMTextImpl.cpp (original)
+++ xerces/c/branches/xerces-3.1/src/xercesc/dom/impl/DOMTextImpl.cpp Wed Oct 27 15:09:39 2010
@@ -145,7 +145,12 @@ bool DOMTextImpl::getIsElementContentWhi
const XMLCh* DOMTextImpl::getWholeText() const
{
DOMDocument *doc = getOwnerDocument();
- DOMTreeWalker* pWalker=doc->createTreeWalker(doc->getDocumentElement(), DOMNodeFilter::SHOW_ALL, NULL, true);
+ if (!doc) {
+ throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, GetDOMNodeMemoryManager);
+ return 0;
+ }
+ DOMNode* root=doc->getDocumentElement();
+ DOMTreeWalker* pWalker=doc->createTreeWalker(root!=NULL?root:(DOMNode*)this, DOMNodeFilter::SHOW_ALL, NULL, true);
pWalker->setCurrentNode((DOMNode*)this);
// Logically-adjacent text nodes are Text or CDATASection nodes that can be visited sequentially in document order or in
// reversed document order without entering, exiting, or passing over Element, Comment, or ProcessingInstruction nodes.
@@ -166,7 +171,7 @@ const XMLCh* DOMTextImpl::getWholeText()
}
pWalker->release();
- XMLCh* wholeString = (XMLCh*) (GetDOMNodeMemoryManager->allocate((buff.getLen()+1)*sizeof(XMLCh)));
+ XMLCh* wholeString = (XMLCh*)((DOMDocumentImpl*)doc)->allocate((buff.getLen()+1) * sizeof(XMLCh));
XMLString::copyString(wholeString, buff.getRawBuffer());
return wholeString;
}
Modified: xerces/c/branches/xerces-3.1/tests/src/MemHandlerTest/MemoryMonitor.cpp
URL: http://svn.apache.org/viewvc/xerces/c/branches/xerces-3.1/tests/src/MemHandlerTest/MemoryMonitor.cpp?rev=1027995&r1=1027994&r2=1027995&view=diff
==============================================================================
--- xerces/c/branches/xerces-3.1/tests/src/MemHandlerTest/MemoryMonitor.cpp (original)
+++ xerces/c/branches/xerces-3.1/tests/src/MemHandlerTest/MemoryMonitor.cpp Wed Oct 27 15:09:39 2010
@@ -378,6 +378,11 @@ int main (int argC, char *argV[])
XERCES_STD_QUALIFIER cout << "getElementsByTagName didn't return a valid DOMNodeList." << XERCES_STD_QUALIFIER endl;
else if(list->item(0)!=doc->getDocumentElement())
XERCES_STD_QUALIFIER cout << "getElementsByTagName didn't find the root element." << XERCES_STD_QUALIFIER endl;
+
+ DOMTreeWalker* pWalker=doc->createTreeWalker(doc->getDocumentElement(), DOMNodeFilter::SHOW_TEXT, NULL, true);
+ DOMText* textNode=(DOMText*)pWalker->nextNode();
+ pWalker->release();
+ const XMLCh* txt=(textNode!=NULL?textNode->getWholeText():NULL);
}
sax2parser->parse(xmlFile);
saxParser->parse(xmlFile);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org