[12079] Remove some redundant explicit NULL checks for pointers before delete or delete[] calls since this check is done implicitly when deleting

Signed-off-by: stfx <stfx@hotmail.de>
This commit is contained in:
Machiavelli 2012-08-03 14:29:04 +02:00 committed by stfx
parent 4a684fe630
commit 21a3ee9267
28 changed files with 80 additions and 160 deletions

View file

@ -35,7 +35,6 @@ Bag::Bag(): Item()
Bag::~Bag()
{
for (int i = 0; i < MAX_BAG_SIZE; ++i)
if (m_bagslot[i])
delete m_bagslot[i];
}
@ -103,12 +102,10 @@ bool Bag::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid)
for (int i = 0; i < MAX_BAG_SIZE; ++i)
{
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (i * 2), ObjectGuid());
if (m_bagslot[i])
{
delete m_bagslot[i];
m_bagslot[i] = NULL;
}
}
return true;
}

View file

@ -732,7 +732,6 @@ bool Creature::AIM_Initialize()
CreatureAI* oldAI = i_AI;
i_motionMaster.Initialize();
i_AI = FactorySelector::selectAI(this);
if (oldAI)
delete oldAI;
return true;
}

View file

@ -117,19 +117,10 @@ bool GridMap::loadData(char* filename)
void GridMap::unloadData()
{
if (m_area_map)
delete[] m_area_map;
if (m_V9)
delete[] m_V9;
if (m_V8)
delete[] m_V8;
if (m_liquid_type)
delete[] m_liquid_type;
if (m_liquid_map)
delete[] m_liquid_map;
m_area_map = NULL;

View file

@ -109,7 +109,6 @@ Group::~Group()
itr2->second.state->RemoveGroup(this);
// Sub group counters clean up
if (m_subGroupsCounts)
delete[] m_subGroupsCounts;
}

View file

@ -48,11 +48,8 @@ Map::~Map()
if (m_persistentState)
m_persistentState->SetUsedByMapState(NULL); // field pointer can be deleted after this
if (i_data)
{
delete i_data;
i_data = NULL;
}
// unload instance specific navigation data
MMAP::MMapFactory::createOrGetMMapManager()->unloadMapInstance(m_TerrainData->GetMapId(), GetInstanceId());

View file

@ -66,19 +66,13 @@ namespace MMAP
}
void MMapFactory::clear()
{
if (g_mmapDisabledIds)
{
delete g_mmapDisabledIds;
g_mmapDisabledIds = NULL;
}
if (g_MMapManager)
{
delete g_MMapManager;
g_mmapDisabledIds = NULL;
g_MMapManager = NULL;
}
}
// ######################## MMapManager ########################
MMapManager::~MMapManager()

View file

@ -71,13 +71,8 @@ Object::~Object()
MANGOS_ASSERT(false);
}
if (m_uint32Values)
{
// DEBUG_LOG("Object desctr 1 check (%p)",(void*)this);
delete[] m_uint32Values;
delete[] m_uint32Values_mirror;
// DEBUG_LOG("Object desctr 2 check (%p)",(void*)this);
}
}
void Object::_InitValues()

View file

@ -312,10 +312,9 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
if (result)
{
if (m_declinedname)
delete m_declinedname;
m_declinedname = new DeclinedName;
Field* fields2 = result->Fetch();
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
m_declinedname->name[i] = fields2[i].GetCppString();

View file

@ -570,7 +570,6 @@ Player::~Player()
// Note: buy back item already deleted from DB when player was saved
for (int i = 0; i < PLAYER_SLOTS_COUNT; ++i)
{
if (m_items[i])
delete m_items[i];
}
CleanupChannels();
@ -590,7 +589,6 @@ Player::~Player()
}
for (size_t x = 0; x < ItemSetEff.size(); ++x)
if (ItemSetEff[x])
delete ItemSetEff[x];
// clean up player-instance binds, may unload some instance saves
@ -15338,10 +15336,9 @@ void Player::_LoadDeclinedNames(QueryResult* result)
if (!result)
return;
if (m_declinedname)
delete m_declinedname;
m_declinedname = new DeclinedName;
Field* fields = result->Fetch();
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
m_declinedname->name[i] = fields[i].GetCppString();
@ -15580,12 +15577,9 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder)
SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid());
SetVisibleItemSlot(slot, NULL);
if (m_items[slot])
{
delete m_items[slot];
m_items[slot] = NULL;
}
}
DEBUG_FILTER_LOG(LOG_FILTER_PLAYER_STATS, "Load Basic value of player %s is: ", m_name.c_str());
outDebugStatsValues();

View file

@ -30,7 +30,6 @@ class UpdateMask
~UpdateMask()
{
if (mUpdateMask)
delete[] mUpdateMask;
}
@ -56,7 +55,6 @@ class UpdateMask
void SetCount(uint32 valuesCount)
{
if (mUpdateMask)
delete[] mUpdateMask;
mCount = valuesCount;

View file

@ -438,7 +438,6 @@ void WaypointManager::Unload()
void WaypointManager::_clearPath(WaypointPath& path)
{
for (WaypointPath::const_iterator itr = path.begin(); itr != path.end(); ++itr)
if (itr->behavior)
delete itr->behavior;
path.clear();
}

View file

@ -117,7 +117,6 @@ WorldSocket::WorldSocket(void) :
WorldSocket::~WorldSocket(void)
{
if (m_RecvWPct)
delete m_RecvWPct;
if (m_OutBuffer)

View file

@ -81,7 +81,6 @@ class ReactorRunnable : protected ACE_Task_Base
Stop();
Wait();
if (m_Reactor)
delete m_Reactor;
}
@ -216,10 +215,7 @@ WorldSocketMgr::WorldSocketMgr():
WorldSocketMgr::~WorldSocketMgr()
{
if (m_NetThreads)
delete[] m_NetThreads;
if (m_Acceptor)
delete m_Acceptor;
}

View file

@ -121,16 +121,11 @@ namespace VMAP
//===============================================
// delete all internal data structures
void VMapFactory::clear()
{
if (iIgnoreSpellIds)
{
delete iIgnoreSpellIds;
iIgnoreSpellIds = NULL;
}
if (gVMapManager)
{
delete gVMapManager;
iIgnoreSpellIds = NULL;
gVMapManager = NULL;
}
}
}

View file

@ -169,11 +169,7 @@ uint8* BigNumber::AsByteArray(int minSize, bool reverse)
{
int length = (minSize >= GetNumBytes()) ? minSize : GetNumBytes();
if (_array)
{
delete[] _array;
_array = NULL;
}
_array = new uint8[length];
// If we need more bytes than length of BigNumber set the rest to 0

View file

@ -30,13 +30,8 @@ DBCFileLoader::DBCFileLoader()
bool DBCFileLoader::Load(const char* filename, const char* fmt)
{
uint32 header;
if (data)
{
delete[] data;
data = NULL;
}
FILE* f = fopen(filename, "rb");
if (!f)return false;
@ -91,9 +86,7 @@ bool DBCFileLoader::Load(const char* filename, const char* fmt)
DBCFileLoader::~DBCFileLoader()
{
if (data)
delete[] data;
if (fieldsOffset)
delete[] fieldsOffset;
}

View file

@ -150,24 +150,17 @@ bool Database::Initialize(const char* infoString, int nConns /*= 1*/)
void Database::StopServer()
{
HaltDelayThread();
/*Delete objects*/
if (m_pResultQueue)
{
delete m_pResultQueue;
m_pResultQueue = NULL;
}
if (m_pAsyncConn)
{
delete m_pResultQueue;
delete m_pAsyncConn;
m_pResultQueue = NULL;
m_pAsyncConn = NULL;
}
for (size_t i = 0; i < m_pQueryConnections.size(); ++i)
delete m_pQueryConnections[i];
m_pQueryConnections.clear();
}
SqlDelayThread* Database::CreateDelayThread()
@ -643,10 +636,7 @@ SqlTransaction* Database::TransHelper::detach()
}
void Database::TransHelper::reset()
{
if (m_pTrans)
{
delete m_pTrans;
m_pTrans = NULL;
}
}

View file

@ -58,12 +58,9 @@ bool QueryResultMysql::NextRow()
}
void QueryResultMysql::EndQuery()
{
if (mCurrentRow)
{
delete[] mCurrentRow;
mCurrentRow = 0;
}
if (mResult)
{

View file

@ -62,12 +62,9 @@ bool QueryResultPostgre::NextRow()
}
void QueryResultPostgre::EndQuery()
{
if (mCurrentRow)
{
delete[] mCurrentRow;
mCurrentRow = 0;
}
if (mResult)
{

View file

@ -195,7 +195,6 @@ SqlQueryHolder::~SqlQueryHolder()
if (m_queries[i].first != NULL)
{
delete[] (const_cast<char*>(m_queries[i].first));
if (m_queries[i].second)
delete m_queries[i].second;
}
}

View file

@ -41,11 +41,8 @@ SqlStatement& SqlStatement::operator=(const SqlStatement& index)
m_index = index.m_index;
m_pDB = index.m_pDB;
if (m_pParams)
{
delete m_pParams;
m_pParams = NULL;
}
if (index.m_pParams)
m_pParams = new SqlStmtParameters(*(index.m_pParams));

View file

@ -215,7 +215,6 @@ Thread* Thread::current()
_thread->m_hThreadHandle = Thread::currentHandle();
Thread* _oldValue = m_ThreadStorage.ts_object(_thread);
if (_oldValue)
delete _oldValue;
}

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12078"
#define REVISION_NR "12079"
#endif // __REVISION_NR_H__