aboutsummaryrefslogtreecommitdiff
path: root/src/function/read_directory.h
diff options
context:
space:
mode:
authorAdrian Kummerländer2014-04-23 21:26:58 +0200
committerAdrian Kummerländer2014-04-23 21:26:58 +0200
commit525aa8c4dc3e23f0369c7edb1fb507ecad5f43bf (patch)
tree6044c2876a55ed4c794bd577909225c49015d402 /src/function/read_directory.h
parent30ae1cc66daf8acbb556ec761f96690a2fa74637 (diff)
downloadInputXSLT-525aa8c4dc3e23f0369c7edb1fb507ecad5f43bf.tar
InputXSLT-525aa8c4dc3e23f0369c7edb1fb507ecad5f43bf.tar.gz
InputXSLT-525aa8c4dc3e23f0369c7edb1fb507ecad5f43bf.tar.bz2
InputXSLT-525aa8c4dc3e23f0369c7edb1fb507ecad5f43bf.tar.lz
InputXSLT-525aa8c4dc3e23f0369c7edb1fb507ecad5f43bf.tar.xz
InputXSLT-525aa8c4dc3e23f0369c7edb1fb507ecad5f43bf.tar.zst
InputXSLT-525aa8c4dc3e23f0369c7edb1fb507ecad5f43bf.zip
Fixed xerces DOM construction related memory leaks
* Wrapped xerces DOM and support class instances in now DomDocumentGuard scope-guard class * FunctionReadDirectory class contains interal std::stack instance to store DomDocumentGuard instances ** wrapped in std::shared_ptr as FunctionReadDirectory is internally cloned by xalan... ** this is needed as the DOM has to preserved longer than the external function execution scope * Sadly XMLCh xerces strings have to be manually released ** added appropriate xercesc::XMLString::release calls * xalan::XercesDOMWrapperParsedSource does not mirror a given xerces DOM but convert it on instantiation ** this is why there is a dedicated finalize member method in InputXSLT::DomDocumentGuard * In short: I do not like the amount of trickery needed to simply prevent memory leaks in this context ** there sadly doesn't seem to be a substantially easier way to return arbitrary DOM trees from a external function
Diffstat (limited to 'src/function/read_directory.h')
-rw-r--r--src/function/read_directory.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/function/read_directory.h b/src/function/read_directory.h
index e7ee0c4..3c55591 100644
--- a/src/function/read_directory.h
+++ b/src/function/read_directory.h
@@ -6,19 +6,18 @@
#include <xalanc/XPath/Function.hpp>
#include <xalanc/XPath/XObject.hpp>
-#include <xalanc/XercesParserLiaison/XercesParserLiaison.hpp>
-
-#include <string>
+#include <memory>
+#include <stack>
#include "common.h"
#include "support/filesystem_context.h"
+#include "support/dom_document_guard.h"
namespace InputXSLT {
class FunctionReadDirectory : public xalan::Function {
public:
FunctionReadDirectory(const FilesystemContext&);
- FunctionReadDirectory(const FunctionReadDirectory&);
virtual xalan::XObjectPtr execute(
xalan::XPathExecutionContext&,
@@ -34,7 +33,8 @@ class FunctionReadDirectory : public xalan::Function {
private:
const FilesystemContext& fs_context_;
- mutable xalan::XercesParserLiaison parser_;
+
+ std::shared_ptr<std::stack<DomDocumentGuard>> documents_;
const xalan::XalanDOMString& getError(xalan::XalanDOMString&) const;