Skip to content

Commit

Permalink
Merge branch 'elfring-Remove_unnecessary_null_pointer_checks'
Browse files Browse the repository at this point in the history
  • Loading branch information
jxyang committed Apr 21, 2019
2 parents 4f540a9 + 52e36d8 commit c7e6a90
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/DepthSpec.h
Expand Up @@ -91,14 +91,14 @@ enum dType {

#define DEPTH_GUARD_BY_DEPTH_RETURN_DEL1(d, t1, rv) \
if (DepthSpec::depth_guard_by_depth(d) != GOOD_DEPTH) { \
if (t1) delete t1; \
delete t1; \
return rv; \
}

#define DEPTH_GUARD_BY_DEPTH_RETURN_DEL2(d, t1, t2, rv) \
if (DepthSpec::depth_guard_by_depth(d) != GOOD_DEPTH) { \
if (t1) delete t1; \
if (t2) delete t2; \
delete t1; \
delete t2; \
return rv; \
}

Expand Down
3 changes: 1 addition & 2 deletions src/Enumerator.h
Expand Up @@ -148,8 +148,7 @@ Enumerator<Name>::~Enumerator()
{
typename map<Name, EnumObject*>::iterator i;
for (i = objs_.begin(); i != objs_.end(); ++i) {
if ((*i).second != NULL)
delete (*i).second;
delete i->second;
}
objs_.clear();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Function.cpp
Expand Up @@ -874,10 +874,7 @@ OutputFunctions(std::ostream &out)
int
Function::deleteFunction(Function* func)
{
if (func) {
delete func;
func = 0;
}
delete func;
return 0;
}

Expand Down
10 changes: 3 additions & 7 deletions src/Probabilities.cpp
Expand Up @@ -191,9 +191,7 @@ GroupProbElem::~GroupProbElem()
{
std::map<ProbName, SingleProbElem*>::iterator i;
for (i = probs_.begin(); i != probs_.end(); ++i) {
SingleProbElem *elem = (*i).second;
assert(elem);
delete elem;
delete i->second;
}
probs_.clear();
}
Expand Down Expand Up @@ -380,10 +378,8 @@ Probabilities::GetInstance()
void
Probabilities::DestroyInstance()
{
if (Probabilities::instance_) {
delete Probabilities::instance_;
Probabilities::instance_ = NULL;
}
delete instance_;
instance_ = NULL;
}

void
Expand Down
4 changes: 1 addition & 3 deletions src/RandomNumber.cpp
Expand Up @@ -174,9 +174,7 @@ RandomNumber::doFinalization()
for (unsigned int i = 0; i < count; ++i) {
RNDNUM_GENERATOR rImpl = static_cast<RNDNUM_GENERATOR>(i);
generator = instance_->generators_[rImpl];
if (generator != NULL) {
delete generator;
}
delete generator;
}
delete instance_;
}
Expand Down
5 changes: 1 addition & 4 deletions src/Variable.cpp
Expand Up @@ -473,10 +473,7 @@ Variable::~Variable(void)
for(i = field_vars.begin(); i != field_vars.end(); ++i)
delete (*i);
field_vars.clear();
if (init) {
delete init;
init = NULL;
}
delete init;
}

// --------------------------------------------------------------
Expand Down

0 comments on commit c7e6a90

Please sign in to comment.