Skip to content

Commit f53d1c5

Browse files
committed
Remove unnecessary null pointer checks (Fix #5)
1 parent dce6e6f commit f53d1c5

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

libmc/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
)
1515

1616
__VERSION__ = '0.5.0'
17-
__version__ = "c5566db"
18-
__author__ = "mckelvin"
19-
__email__ = "kelvin0576@gmail.com"
20-
__date__ = "Sat Apr 4 13:07:39 2015 +0800"
17+
__version__ = "v0.5.0-3-gdce6e6f"
18+
__author__ = "PAN, Myautsai"
19+
__email__ = "[email protected].com"
20+
__date__ = "Sun Apr 5 11:48:29 2015 +0800"
2121

2222

2323
class Client(PyClient):

src/ConnectionPool.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ int ConnectionPool::s_pollTimeout = MC_DEFAULT_POLL_TIMEOUT;
3434

3535

3636
ConnectionPool::~ConnectionPool() {
37-
if (m_conns != NULL) {
38-
delete[] m_conns;
39-
m_conns = NULL;
40-
}
37+
delete[] m_conns;
38+
m_conns = NULL;
4139
}
4240

4341

@@ -64,11 +62,8 @@ void ConnectionPool::setHashFunction(hash_function_options_t fn_opt) {
6462

6563
int ConnectionPool::init(const char* const * hosts, const uint32_t* ports, const size_t n,
6664
const uint32_t* weights) {
67-
if (m_conns != NULL) {
68-
delete[] m_conns;
69-
m_conns = NULL;
70-
m_connSelector.reset();
71-
}
65+
delete[] m_conns;
66+
m_connSelector.reset();
7267
int rv = 0;
7368
m_nConns = n;
7469
m_conns = new Connection[m_nConns];

src/DataBlock.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ size_t DataBlock::s_minCapacity(MIN_DATABLOCK_CAPACITY);
3232

3333

3434
DataBlock::~DataBlock() {
35-
if (m_data != NULL) {
36-
delete[] m_data;
37-
}
35+
delete[] m_data;
3836
}
3937

4038

src/Result.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ RetrievalResult::RetrievalResult(const RetrievalResult& other) {
3131

3232

3333
RetrievalResult::~RetrievalResult() {
34-
if (key.size() > 1 && m_inner.key != NULL) { // copy happened
34+
if (key.size() > 1) { // copy happened
3535
delete[] m_inner.key;
3636
}
37-
if (data_block.size() > 1 && m_inner.data_block != NULL) {
37+
if (data_block.size() > 1) {
3838
delete[] m_inner.data_block;
3939
}
4040
freeTokenData(key);
@@ -69,7 +69,7 @@ LineResult::LineResult(const LineResult& other) {
6969

7070

7171
LineResult::~LineResult() {
72-
if (this->line.size() > 1 && this->m_inner != NULL) {
72+
if (this->line.size() > 1) {
7373
delete[] this->m_inner;
7474
}
7575
freeTokenData(this->line);

0 commit comments

Comments
 (0)