You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2004/10/12 23:57:08 UTC

cvs commit: xml-xalan/c/src/xalanc/XSLT StylesheetExecutionContextDefault.cpp StylesheetExecutionContextDefault.hpp

dbertoni    2004/10/12 14:57:08

  Modified:    c/src/xalanc/XSLT StylesheetExecutionContextDefault.cpp
                        StylesheetExecutionContextDefault.hpp
  Log:
  Fixed leak of DOMStringPrintWriter instances.
  
  Revision  Changes    Path
  1.31      +33 -24    xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.cpp
  
  Index: StylesheetExecutionContextDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.cpp,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- StylesheetExecutionContextDefault.cpp	13 Aug 2004 15:49:47 -0000	1.30
  +++ StylesheetExecutionContextDefault.cpp	12 Oct 2004 21:57:08 -0000	1.31
  @@ -94,8 +94,6 @@
   
   
   
  -
  -
   StylesheetExecutionContextDefault::StylesheetExecutionContextDefault(
   			XSLTEngineImpl&			xsltProcessor,
   			XPathEnvSupport&		theXPathEnvSupport,
  @@ -3000,26 +2998,12 @@
   void
   StylesheetExecutionContextDefault::beginFormatToText(XalanDOMString&  theResult)
   {
  -	FormatterToText* theFormatter = m_formatterToTextStack.get();
  +    FormatterToTextDOMString* const     theFormatter =
  +        m_formatterToTextStack.get();
  +    assert(theFormatter != 0);
  +
  +    theFormatter->setDOMString(theResult);
   
  -	if (theFormatter->getWriter() == 0)
  -	{
  -		theFormatter->setWriter(new DOMStringPrintWriter(theResult));
  -		theFormatter->setNormalizeLinefeed(false);
  -		theFormatter->setHandleIgnorableWhitespace(true);
  -		theFormatter->clearEncoding();
  -	}
  -	else
  -	{
  -		 DOMStringPrintWriter*	thePrinterWriter  =
  -#if defined(XALAN_OLD_STYLE_CASTS)
  -				(DOMStringPrintWriter*)(theFormatter->getWriter());
  -#else
  -				static_cast<DOMStringPrintWriter*>(theFormatter->getWriter());
  -#endif
  -		thePrinterWriter->setString(theResult);
  -	}
  -	
   	pushOutputContext(theFormatter);
   	
   	theFormatter->startDocument();
  @@ -3030,8 +3014,13 @@
   void
   StylesheetExecutionContextDefault::endFormatToText()
   {
  -	FormatterToText* theFormatter = m_formatterToTextStack.top();
  -	
  +	FormatterToText* const  theFormatter = m_formatterToTextStack.top();
  +	assert(
  +        theFormatter != 0 &&
  +        theFormatter->getEncoding().empty() == true &&
  +        theFormatter->getNormalizeLinefeed() == false &&
  +        theFormatter->getHandleIgnorableWhitespace() == true);
  +
   	theFormatter->endDocument();
   
   	popOutputContext();
  @@ -3108,8 +3097,28 @@
   
   	m_nodesToTransformStack.pop_back();
   }
  -#endif
   
  +
  +
  +XalanDOMString  StylesheetExecutionContextDefault::FormatterToTextDOMString::s_dummyString;
  +
  +
  +
  +StylesheetExecutionContextDefault::FormatterToTextDOMString::FormatterToTextDOMString() :
  +    FormatterToText(),
  +    m_printWriter(s_dummyString)
  +{
  +    setNormalizeLinefeed(false);
  +
  +    setWriter(&m_printWriter);
  +}
  +
  +
  +StylesheetExecutionContextDefault::FormatterToTextDOMString::~FormatterToTextDOMString()
  +{
  +    assert(s_dummyString.capacity() == 0);
  +}
  +#endif
   
   
   XALAN_CPP_NAMESPACE_END
  
  
  
  1.31      +29 -1     xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp
  
  Index: StylesheetExecutionContextDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- StylesheetExecutionContextDefault.hpp	30 Sep 2004 22:28:10 -0000	1.30
  +++ StylesheetExecutionContextDefault.hpp	12 Oct 2004 21:57:08 -0000	1.31
  @@ -37,6 +37,12 @@
   
   
   
  +#if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
  +#include <xalanc/PlatformSupport/DOMStringPrintWriter.hpp>
  +#endif
  +
  +
  +
   #include <xalanc/XPath/XPathExecutionContextDefault.hpp>
   
   
  @@ -1181,12 +1187,34 @@
   #endif
   
   #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
  +    class FormatterToTextDOMString : public FormatterToText
  +    {
  +    public:
  +
  +        FormatterToTextDOMString();
  +
  +        virtual
  +        ~FormatterToTextDOMString();
  +
  +        void
  +        setDOMString(XalanDOMString&    theString)
  +        {
  +            m_printWriter.setString(theString);
  +        }
  +
  +    private:
  +
  +        DOMStringPrintWriter    m_printWriter;
  +
  +        static XalanDOMString   s_dummyString;
  +    };
  +
   	typedef XalanVector<XObjectPtr>			XObjectPtrStackType;
   	typedef XalanVector<ParamsVectorType>		ParamsVectorStackType;
   	typedef XalanVector<UseAttributeSetIndexes>  	UseAttributeSetIndexesStackType;
   	typedef XalanObjectStackCache<MutableNodeRefList>		MutableNodeRefListStackType;
   	typedef XalanObjectStackCache<XalanDOMString>			StringStackType;
  -	typedef XalanObjectStackCache<FormatterToText>			FormatterToTextStackType;
  +	typedef XalanObjectStackCache<FormatterToTextDOMString>			FormatterToTextStackType;
   	typedef XalanObjectStackCache<FormatterToSourceTree>		FormatterToSourceTreeStackType;
   
   	/*
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org