mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Guard against null pointers and remove unnecessary include.
This commit is contained in:
parent
7004ec627e
commit
859514a792
2 changed files with 10 additions and 9 deletions
|
|
@ -23,7 +23,6 @@
|
||||||
#include "console/simDictionary.h"
|
#include "console/simDictionary.h"
|
||||||
#include "console/simBase.h"
|
#include "console/simBase.h"
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
extern U32 HashPointer(StringTableEntry e);
|
extern U32 HashPointer(StringTableEntry e);
|
||||||
|
|
@ -46,7 +45,7 @@ SimNameDictionary::~SimNameDictionary()
|
||||||
|
|
||||||
void SimNameDictionary::insert(SimObject* obj)
|
void SimNameDictionary::insert(SimObject* obj)
|
||||||
{
|
{
|
||||||
if(!obj->objectName)
|
if(!obj || !obj->objectName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SimObject* checkForDup = find(obj->objectName);
|
SimObject* checkForDup = find(obj->objectName);
|
||||||
|
|
@ -140,7 +139,7 @@ SimObject* SimNameDictionary::find(StringTableEntry name)
|
||||||
|
|
||||||
void SimNameDictionary::remove(SimObject* obj)
|
void SimNameDictionary::remove(SimObject* obj)
|
||||||
{
|
{
|
||||||
if(!obj->objectName)
|
if(!obj || !obj->objectName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Mutex::lockMutex(mutex);
|
Mutex::lockMutex(mutex);
|
||||||
|
|
@ -191,7 +190,7 @@ SimManagerNameDictionary::~SimManagerNameDictionary()
|
||||||
|
|
||||||
void SimManagerNameDictionary::insert(SimObject* obj)
|
void SimManagerNameDictionary::insert(SimObject* obj)
|
||||||
{
|
{
|
||||||
if(!obj->objectName)
|
if(!obj || !obj->objectName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Mutex::lockMutex(mutex);
|
Mutex::lockMutex(mutex);
|
||||||
|
|
@ -268,7 +267,7 @@ SimObject* SimManagerNameDictionary::find(StringTableEntry name)
|
||||||
|
|
||||||
void SimManagerNameDictionary::remove(SimObject* obj)
|
void SimManagerNameDictionary::remove(SimObject* obj)
|
||||||
{
|
{
|
||||||
if(!obj->objectName)
|
if(!obj || !obj->objectName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifndef USE_NEW_SIMDICTIONARY
|
#ifndef USE_NEW_SIMDICTIONARY
|
||||||
|
|
@ -316,6 +315,9 @@ SimIdDictionary::~SimIdDictionary()
|
||||||
|
|
||||||
void SimIdDictionary::insert(SimObject* obj)
|
void SimIdDictionary::insert(SimObject* obj)
|
||||||
{
|
{
|
||||||
|
if (!obj)
|
||||||
|
return;
|
||||||
|
|
||||||
Mutex::lockMutex(mutex);
|
Mutex::lockMutex(mutex);
|
||||||
#ifndef USE_NEW_SIMDICTIONARY
|
#ifndef USE_NEW_SIMDICTIONARY
|
||||||
S32 idx = obj->getId() & TableBitMask;
|
S32 idx = obj->getId() & TableBitMask;
|
||||||
|
|
@ -356,6 +358,9 @@ SimObject* SimIdDictionary::find(S32 id)
|
||||||
|
|
||||||
void SimIdDictionary::remove(SimObject* obj)
|
void SimIdDictionary::remove(SimObject* obj)
|
||||||
{
|
{
|
||||||
|
if (!obj)
|
||||||
|
return;
|
||||||
|
|
||||||
Mutex::lockMutex(mutex);
|
Mutex::lockMutex(mutex);
|
||||||
#ifndef USE_NEW_SIMDICTIONARY
|
#ifndef USE_NEW_SIMDICTIONARY
|
||||||
SimObject **walk = &table[obj->getId() & TableBitMask];
|
SimObject **walk = &table[obj->getId() & TableBitMask];
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,6 @@ class SimObject;
|
||||||
#include "console/sim.h"
|
#include "console/sim.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "core/strings/stringFunctions.h"
|
|
||||||
|
|
||||||
struct StringTableEntryHash
|
struct StringTableEntryHash
|
||||||
{
|
{
|
||||||
inline size_t operator()(StringTableEntry val) const
|
inline size_t operator()(StringTableEntry val) const
|
||||||
|
|
@ -67,8 +65,6 @@ typedef std::unordered_map<StringTableEntry, SimObject*, StringTableEntryHash, S
|
||||||
typedef std::unordered_map<SimObjectId, SimObject*> SimObjectIdDictDef;
|
typedef std::unordered_map<SimObjectId, SimObject*> SimObjectIdDictDef;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
/// Map of names to SimObjects
|
/// Map of names to SimObjects
|
||||||
///
|
///
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue