Skip to content

Commit b48f410

Browse files
author
Hieu Hoang
committed
don't check object pointer before deleting /Markus Elfring
1 parent c48d8b5 commit b48f410

File tree

5 files changed

+10
-17
lines changed

5 files changed

+10
-17
lines changed

mert/FeatureStats.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,8 @@ FeatureStats::FeatureStats(const size_t size)
181181

182182
FeatureStats::~FeatureStats()
183183
{
184-
if (m_array) {
185-
delete [] m_array;
186-
m_array = NULL;
187-
}
184+
delete [] m_array;
185+
m_array = NULL;
188186
}
189187

190188
void FeatureStats::Copy(const FeatureStats &stats)

mert/ScoreStats.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ ScoreStats::ScoreStats(const size_t size)
3535

3636
ScoreStats::~ScoreStats()
3737
{
38-
if (m_array) {
39-
delete [] m_array;
40-
m_array = NULL;
41-
}
38+
delete [] m_array;
39+
m_array = NULL;
4240
}
4341

4442
void ScoreStats::Copy(const ScoreStats &stats)
@@ -157,4 +155,4 @@ bool operator==(const ScoreStats& s1, const ScoreStats& s2)
157155
return true;
158156
}
159157

160-
}
158+
}

mert/Singleton.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ class Singleton
2121
}
2222

2323
static void Delete() {
24-
if (m_instance) {
25-
delete m_instance;
26-
m_instance = NULL;
27-
}
24+
delete m_instance;
25+
m_instance = NULL;
2826
}
2927

3028
private:

moses/FF/LexicalReordering/LexicalReordering.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ LexicalReordering::LexicalReordering(const std::string &line)
5252

5353
LexicalReordering::~LexicalReordering()
5454
{
55-
if(m_table)
56-
delete m_table;
55+
delete m_table;
5756
delete m_configuration;
5857
}
5958

moses/TranslationModel/DynSAInclude/onlineRLM.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ class OnlineRLM: public PerfectHash<T>
4343
alpha_[i] = i * log10(0.4);
4444
}
4545
~OnlineRLM() {
46-
if(alpha_) delete[] alpha_;
46+
delete[] alpha_;
4747
if(bAdapting_) delete vocab_;
4848
else vocab_ = NULL;
49-
if(cache_) delete cache_;
49+
delete cache_;
5050
delete bPrefix_;
5151
delete bHit_;
5252
}

0 commit comments

Comments
 (0)