Remove superfluous pointer null checks

This commit is contained in:
QrchackOfficial 2017-06-05 01:52:55 +02:00 committed by ShadowNinja
parent 7bfd53ba58
commit 5cc8ad946e
10 changed files with 20 additions and 46 deletions

@ -490,10 +490,8 @@ void Client::step(float dtime)
MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(r.p); MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(r.p);
if (block) { if (block) {
// Delete the old mesh // Delete the old mesh
if (block->mesh != NULL) {
delete block->mesh; delete block->mesh;
block->mesh = NULL; block->mesh = NULL;
}
if (r.mesh) { if (r.mesh) {
minimap_mapblock = r.mesh->moveMinimapMapblock(); minimap_mapblock = r.mesh->moveMinimapMapblock();

@ -53,13 +53,10 @@ MainGameCallback *g_gamecallback = NULL;
ClientLauncher::~ClientLauncher() ClientLauncher::~ClientLauncher()
{ {
if (receiver)
delete receiver; delete receiver;
if (input)
delete input; delete input;
if (g_fontengine)
delete g_fontengine; delete g_fontengine;
if (device) if (device)

@ -3231,7 +3231,6 @@ void Game::processClientEvents(CameraOrientation *cam)
{ {
HudElement *e = player->removeHud(event.hudrm.id); HudElement *e = player->removeHud(event.hudrm.id);
if (e != NULL)
delete e; delete e;
} }
break; break;

@ -134,13 +134,8 @@ GUIFormSpecMenu::~GUIFormSpecMenu()
} }
delete m_selected_item; delete m_selected_item;
if (m_form_src != NULL) {
delete m_form_src; delete m_form_src;
}
if (m_text_dst != NULL) {
delete m_text_dst; delete m_text_dst;
}
} }
void GUIFormSpecMenu::removeChildren() void GUIFormSpecMenu::removeChildren()

@ -310,18 +310,14 @@ public:
// form_src is deleted by this GUIFormSpecMenu // form_src is deleted by this GUIFormSpecMenu
void setFormSource(IFormSource *form_src) void setFormSource(IFormSource *form_src)
{ {
if (m_form_src != NULL) {
delete m_form_src; delete m_form_src;
}
m_form_src = form_src; m_form_src = form_src;
} }
// text_dst is deleted by this GUIFormSpecMenu // text_dst is deleted by this GUIFormSpecMenu
void setTextDest(TextDest *text_dst) void setTextDest(TextDest *text_dst)
{ {
if (m_text_dst != NULL) {
delete m_text_dst; delete m_text_dst;
}
m_text_dst = text_dst; m_text_dst = text_dst;
} }

@ -112,11 +112,8 @@ void ItemDefinition::reset()
stack_max = 99; stack_max = 99;
usable = false; usable = false;
liquids_pointable = false; liquids_pointable = false;
if(tool_capabilities)
{
delete tool_capabilities; delete tool_capabilities;
tool_capabilities = NULL; tool_capabilities = NULL;
}
groups.clear(); groups.clear();
sound_place = SimpleSoundSpec(); sound_place = SimpleSoundSpec();
sound_place_failed = SimpleSoundSpec(); sound_place_failed = SimpleSoundSpec();

@ -97,15 +97,11 @@ MapBlock::~MapBlock()
{ {
//MutexAutoLock lock(mesh_mutex); //MutexAutoLock lock(mesh_mutex);
if(mesh)
{
delete mesh; delete mesh;
mesh = NULL; mesh = NULL;
} }
}
#endif #endif
if(data)
delete[] data; delete[] data;
} }

@ -40,7 +40,6 @@ CachedMapBlockData::~CachedMapBlockData()
{ {
assert(refcount_from_queue == 0); assert(refcount_from_queue == 0);
if (data)
delete[] data; delete[] data;
} }
@ -60,7 +59,6 @@ QueuedMeshUpdate::QueuedMeshUpdate():
QueuedMeshUpdate::~QueuedMeshUpdate() QueuedMeshUpdate::~QueuedMeshUpdate()
{ {
if (data)
delete data; delete data;
} }

@ -97,7 +97,6 @@ public:
private: private:
void drop() void drop()
{ {
if(data)
delete[] data; delete[] data;
} }
T *data; T *data;
@ -214,7 +213,6 @@ private:
(*refcount)--; (*refcount)--;
if(*refcount == 0) if(*refcount == 0)
{ {
if(data)
delete[] data; delete[] data;
delete refcount; delete refcount;
} }

@ -861,7 +861,7 @@ err_exit:
mpz_clear(usr->a); mpz_clear(usr->a);
mpz_clear(usr->A); mpz_clear(usr->A);
mpz_clear(usr->S); mpz_clear(usr->S);
if (usr->ng) delete_ng(usr->ng); delete_ng(usr->ng);
srp_free(usr->username); srp_free(usr->username);
srp_free(usr->username_verifier); srp_free(usr->username_verifier);
if (usr->password) { if (usr->password) {