summaryrefslogtreecommitdiffstats
path: root/src/uscxml/interpreter/InterpreterImpl.cpp
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2016-06-13 08:52:55 (GMT)
committerStefan Radomski <github@mintwerk.de>2016-06-13 08:52:55 (GMT)
commit053e9bc973fbe88fc41a34064ffadc0deabac58d (patch)
tree6aeee286577159ffcb612d41972a9d18ab685c6d /src/uscxml/interpreter/InterpreterImpl.cpp
parent6e13c7b6e0888323223afd5d2e36e86243df57af (diff)
downloaduscxml-053e9bc973fbe88fc41a34064ffadc0deabac58d.zip
uscxml-053e9bc973fbe88fc41a34064ffadc0deabac58d.tar.gz
uscxml-053e9bc973fbe88fc41a34064ffadc0deabac58d.tar.bz2
Fixed dozens of memory leaks
Diffstat (limited to 'src/uscxml/interpreter/InterpreterImpl.cpp')
-rw-r--r--src/uscxml/interpreter/InterpreterImpl.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/uscxml/interpreter/InterpreterImpl.cpp b/src/uscxml/interpreter/InterpreterImpl.cpp
index 3383411..0547f12 100644
--- a/src/uscxml/interpreter/InterpreterImpl.cpp
+++ b/src/uscxml/interpreter/InterpreterImpl.cpp
@@ -82,15 +82,31 @@ InterpreterImpl::InterpreterImpl() : _isInitialized(false), _document(NULL), _sc
InterpreterImpl::~InterpreterImpl() {
- if (_delayQueue)
- _delayQueue.cancelAllDelayed();
- if (_document)
- delete _document;
-
- {
- std::lock_guard<std::recursive_mutex> lock(_instanceMutex);
- _instances.erase(getSessionId());
- }
+
+ // make sure we deallocate all user-data in the DOM,
+ // this is neccesary if we were aborted early
+ std::list<DOMElement*> invokes = DOMUtils::filterChildElements(_xmlPrefix.str() + "invoke", _scxml, true);
+ for (auto invoke : invokes) {
+ char* invokeId = (char*)invoke->getUserData(X("invokeid"));
+ if (invokeId != NULL) {
+ free(invokeId);
+ invoke->setUserData(X("invokeid"), NULL, NULL);
+ }
+ }
+
+ if (_delayQueue)
+ _delayQueue.cancelAllDelayed();
+ if (_document)
+ delete _document;
+
+ {
+ std::lock_guard<std::recursive_mutex> lock(_instanceMutex);
+ _instances.erase(getSessionId());
+ }
+
+// assert(_invokers.size() == 0);
+// ::xercesc_3_1::XMLPlatformUtils::Terminate();
+
}
void InterpreterImpl::cancel() {
@@ -361,6 +377,7 @@ void InterpreterImpl::uninvoke(const std::string& invokeId) {
if (_invokers.find(invokeId) != _invokers.end()) {
_invokers[invokeId].uninvoke();
_autoForwarders.erase(invokeId);
+ _invokers.erase(invokeId);
}
}