Skip to content

Commit

Permalink
Fix nasa#169, Remove unnecessary null pointer checks
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Oct 28, 2022
1 parent ac5c332 commit df62ebe
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 25 deletions.
3 changes: 1 addition & 2 deletions src/PLASMA/ANML/base/ANMLTranslator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,7 @@ namespace ANML

Change::~Change()
{
if (m_whenCondition != NULL)
delete m_whenCondition;
delete m_whenCondition;

delete m_changeStmt;
}
Expand Down
3 changes: 1 addition & 2 deletions src/PLASMA/ConstraintEngine/base/DataType.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ DataType::~DataType()
{
m_id.remove();

if (m_baseDomain != NULL)
delete m_baseDomain;
delete m_baseDomain;
}

const DataTypeId DataType::getId() const { return m_id; }
Expand Down
6 changes: 2 additions & 4 deletions src/PLASMA/ConstraintEngine/component/Constraints.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1085,8 +1085,7 @@ EqualSumConstraint::EqualSumConstraint(const std::string& name,
if (canProveTrue)
boolDom.remove(false);
// Before it goes out of scope:
if (common != 0)
delete common;
delete common;
} //if !boolDom.isSingleton

// Whether the condition was singleton on entry to this function
Expand Down Expand Up @@ -1324,8 +1323,7 @@ void addToUnion(Domain **unionOfDomains,
}
} // for ( ; i < ARG_COUNT; i++)
// Don't need this below, so:
if (unionOfOthers != 0)
delete unionOfOthers;
delete unionOfOthers;
if (canProveTrue)
boolDom.remove(false);

Expand Down
9 changes: 3 additions & 6 deletions src/PLASMA/NDDL/component/Interpreter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1918,8 +1918,7 @@ DataRef ExprEnumdef::eval(EvalContext& context) const {

ExprVarDeclaration::~ExprVarDeclaration()
{
if (m_initValue != NULL)
delete m_initValue;
delete m_initValue;
}

const std::string& ExprVarDeclaration::getName() const { return m_name; }
Expand Down Expand Up @@ -2238,8 +2237,7 @@ void evalArgs(EvalContext& context,

ExprMethodCall::~ExprMethodCall()
{
if (m_varExpr != NULL)
delete m_varExpr;
delete m_varExpr;

for (unsigned int i=0;i<m_argExprs.size();i++)
delete m_argExprs[i];
Expand Down Expand Up @@ -2281,8 +2279,7 @@ void evalArgs(EvalContext& context,

ExprVariableMethod::~ExprVariableMethod()
{
if (m_varExpr != NULL)
delete m_varExpr;
delete m_varExpr;

for (unsigned int i=0;i<m_argExprs.size();i++)
delete m_argExprs[i];
Expand Down
3 changes: 1 addition & 2 deletions src/PLASMA/PlanDatabase/base/ObjectType.cc
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,7 @@ void* ObjectEvalContext::getElement(const std::string& name) const {

InterpretedObjectFactory::~InterpretedObjectFactory()
{
if (m_superCallExpr != NULL)
delete m_superCallExpr;
delete m_superCallExpr;

for (unsigned int i=0; i < m_constructorBody.size(); i++)
delete m_constructorBody[i];
Expand Down
6 changes: 2 additions & 4 deletions src/PLASMA/Resource/component/FlowProfile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,11 @@ private:
*/
template<typename FlowGraphType>
void initializeGraphs() {
if(m_lowerLevelGraph != NULL)
delete m_lowerLevelGraph;
delete m_lowerLevelGraph;
m_lowerLevelGraph = new FlowGraphType(m_dummySourceTransaction,
m_dummySinkTransaction, true);

if(m_upperLevelGraph != NULL)
delete m_upperLevelGraph;
delete m_upperLevelGraph;
m_upperLevelGraph = new FlowGraphType(m_dummySourceTransaction,
m_dummySinkTransaction, false);
}
Expand Down
3 changes: 1 addition & 2 deletions src/PLASMA/RulesEngine/base/RuleInstance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ RuleInstance::RuleInstance(const RuleInstanceId parent,
undo();

// If there is a guard domain, delete it
if(m_guardDomain != 0)
delete m_guardDomain;
delete m_guardDomain;

// Delete the guard listener if we are not in purge mode. Purge mode will handle the deletion
// of the constraint in the Constraint Engine. We can deactivate this constraint since it does not impose a restriction
Expand Down
3 changes: 1 addition & 2 deletions src/PLASMA/Solvers/component/OpenConditionDecisionPoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ SupportedOCDecisionPoint::~SupportedOCDecisionPoint()

m_choices.clear();

if (m_heuristic != NULL)
delete m_heuristic;
delete m_heuristic;
}

std::string SupportedOCDecisionPoint::toString() const
Expand Down
2 changes: 1 addition & 1 deletion src/PLASMA/Utils/base/Logger-log4cpp.hh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public:
//TODO - mcr - iterate through and delete loggers
}
delete loggers;
if( instance != NULL ) {delete instance;}
delete instance;
}

void readConfiguration( string configFilename ) {
Expand Down

0 comments on commit df62ebe

Please sign in to comment.