Skip to content

Commit aa95a56

Browse files
committed
destructor frees stylesheet
1 parent 0ed8029 commit aa95a56

5 files changed

Lines changed: 24 additions & 77 deletions

File tree

docs/dictionary/command/xsltFreeStylesheet.xml

Lines changed: 0 additions & 68 deletions
This file was deleted.

docs/dictionary/function/xsltLoadStylesheet.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
<function tag="xsltApplyStylesheet">xsltApplyStylesheet</function>
6161
<function tag="xsltApplyStylesheetFromFile">xsltApplyStylesheetFromFile</function>
6262
<function tag="xsltLoadStylesheetFromFile">xsltLoadStylesheetFromFile</function>
63-
<command tag="xsltFreeStylesheet">xsltFreeStylesheet</command>
63+
<command tag=""></command>
6464
</references>
6565

66-
<description>The xsltLoadStylesheet function loads an xslt stylesheet into memory from xml data so that it can be applied to xml data using the xsltApplyStylesheet function. It returns an xslt stylesheet id. It is the responsibility of the program to free the stylesheet with the xsltFreeStylesheet command when it is no longer needed in order to prevent memory leaks.</description>
66+
<description>The xsltLoadStylesheet function loads an xslt stylesheet into memory from xml data so that it can be applied to xml data using the xsltApplyStylesheet function. It returns an xslt stylesheet id.</description>
6767
</doc>

docs/dictionary/function/xsltLoadStylesheetFromFile.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
<function tag="xsltApplyStylesheet">xsltApplyStylesheet</function>
6161
<function tag="xsltApplyStylesheetFromFile">xsltApplyStylesheetFromFile</function>
6262
<function tag="xsltLoadStylesheetFromFile">xsltLoadStylesheetFromFile</function>
63-
<command tag="xsltFreeStylesheet">xsltFreeStylesheet</command>
63+
<command tag=""></command>
6464
</references>
6565

66-
<description>The xsltLoadStylesheetFromFile function loads an xslt stylesheet into memory from a file so that it can be applied to xml data using the xsltApplyStylesheet function. It returns an xslt stylesheet id. It is the responsibility of the program to free the stylesheet with the xsltFreeStylesheet command when it is no longer needed in order to prevent memory leaks.</description>
66+
<description>The xsltLoadStylesheetFromFile function loads an xslt stylesheet into memory from a file so that it can be applied to xml data using the xsltApplyStylesheet function. It returns an xslt stylesheet id.</description>
6767
</doc>

revxml/src/revxml.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ class XMLDocumentList
156156
for (theIterator = doclist.begin(); theIterator != doclist.end(); theIterator++){
157157
CXMLDocument *curobject = (CXMLDocument *)(*theIterator);
158158
// MDW-2013-07-09: [[ RevXmlXPath ]]
159-
xmlXPathFreeContext(curobject->GetXPathContext());
159+
if (NULL != curobject->GetXPathContext())
160+
xmlXPathFreeContext(curobject->GetXPathContext());
161+
// MDW-2013-09-04: [[ RevXmlXslt ]]
162+
if (NULL != curobject->GetXsltContext())
163+
xsltFreeStylesheet(curobject->GetXsltContext());
160164
delete curobject;
161165
}
162166
doclist.clear();
@@ -2785,6 +2789,10 @@ void XML_xsltLoadStylesheetFromFile(char *args[], int nargs, char **retstring, B
27852789
* frees a xsltStylesheetPtr created by xsltLoadStylesheet
27862790
*
27872791
* xsltFreeStylesheet tStylesheetID
2792+
*
2793+
* NOTE: this is no longer necessary, so I commented out the reference to it
2794+
* but I'm keeping this here so I don't have to reinvent it if it becomes
2795+
* necessary to pull it in again. MDW-2013-09-04
27882796
*/
27892797
void XML_xsltFreeStylesheet(char *args[], int nargs, char **retstring, Bool *pass, Bool *error)
27902798
{
@@ -3041,7 +3049,7 @@ EXTERNAL_BEGIN_DECLARATIONS("revXML")
30413049
EXTERNAL_DECLARE_FUNCTION("xsltApplyStylesheetFile", XML_xsltApplyStylesheetFile)
30423050
EXTERNAL_DECLARE_FUNCTION("xsltLoadStylesheet", XML_xsltLoadStylesheet)
30433051
EXTERNAL_DECLARE_FUNCTION("xsltLoadStylesheetFromFile", XML_xsltLoadStylesheetFromFile)
3044-
EXTERNAL_DECLARE_COMMAND("xsltFreeStylesheet", XML_xsltFreeStylesheet)
3052+
// EXTERNAL_DECLARE_COMMAND("xsltFreeStylesheet", XML_xsltFreeStylesheet)
30453053
EXTERNAL_END_DECLARATIONS
30463054

30473055

revxml/src/xmldoc.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,16 @@ void CXMLDocument::Write(char **data,int *tlength,Bool isformatted)
337337
/*Free - frees xml document*/
338338
void CXMLDocument::Free()
339339
{
340-
if (!isinited()) return;
341-
xmlFreeDoc(doc);
342-
doc = NULL;
340+
if (!isinited()) return;
341+
xmlFreeDoc(doc);
342+
doc = NULL;
343+
if (NULL != xpathContext)
344+
xmlXPathFreeContext(xpathContext);
345+
xpathContext = NULL;
346+
// MDW-2013-09-04: [[ RevXmlXslt ]]
347+
if (NULL != xsltID)
348+
xsltFreeStylesheet(xsltID);
349+
xsltID = NULL;
343350
}
344351

345352
/*CopyDocument - copies xml tree of other CXMLDocument

0 commit comments

Comments
 (0)