Remove some redundant explicit NULL checks for pointers before ´delete´ or ´delete[]´ calls since this check is done implicitly when deleting.
Also fixes a memory leak in .reload creature_template command --HG-- branch : trunk
This commit is contained in:
@@ -122,15 +122,10 @@ namespace VMAP
|
|||||||
// delete all internal data structures
|
// delete all internal data structures
|
||||||
void VMapFactory::clear()
|
void VMapFactory::clear()
|
||||||
{
|
{
|
||||||
if(iIgnoreSpellIds)
|
delete iIgnoreSpellIds;
|
||||||
{
|
iIgnoreSpellIds = NULL;
|
||||||
delete iIgnoreSpellIds;
|
|
||||||
iIgnoreSpellIds = NULL;
|
delete gVMapManager;
|
||||||
}
|
gVMapManager = NULL;
|
||||||
if(gVMapManager)
|
|
||||||
{
|
|
||||||
delete gVMapManager;
|
|
||||||
gVMapManager = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -795,24 +795,21 @@ bool ChatHandler::HandleReloadCreatureTemplateCommand(const char* args)
|
|||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
if (const char* temp = fields[9].GetString())
|
if (const char* temp = fields[9].GetString())
|
||||||
{
|
{
|
||||||
if (cInfo->Name)
|
delete[] cInfo->Name;
|
||||||
delete cInfo->Name;
|
|
||||||
len = strlen(temp)+1;
|
len = strlen(temp)+1;
|
||||||
const_cast<CreatureInfo*>(cInfo)->Name = new char[len];
|
const_cast<CreatureInfo*>(cInfo)->Name = new char[len];
|
||||||
strncpy(cInfo->Name, temp, len);
|
strncpy(cInfo->Name, temp, len);
|
||||||
}
|
}
|
||||||
if (const char* temp = fields[10].GetString())
|
if (const char* temp = fields[10].GetString())
|
||||||
{
|
{
|
||||||
if (cInfo->SubName)
|
delete[] cInfo->SubName;
|
||||||
delete cInfo->SubName;
|
|
||||||
len = strlen(temp)+1;
|
len = strlen(temp)+1;
|
||||||
const_cast<CreatureInfo*>(cInfo)->SubName = new char[len];
|
const_cast<CreatureInfo*>(cInfo)->SubName = new char[len];
|
||||||
strncpy(cInfo->SubName, temp, len);
|
strncpy(cInfo->SubName, temp, len);
|
||||||
}
|
}
|
||||||
if (const char* temp = fields[11].GetString())
|
if (const char* temp = fields[11].GetString())
|
||||||
{
|
{
|
||||||
if (cInfo->IconName)
|
delete[] cInfo->IconName;
|
||||||
delete cInfo->IconName;
|
|
||||||
len = strlen(temp)+1;
|
len = strlen(temp)+1;
|
||||||
const_cast<CreatureInfo*>(cInfo)->IconName = new char[len];
|
const_cast<CreatureInfo*>(cInfo)->IconName = new char[len];
|
||||||
strncpy(cInfo->IconName, temp, len);
|
strncpy(cInfo->IconName, temp, len);
|
||||||
@@ -871,8 +868,7 @@ bool ChatHandler::HandleReloadCreatureTemplateCommand(const char* args)
|
|||||||
const_cast<CreatureInfo*>(cInfo)->maxgold = fields[63].GetUInt32();
|
const_cast<CreatureInfo*>(cInfo)->maxgold = fields[63].GetUInt32();
|
||||||
if (const char* temp = fields[64].GetString())
|
if (const char* temp = fields[64].GetString())
|
||||||
{
|
{
|
||||||
if (cInfo->AIName)
|
delete[] cInfo->AIName;
|
||||||
delete cInfo->AIName;
|
|
||||||
len = strlen(temp)+1;
|
len = strlen(temp)+1;
|
||||||
const_cast<CreatureInfo*>(cInfo)->AIName = new char[len];
|
const_cast<CreatureInfo*>(cInfo)->AIName = new char[len];
|
||||||
strncpy(const_cast<char*>(cInfo->AIName), temp, len);
|
strncpy(const_cast<char*>(cInfo->AIName), temp, len);
|
||||||
|
|||||||
@@ -235,8 +235,8 @@ inline void LoadDBC(uint32& availableDbcLocales,barGoLink& bar, StoreProblemList
|
|||||||
else
|
else
|
||||||
errlist.push_back(dbc_filename);
|
errlist.push_back(dbc_filename);
|
||||||
}
|
}
|
||||||
if (sql)
|
|
||||||
delete sql;
|
delete sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadDBCStores(const std::string& dataPath)
|
void LoadDBCStores(const std::string& dataPath)
|
||||||
|
|||||||
@@ -46,8 +46,7 @@ LFGQueue::~LFGQueue()
|
|||||||
|
|
||||||
void LFGQueue::AddToQueue(uint64 guid, LfgQueueInfo* pqInfo)
|
void LFGQueue::AddToQueue(uint64 guid, LfgQueueInfo* pqInfo)
|
||||||
{
|
{
|
||||||
if (LfgQueueInfo* qInfo = m_LfgQueue[guid])
|
delete m_LfgQueue[guid];
|
||||||
delete qInfo;
|
|
||||||
m_LfgQueue[guid] = pqInfo;
|
m_LfgQueue[guid] = pqInfo;
|
||||||
// ATM will only add it to the queue... No find group implementation... yet (on purpose)
|
// ATM will only add it to the queue... No find group implementation... yet (on purpose)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,11 +171,8 @@ Creature::~Creature()
|
|||||||
{
|
{
|
||||||
m_vendorItemCounts.clear();
|
m_vendorItemCounts.clear();
|
||||||
|
|
||||||
if (i_AI)
|
delete i_AI;
|
||||||
{
|
i_AI = NULL;
|
||||||
delete i_AI;
|
|
||||||
i_AI = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (m_uint32Values)
|
//if (m_uint32Values)
|
||||||
// sLog.outError("Deconstruct Creature Entry = %u", GetEntry());
|
// sLog.outError("Deconstruct Creature Entry = %u", GetEntry());
|
||||||
@@ -721,7 +718,7 @@ bool Creature::AIM_Initialize(CreatureAI* ai)
|
|||||||
Motion_Initialize();
|
Motion_Initialize();
|
||||||
|
|
||||||
i_AI = ai ? ai : FactorySelector::selectAI(this);
|
i_AI = ai ? ai : FactorySelector::selectAI(this);
|
||||||
if (oldAI) delete oldAI;
|
delete oldAI;
|
||||||
IsAIEnabled = true;
|
IsAIEnabled = true;
|
||||||
i_AI->InitializeAI();
|
i_AI->InitializeAI();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -117,11 +117,8 @@ bool Bag::LoadFromDB(uint32 guid, uint64 owner_guid, QueryResult_AutoPtr result)
|
|||||||
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
|
for (uint8 i = 0; i < MAX_BAG_SIZE; ++i)
|
||||||
{
|
{
|
||||||
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0);
|
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + (i*2), 0);
|
||||||
if (m_bagslot[i])
|
delete m_bagslot[i];
|
||||||
{
|
m_bagslot[i] = NULL;
|
||||||
delete m_bagslot[i];
|
|
||||||
m_bagslot[i] = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -113,13 +113,9 @@ Object::~Object()
|
|||||||
ObjectAccessor::Instance().RemoveUpdateObject(this);
|
ObjectAccessor::Instance().RemoveUpdateObject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_uint32Values)
|
delete [] m_uint32Values;
|
||||||
{
|
delete [] m_uint32Values_mirror;
|
||||||
//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()
|
void Object::_InitValues()
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ class UpdateMask
|
|||||||
|
|
||||||
~UpdateMask()
|
~UpdateMask()
|
||||||
{
|
{
|
||||||
if (mUpdateMask)
|
delete [] mUpdateMask;
|
||||||
delete [] mUpdateMask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetBit (uint32 index)
|
void SetBit (uint32 index)
|
||||||
@@ -58,8 +57,7 @@ class UpdateMask
|
|||||||
|
|
||||||
void SetCount (uint32 valuesCount)
|
void SetCount (uint32 valuesCount)
|
||||||
{
|
{
|
||||||
if (mUpdateMask)
|
delete [] mUpdateMask;
|
||||||
delete [] mUpdateMask;
|
|
||||||
|
|
||||||
mCount = valuesCount;
|
mCount = valuesCount;
|
||||||
mBlocks = (valuesCount + 31) / 32;
|
mBlocks = (valuesCount + 31) / 32;
|
||||||
|
|||||||
@@ -324,9 +324,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
|
|||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
if (m_declinedname)
|
delete m_declinedname;
|
||||||
delete m_declinedname;
|
|
||||||
|
|
||||||
m_declinedname = new DeclinedName;
|
m_declinedname = new DeclinedName;
|
||||||
Field *fields2 = result->Fetch();
|
Field *fields2 = result->Fetch();
|
||||||
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
||||||
|
|||||||
@@ -514,10 +514,7 @@ Player::~Player ()
|
|||||||
|
|
||||||
// Note: buy back item already deleted from DB when player was saved
|
// Note: buy back item already deleted from DB when player was saved
|
||||||
for (uint8 i = 0; i < PLAYER_SLOTS_COUNT; ++i)
|
for (uint8 i = 0; i < PLAYER_SLOTS_COUNT; ++i)
|
||||||
{
|
delete m_items[i];
|
||||||
if (m_items[i])
|
|
||||||
delete m_items[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
|
for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
|
||||||
delete itr->second;
|
delete itr->second;
|
||||||
@@ -539,8 +536,7 @@ Player::~Player ()
|
|||||||
delete PlayerTalkClass;
|
delete PlayerTalkClass;
|
||||||
|
|
||||||
for (size_t x = 0; x < ItemSetEff.size(); x++)
|
for (size_t x = 0; x < ItemSetEff.size(); x++)
|
||||||
if (ItemSetEff[x])
|
delete ItemSetEff[x];
|
||||||
delete ItemSetEff[x];
|
|
||||||
|
|
||||||
delete m_declinedname;
|
delete m_declinedname;
|
||||||
delete m_runes;
|
delete m_runes;
|
||||||
@@ -15565,9 +15561,7 @@ void Player::_LoadDeclinedNames(QueryResult_AutoPtr result)
|
|||||||
if (!result)
|
if (!result)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_declinedname)
|
delete m_declinedname;
|
||||||
delete m_declinedname;
|
|
||||||
|
|
||||||
m_declinedname = new DeclinedName;
|
m_declinedname = new DeclinedName;
|
||||||
Field *fields = result->Fetch();
|
Field *fields = result->Fetch();
|
||||||
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
||||||
@@ -15817,11 +15811,8 @@ bool Player::LoadFromDB(uint32 guid, SqlQueryHolder *holder)
|
|||||||
SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0);
|
SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0);
|
||||||
SetVisibleItemSlot(slot, NULL);
|
SetVisibleItemSlot(slot, NULL);
|
||||||
|
|
||||||
if (m_items[slot])
|
delete m_items[slot];
|
||||||
{
|
m_items[slot] = NULL;
|
||||||
delete m_items[slot];
|
|
||||||
m_items[slot] = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sLog.outDebug("Load Basic value of player %s is: ", m_name.c_str());
|
sLog.outDebug("Load Basic value of player %s is: ", m_name.c_str());
|
||||||
|
|||||||
@@ -201,10 +201,8 @@ Unit::~Unit()
|
|||||||
RemoveAllDynObjects();
|
RemoveAllDynObjects();
|
||||||
_DeleteRemovedAuras();
|
_DeleteRemovedAuras();
|
||||||
|
|
||||||
if (m_charmInfo)
|
delete m_charmInfo;
|
||||||
delete m_charmInfo;
|
delete m_vehicleKit;
|
||||||
if (m_vehicleKit)
|
|
||||||
delete m_vehicleKit;
|
|
||||||
|
|
||||||
assert(!m_attacking);
|
assert(!m_attacking);
|
||||||
assert(m_attackers.empty());
|
assert(m_attackers.empty());
|
||||||
@@ -13297,8 +13295,7 @@ void Unit::UpdateCharmAI()
|
|||||||
{
|
{
|
||||||
if (!isCharmed())
|
if (!isCharmed())
|
||||||
{
|
{
|
||||||
if (i_AI)
|
delete i_AI;
|
||||||
delete i_AI;
|
|
||||||
i_AI = i_disabledAI;
|
i_AI = i_disabledAI;
|
||||||
i_disabledAI = NULL;
|
i_disabledAI = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3419,7 +3419,7 @@ void ObjectMgr::LoadGuilds()
|
|||||||
!newGuild->LoadMembersFromDB(guildMembersResult) ||
|
!newGuild->LoadMembersFromDB(guildMembersResult) ||
|
||||||
!newGuild->LoadBankRightsFromDB(guildBankTabRightsResult) ||
|
!newGuild->LoadBankRightsFromDB(guildBankTabRightsResult) ||
|
||||||
!newGuild->CheckGuildStructure()
|
!newGuild->CheckGuildStructure()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
newGuild->Disband();
|
newGuild->Disband();
|
||||||
delete newGuild;
|
delete newGuild;
|
||||||
|
|||||||
@@ -79,8 +79,7 @@ Group::~Group()
|
|||||||
itr2->second.save->RemoveGroup(this);
|
itr2->second.save->RemoveGroup(this);
|
||||||
|
|
||||||
// Sub group counters clean up
|
// Sub group counters clean up
|
||||||
if (m_subGroupsCounts)
|
delete[] m_subGroupsCounts;
|
||||||
delete[] m_subGroupsCounts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Group::Create(const uint64 &guid, const char * name)
|
bool Group::Create(const uint64 &guid, const char * name)
|
||||||
|
|||||||
@@ -1241,11 +1241,11 @@ bool GridMap::loadData(char *filename)
|
|||||||
|
|
||||||
void GridMap::unloadData()
|
void GridMap::unloadData()
|
||||||
{
|
{
|
||||||
if (m_area_map) delete[] m_area_map;
|
delete[] m_area_map;
|
||||||
if (m_V9) delete[] m_V9;
|
delete[] m_V9;
|
||||||
if (m_V8) delete[] m_V8;
|
delete[] m_V8;
|
||||||
if (m_liquid_type) delete[] m_liquid_type;
|
delete[] m_liquid_type;
|
||||||
if (m_liquid_map) delete[] m_liquid_map;
|
delete[] m_liquid_map;
|
||||||
m_area_map = NULL;
|
m_area_map = NULL;
|
||||||
m_V9 = NULL;
|
m_V9 = NULL;
|
||||||
m_V8 = NULL;
|
m_V8 = NULL;
|
||||||
@@ -2350,11 +2350,8 @@ InstanceMap::InstanceMap(uint32 id, time_t expiry, uint32 InstanceId, uint8 Spaw
|
|||||||
|
|
||||||
InstanceMap::~InstanceMap()
|
InstanceMap::~InstanceMap()
|
||||||
{
|
{
|
||||||
if (i_data)
|
delete i_data;
|
||||||
{
|
i_data = NULL;
|
||||||
delete i_data;
|
|
||||||
i_data = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceMap::InitVisibilityDistance()
|
void InstanceMap::InitVisibilityDistance()
|
||||||
|
|||||||
@@ -120,8 +120,7 @@ m_LastPingTime(ACE_Time_Value::zero)
|
|||||||
|
|
||||||
WorldSocket::~WorldSocket (void)
|
WorldSocket::~WorldSocket (void)
|
||||||
{
|
{
|
||||||
if (m_RecvWPct)
|
delete m_RecvWPct;
|
||||||
delete m_RecvWPct;
|
|
||||||
|
|
||||||
if (m_OutBuffer)
|
if (m_OutBuffer)
|
||||||
m_OutBuffer->release();
|
m_OutBuffer->release();
|
||||||
|
|||||||
@@ -84,8 +84,7 @@ class ReactorRunnable : protected ACE_Task_Base
|
|||||||
Stop();
|
Stop();
|
||||||
Wait();
|
Wait();
|
||||||
|
|
||||||
if (m_Reactor)
|
delete m_Reactor;
|
||||||
delete m_Reactor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stop()
|
void Stop()
|
||||||
@@ -220,11 +219,8 @@ WorldSocketMgr::WorldSocketMgr() :
|
|||||||
|
|
||||||
WorldSocketMgr::~WorldSocketMgr()
|
WorldSocketMgr::~WorldSocketMgr()
|
||||||
{
|
{
|
||||||
if (m_NetThreads)
|
delete [] m_NetThreads;
|
||||||
delete [] m_NetThreads;
|
delete m_Acceptor;
|
||||||
|
|
||||||
if (m_Acceptor)
|
|
||||||
delete m_Acceptor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|||||||
@@ -387,8 +387,7 @@ AuraEffect::AuraEffect(Aura * base, uint8 effIndex, int32 *baseAmount, Unit * ca
|
|||||||
|
|
||||||
AuraEffect::~AuraEffect()
|
AuraEffect::~AuraEffect()
|
||||||
{
|
{
|
||||||
if (m_spellmod)
|
delete m_spellmod;
|
||||||
delete m_spellmod;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuraEffect::GetTargetList(std::list<Unit *> & targetList) const
|
void AuraEffect::GetTargetList(std::list<Unit *> & targetList) const
|
||||||
|
|||||||
@@ -342,8 +342,7 @@ Aura::~Aura()
|
|||||||
{
|
{
|
||||||
// free effects memory
|
// free effects memory
|
||||||
for (uint8 i = 0 ; i < MAX_SPELL_EFFECTS; ++i)
|
for (uint8 i = 0 ; i < MAX_SPELL_EFFECTS; ++i)
|
||||||
if (m_effects[i])
|
delete m_effects[i];
|
||||||
delete m_effects[i];
|
|
||||||
|
|
||||||
assert(m_applications.empty());
|
assert(m_applications.empty());
|
||||||
_DeleteRemovedApplications();
|
_DeleteRemovedApplications();
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ World::~World()
|
|||||||
|
|
||||||
VMAP::VMapFactory::clear();
|
VMAP::VMapFactory::clear();
|
||||||
|
|
||||||
if (m_resultQueue) delete m_resultQueue;
|
delete m_resultQueue;
|
||||||
|
|
||||||
//TODO free addSessQueue
|
//TODO free addSessQueue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user