[Mobies-commit] [commit] r4390 - in UDM/trunk/src: UdmBase UdmDom
ksmyth at svn.isis.vanderbilt.edu
ksmyth at svn.isis.vanderbilt.edu
Fri Oct 13 09:38:45 CDT 2017
Author: ksmyth
Date: Fri Oct 13 09:38:45 2017
New Revision: 4390
Log:
Fix memory leaks
Modified:
UDM/trunk/src/UdmBase/UdmBase.cpp
UDM/trunk/src/UdmDom/UdmDom.cpp
Modified: UDM/trunk/src/UdmBase/UdmBase.cpp
==============================================================================
--- UDM/trunk/src/UdmBase/UdmBase.cpp Fri Oct 13 09:38:37 2017 (r4389)
+++ UDM/trunk/src/UdmBase/UdmBase.cpp Fri Oct 13 09:38:45 2017 (r4390)
@@ -1712,20 +1712,22 @@
{
UDM_ASSERT(refs.size());
- ObjectImpl* ref = refs.back();
+ Object ref = refs.back()->clone();
// exit loop when reaching the parent of the reference port
- const ObjectImpl *target_parent = target->getParent(NULLPARENTROLE);
+ ObjectImpl *target_parent = target->getParent(NULLPARENTROLE);
- while (ref != &_null) {
+ while (ref.__impl() != &_null) {
- Object referred = Object(ref->clone()).getReferencedObject();
+ Object referred = Object(ref.__impl()->clone()).getReferencedObject();
if (referred.uniqueId() == target_parent->uniqueId())
break;
ref = referred.__impl()->clone();
}
+ if (target_parent != &_null)
+ target_parent->release();
return ref != &_null;
}
@@ -1738,8 +1740,9 @@
ObjectImpl* rp_helper_ref = &_null;
if (rp_helper) {
vector<ObjectImpl*> v = getAssociation(rp_helper);
- if (v.size())
+ if (v.size()) {
rp_helper_ref = v.front();
+ }
}
if (refs.size()) {
@@ -1751,6 +1754,7 @@
vector<ObjectImpl*> v;
v.push_back(refs.front());
setAssociation(rp_helper, v);
+ rp_helper_ref->release();
}
} else {
if (rp_helper_ref != &_null) {
@@ -1758,25 +1762,35 @@
// is there a reference port helper set for this connection?
vector<ObjectImpl*> v;
v.push_back(rp_helper_ref);
- if (!canCompleteRefsChain(target, v))
+ if (!canCompleteRefsChain(target, v)) {
+ rp_helper_ref->release();
throw udm_exception("Could not reach target " + UdmUtil::ExtractName(target) + " starting with the reference port helper set in the model");
+ }
+ rp_helper_ref->release();
} else {
- ObjectImpl* parent = getParent(NULLPARENTROLE);
- if (parent != target->getParent(NULLPARENTROLE)) {
- vector<ObjectImpl*> children = parent->getChildren(NULL, NULL);
+ Object parent = getParent(NULLPARENTROLE);
+ Object parent_target = target->getParent(NULLPARENTROLE);
+ if (parent.__impl() != parent_target.__impl()) {
+ vector<ObjectImpl*> children = parent.__impl()->getChildren(NULL, NULL);
vector<ObjectImpl*>::const_iterator i = children.begin();
for (; i != children.end(); i++) {
- ObjectImpl *child = *i;
+ ObjectImpl* child = *i;
vector<ObjectImpl*> v;
v.push_back(child);
if (child->type().stereotype() == "Reference" && canCompleteRefsChain(target, v)) {
// found a child that can be used to reach the target
setAssociation(rp_helper, v);
+ //(*i)->release();
break;
+ } else {
+ (*i)->release();
}
}
if (i == children.end())
throw udm_exception("Could not reach target " + UdmUtil::ExtractName(target) + " from any reference found in the parent of connection");
+ for (; i != children.end(); i++) {
+ (*i)->release();
+ }
}
}
}
@@ -1847,13 +1861,13 @@
ObjectImpl* ref = v[0];
// exit loop when reaching the parent of the reference port
- const ObjectImpl *target_parent = target->getParent(NULLPARENTROLE);
+ Object target_parent = target->getParent(NULLPARENTROLE);
do {
ret.push_back(ref);
Object referred = Object(ref->clone()).getReferencedObject();
- if (referred.uniqueId() == target_parent->uniqueId())
+ if (referred.uniqueId() == target_parent.__impl()->uniqueId())
break;
ref = referred.__impl()->clone();
Modified: UDM/trunk/src/UdmDom/UdmDom.cpp
==============================================================================
--- UDM/trunk/src/UdmDom/UdmDom.cpp Fri Oct 13 09:38:37 2017 (r4389)
+++ UDM/trunk/src/UdmDom/UdmDom.cpp Fri Oct 13 09:38:45 2017 (r4390)
@@ -923,7 +923,7 @@
*(target + startIndex) = chNull;
else
// +1 for the end of string
- XMLString::moveChars(target + startIndex, target + startIndex + count, XMLString::stringLen(target) - startIndex - count + 1);
+ XMLString::moveChars(target + startIndex, target + startIndex + count, length - startIndex - count + 1);
}
const XMLCh* GetID()
@@ -2809,6 +2809,7 @@
currentpeer->setAttribute(tname_buf, cpa_new);
else
currentpeer->removeAttribute(tname_buf);
+ XMLString::release(&cpa_new);
}
else
currentpeer->removeAttribute(tname_buf);
More information about the Mobies-commit
mailing list