newer standards prefer nullptr over NULL - this is most of them but there are others too

This commit is contained in:
DarthArgus
2016-02-11 15:16:14 -06:00
parent a7f2d0ea6a
commit 3e4cc36e7e
937 changed files with 14983 additions and 14983 deletions
@@ -9,7 +9,7 @@ namespace ChatSystem
// AVATAR ITERATOR CORE
AvatarIteratorCore::AvatarIteratorCore()
: m_map(NULL)
: m_map(nullptr)
{
}
@@ -33,7 +33,7 @@ AvatarIteratorCore &AvatarIteratorCore::operator=(const AvatarIteratorCore& rhs)
ChatAvatar *AvatarIteratorCore::getCurAvatar()
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
if (!outOfBounds())
{
@@ -87,7 +87,7 @@ bool AvatarIteratorCore::outOfBounds()
// MODERATOR ITERATOR CORE
ModeratorIteratorCore::ModeratorIteratorCore()
: m_set(NULL)
: m_set(nullptr)
{
}
@@ -111,7 +111,7 @@ ModeratorIteratorCore &ModeratorIteratorCore::operator=(const ModeratorIteratorC
ChatAvatar *ModeratorIteratorCore::getCurAvatar()
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
if (!outOfBounds())
{
@@ -165,7 +165,7 @@ bool ModeratorIteratorCore::outOfBounds()
// TEMPORARY MODERATOR ITERATOR CORE
TemporaryModeratorIteratorCore::TemporaryModeratorIteratorCore()
: m_set(NULL)
: m_set(nullptr)
{
}
@@ -189,7 +189,7 @@ TemporaryModeratorIteratorCore &TemporaryModeratorIteratorCore::operator=(const
ChatAvatar *TemporaryModeratorIteratorCore::getCurAvatar()
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
if (!outOfBounds())
{
@@ -243,7 +243,7 @@ bool TemporaryModeratorIteratorCore::outOfBounds()
// VOICE ITERATOR CORE
VoiceIteratorCore::VoiceIteratorCore()
: m_set(NULL)
: m_set(nullptr)
{
}
@@ -267,7 +267,7 @@ VoiceIteratorCore &VoiceIteratorCore::operator=(const VoiceIteratorCore& rhs)
ChatAvatar *VoiceIteratorCore::getCurAvatar()
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
if (!outOfBounds())
{
@@ -321,7 +321,7 @@ bool VoiceIteratorCore::outOfBounds()
// INVITE ITERATOR CORE
InviteIteratorCore::InviteIteratorCore()
: m_set(NULL)
: m_set(nullptr)
{
}
@@ -345,7 +345,7 @@ InviteIteratorCore &InviteIteratorCore::operator=(const InviteIteratorCore& rhs)
ChatAvatar *InviteIteratorCore::getCurAvatar()
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
if (!outOfBounds())
{
@@ -399,7 +399,7 @@ bool InviteIteratorCore::outOfBounds()
// BAN ITERATOR CORE
BanIteratorCore::BanIteratorCore()
: m_set(NULL)
: m_set(nullptr)
{
}
@@ -423,7 +423,7 @@ BanIteratorCore &BanIteratorCore::operator=(const BanIteratorCore& rhs)
ChatAvatar *BanIteratorCore::getCurAvatar()
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
if (!outOfBounds())
{
@@ -7,7 +7,7 @@ namespace ChatSystem
using namespace Plat_Unicode;
AvatarListItem::AvatarListItem()
: m_core(NULL)
: m_core(nullptr)
{
}
@@ -16,7 +16,7 @@ namespace ChatSystem
}
AvatarListItemCore::AvatarListItemCore()
: m_interface(NULL)
: m_interface(nullptr)
{
}
@@ -13,7 +13,7 @@ namespace ChatSystem
{
ChatAPI::ChatAPI(const char *registrar_host, short registrar_port, const char *server_host, short server_port)
: m_defaultRoomParams(NULL),
: m_defaultRoomParams(nullptr),
m_defaultLoginPriority(0),
m_defaultEntryType(false)
{
@@ -25,13 +25,13 @@ ChatAPI::ChatAPI(const char *registrar_host, short registrar_port, const char *s
ChatAPI::~ChatAPI()
{
delete m_defaultRoomParams;
m_defaultRoomParams = NULL;
m_defaultRoomParams = nullptr;
delete m_core;
m_core = NULL;
m_core = nullptr;
}
ChatAPI::ChatAPI(ChatAPICore *core)
: m_defaultRoomParams(NULL)
: m_defaultRoomParams(nullptr)
{
m_core = core;
m_core->setAPI(this);
@@ -721,7 +721,7 @@ void ChatAPI::setDefaultRoomParams(RoomParams *roomParams)
{
if (roomParams)
{
if (m_defaultRoomParams == NULL)
if (m_defaultRoomParams == nullptr)
{
m_defaultRoomParams = new RoomParams;
}
@@ -732,7 +732,7 @@ void ChatAPI::setDefaultRoomParams(RoomParams *roomParams)
else
{
delete m_defaultRoomParams;
m_defaultRoomParams = NULL;
m_defaultRoomParams = nullptr;
}
}
void ChatAPI::setDefaultLoginLocation(const ChatUnicodeString &defaultLoginLocation)
@@ -105,7 +105,7 @@ namespace ChatSystem
// will be connected to, as well as the hostname and port of the Registrar
// ChatServer (which will automatically reroute the ChatAPI connection to
// a hotspare ChatServer if the provided choice is unavailable).
// NULL pointers are NOT valid input.
// nullptr pointers are NOT valid input.
ChatAPI(const char *registrar_host, short registrar_port, const char *server_host, short server_port);
virtual ~ChatAPI();
@@ -209,7 +209,7 @@ namespace ChatSystem
// getAvatar
// Requests immediate return of a ChatAvatar object that this API
// has cached due to a RequestLoginAvatar. Request does not go
// to ChatServer. Returns NULL if API does not have object locally.
// to ChatServer. Returns nullptr if API does not have object locally.
ChatAvatar *getAvatar(const ChatUnicodeString &avatarName, const ChatUnicodeString &avatarAddress);
ChatAvatar *getAvatar(unsigned avatarID);
@@ -286,7 +286,7 @@ namespace ChatSystem
// Requests immediate return of a ChatRoom object that this API
// has cached due to a RequestGetRoom, RequestCreateRoom, or
// RequestEnterRoom. Request does not go to ChatServer. Returns
// NULL if API does not have object locally.
// nullptr if API does not have object locally.
ChatRoom *getRoom(const ChatUnicodeString &roomAddress);
ChatRoom *getRoom(unsigned roomID);
@@ -298,13 +298,13 @@ namespace ChatSystem
// getDefaultRoomParams
// Requests the ChatAPI's current default RoomParams object. Used for
// the EnterRoom call. If NULL, EnterRoom will not do passive room
// the EnterRoom call. If nullptr, EnterRoom will not do passive room
// creation if the room to enter does not yet exist. Initial value
// is NULL (no RoomParams object defined).
// is nullptr (no RoomParams object defined).
const RoomParams *getDefaultRoomParams(void);
// setDefaultRoomParams
// Sets the ChatAPI's current default RoomParams object. Passing a NULL
// Sets the ChatAPI's current default RoomParams object. Passing a nullptr
// pointer will cause the default params not to be used by EnterRoom.
void setDefaultRoomParams(RoomParams *roomParams);
@@ -67,7 +67,7 @@ const char * const ChatAPICore::ms_errorStringsEnglish[] =
"UID node already exists",
"Wrong chat server for request",
"Succeeded, but local data is invalid",
"Login with null name",
"Login with nullptr name",
"No server assigned to this identity", // 45
"Another server already assumed this identity",
"Remote server is down",
@@ -82,9 +82,9 @@ const char * const ChatAPICore::ms_errorStringsEnglish[] =
"Duplicate voice",
"Chat avatar must first be logged out",
"No work to do",
"Cannot perform rename to NULL avatar name",
"Cannot perform rename to nullptr avatar name",
"Cannot perform station acct transfer to stationID = 0", // 60
"Cannot perform avatar move to NULL avatar address",
"Cannot perform avatar move to nullptr avatar address",
"Failed to obtain an ID for a new room or avatar",
"Room is local to namespace/world; cannot enter from other worlds",
"Room is local to game; cannot enter from other game namespaces",
@@ -122,7 +122,7 @@ ChatAPICore::ChatAPICore(const char *registrar_host, short registrar_port, const
m_registrarPort(registrar_port),
m_defaultServerPort(server_port),
m_assignedServerPort(server_port),
m_timeSinceLastDisconnect(time(NULL)),
m_timeSinceLastDisconnect(time(nullptr)),
m_rcvdRegistrarResponse(false),
m_shouldSendVersion(true)
{
@@ -132,7 +132,7 @@ ChatAPICore::ChatAPICore(const char *registrar_host, short registrar_port, const
ChatAPICore::~ChatAPICore()
{
m_api = NULL;
m_api = nullptr;
std::map<unsigned, ChatAvatarCore*>::iterator iter = m_avatarCoreCache.begin();
for (; iter != m_avatarCoreCache.end(); ++iter)
@@ -209,7 +209,7 @@ void ChatAPICore::cacheAvatar(ChatAvatarCore *avatarCore)
ChatAvatarCore *ChatAPICore::getAvatarCore(unsigned avatarID)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
std::map<unsigned, ChatAvatarCore *>::iterator iter = m_avatarCoreCache.find(avatarID);
if(iter != m_avatarCoreCache.end())
@@ -221,7 +221,7 @@ ChatAvatarCore *ChatAPICore::getAvatarCore(unsigned avatarID)
ChatAvatar *ChatAPICore::getAvatar(unsigned avatarID)
{
ChatAvatar *returnAvatar = NULL;
ChatAvatar *returnAvatar = nullptr;
std::map<unsigned, ChatAvatar *>::iterator iter = m_avatarCache.find(avatarID);
if(iter != m_avatarCache.end())
@@ -233,7 +233,7 @@ ChatAvatar *ChatAPICore::getAvatar(unsigned avatarID)
ChatAvatarCore *ChatAPICore::decacheAvatar(unsigned avatarID)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
std::map<unsigned, ChatAvatarCore *>::iterator iterCore = m_avatarCoreCache.find(avatarID);
if(iterCore != m_avatarCoreCache.end())
{
@@ -267,7 +267,7 @@ void ChatAPICore::cacheRoom(ChatRoomCore *roomCore)
ChatRoomCore *ChatAPICore::getRoomCore(unsigned roomID)
{
ChatRoomCore *returnRoom = NULL;
ChatRoomCore *returnRoom = nullptr;
std::map<unsigned, ChatRoomCore *>::iterator iter = m_roomCoreCache.find(roomID);
if(iter != m_roomCoreCache.end())
{
@@ -279,7 +279,7 @@ ChatRoomCore *ChatAPICore::getRoomCore(unsigned roomID)
ChatRoom *ChatAPICore::getRoom(unsigned roomID)
{
ChatRoom *returnRoom = NULL;
ChatRoom *returnRoom = nullptr;
std::map<unsigned, ChatRoom *>::iterator iter = m_roomCache.find(roomID);
if(iter != m_roomCache.end())
{
@@ -291,7 +291,7 @@ ChatRoom *ChatAPICore::getRoom(unsigned roomID)
ChatRoomCore *ChatAPICore::decacheRoom(unsigned roomID)
{
ChatRoomCore *returnRoom = NULL;
ChatRoomCore *returnRoom = nullptr;
std::map<unsigned, ChatRoomCore *>::iterator iterCore = m_roomCoreCache.find(roomID);
if(iterCore != m_roomCoreCache.end())
@@ -315,7 +315,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_LOGINAVATAR:
{
ResLoginAvatar *R = static_cast<ResLoginAvatar *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getAvatar())
{
@@ -338,7 +338,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_TEMPORARYAVATAR:
{
ResTemporaryAvatar* R = static_cast<ResTemporaryAvatar*>(res);
ChatAvatar* avatar = NULL;
ChatAvatar* avatar = nullptr;
if ( R->getAvatar() )
{
@@ -394,8 +394,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_GETAVATAR:
{
ResGetAvatar *R = static_cast<ResGetAvatar *>(res);
ChatAvatar *cachedAvatar = NULL;
ChatAvatar *avatar = NULL;
ChatAvatar *cachedAvatar = nullptr;
ChatAvatar *avatar = nullptr;
ChatAvatarCore *avatarCore = R->getAvatar();
if (R->getResult() == 0 && avatarCore) // if success
@@ -403,7 +403,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// attempt to return locally cached avatar, if available
cachedAvatar = getAvatar(avatarCore->getAvatarID());
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
// update cached information with returned data
cachedAvatar->setAttributes(avatarCore->getAttributes());
@@ -427,7 +427,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
m_api->OnGetAvatar(R->getTrack(), R->getResult(), avatar, R->getUser());
if (cachedAvatar == NULL)
if (cachedAvatar == nullptr)
{
delete avatar;
}
@@ -438,8 +438,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_GETANYAVATAR:
{
ResGetAnyAvatar *R = static_cast<ResGetAnyAvatar *>(res);
ChatAvatar *cachedAvatar = NULL;
ChatAvatar *avatar = NULL;
ChatAvatar *cachedAvatar = nullptr;
ChatAvatar *avatar = nullptr;
ChatAvatarCore *avatarCore = R->getAvatar();
if (R->getResult() == 0 && avatarCore) // if success
@@ -447,7 +447,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// attempt to return locally cached avatar, if available
cachedAvatar = getAvatar(avatarCore->getAvatarID());
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
// update cached information with returned data
cachedAvatar->setAttributes(avatarCore->getAttributes());
@@ -471,7 +471,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
m_api->OnGetAnyAvatar(R->getTrack(), R->getResult(), avatar, R->isLoggedIn(), R->getUser());
if (cachedAvatar == NULL)
if (cachedAvatar == nullptr)
{
delete avatar;
}
@@ -490,8 +490,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_SETAVATARATTRIBUTES:
{
ResSetAvatarAttributes *R = static_cast<ResSetAvatarAttributes *>(res);
ChatAvatar *cachedAvatar = NULL;
ChatAvatar *avatar = NULL;
ChatAvatar *cachedAvatar = nullptr;
ChatAvatar *avatar = nullptr;
ChatAvatarCore *avatarCore = R->getAvatar();
if (R->getResult() == 0 && avatarCore) // if success
@@ -502,14 +502,14 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// attempt to return locally cached avatar, if available
cachedAvatar = getAvatar(avatar->getAvatarID());
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar->setAttributes(avatar->getAttributes());
}
}
}
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar = avatar;
m_api->OnSetAvatarAttributes(R->getTrack(), R->getResult(), cachedAvatar, R->getUser());
@@ -531,8 +531,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_SETSTATUSMESSAGE:
{
ResSetAvatarStatusMessage *R = static_cast<ResSetAvatarStatusMessage*>(res);
ChatAvatar *cachedAvatar = NULL;
ChatAvatar *avatar = NULL;
ChatAvatar *cachedAvatar = nullptr;
ChatAvatar *avatar = nullptr;
ChatAvatarCore *avatarCore = R->getAvatar();
if (R->getResult() == 0 && avatarCore) // if success
@@ -543,14 +543,14 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// attempt to return locally cached avatar, if available
cachedAvatar = getAvatar(avatar->getAvatarID());
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar->setStatusMessage(avatar->getStatusMessage());
}
}
}
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar = avatar;
m_api->OnSetAvatarStatusMessage(R->getTrack(), R->getResult(), cachedAvatar, R->getUser());
@@ -572,8 +572,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_SETAVATAREMAIL:
{
ResSetAvatarForwardingEmail*R = static_cast<ResSetAvatarForwardingEmail*>(res);
ChatAvatar *cachedAvatar = NULL;
ChatAvatar *avatar = NULL;
ChatAvatar *cachedAvatar = nullptr;
ChatAvatar *avatar = nullptr;
ChatAvatarCore *avatarCore = R->getAvatar();
if (R->getResult() == 0 && avatarCore) // if success
@@ -584,14 +584,14 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// attempt to return locally cached avatar, if available
cachedAvatar = getAvatar(avatar->getAvatarID());
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar->setForwardingEmail(avatar->getForwardingEmail());
}
}
}
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar = avatar;
m_api->OnSetAvatarForwardingEmail(R->getTrack(), R->getResult(), cachedAvatar, R->getUser());
@@ -613,8 +613,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_SETAVATARINBOXLIMIT:
{
ResSetAvatarInboxLimit *R = static_cast<ResSetAvatarInboxLimit*>(res);
ChatAvatar *cachedAvatar = NULL;
ChatAvatar *avatar = NULL;
ChatAvatar *cachedAvatar = nullptr;
ChatAvatar *avatar = nullptr;
ChatAvatarCore *avatarCore = R->getAvatar();
if (R->getResult() == 0 && avatarCore) // if success
@@ -625,14 +625,14 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// attempt to return locally cached avatar, if available
cachedAvatar = getAvatar(avatar->getAvatarID());
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar->setInboxLimit(avatar->getInboxLimit());
}
}
}
if (cachedAvatar != NULL)
if (cachedAvatar != nullptr)
{
cachedAvatar = avatar;
m_api->OnSetAvatarInboxLimit(R->getTrack(), R->getResult(), cachedAvatar, R->getUser());
@@ -654,13 +654,13 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_GETROOM:
{
ResGetRoom *R = static_cast<ResGetRoom *>(res);
ChatRoom *room = NULL;
ChatRoom *room = nullptr;
ChatRoomCore *roomCore = R->getRoom();
if (R->getResult() == 0 && roomCore) // if success
{
unsigned roomid = roomCore->getRoomID();
if (getRoomCore(roomid) == NULL)
if (getRoomCore(roomid) == nullptr)
{
// we need to cache this room first
cacheRoom(roomCore);
@@ -708,8 +708,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
{
ResCreateRoom *R = static_cast<ResCreateRoom *>(res);
ChatRoom *room = NULL;
ChatRoomCore* roomCore = NULL;
ChatRoom *room = nullptr;
ChatRoomCore* roomCore = nullptr;
if (R->getResult() == 0) // if success
{
@@ -939,7 +939,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
else if (!room && !roomCore)
{
// we didn't have room cached, and we didn't get one to cache,
// thus we'll have trouble giving a callback with a NULL pointer.
// thus we'll have trouble giving a callback with a nullptr pointer.
_chatdebug_("ChatAPI:BadData: RESPONSE_ENTERROOM: avatar=%p, room=%p , roomCore=%p\n", avatar, room, roomCore);
}
}
@@ -1175,8 +1175,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_FINDAVATARBYUID:
{
ResFindAvatarByUID *R = static_cast<ResFindAvatarByUID *>(res);
ChatAvatar **avatarMatches = NULL;
ChatAvatarCore **avatarCoreMatches = NULL;
ChatAvatar **avatarMatches = nullptr;
ChatAvatarCore **avatarCoreMatches = nullptr;
unsigned numAvatarsOnline = R->getNumAvatarsOnline();
@@ -1374,7 +1374,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
// duplicate login from this API, then effectively
// our API must consider him logged out because he's now
// no longer logged in to his AID controller.
m_api->OnLogoutAvatar(0, 0, avatar, NULL);
m_api->OnLogoutAvatar(0, 0, avatar, nullptr);
}
}
@@ -1476,7 +1476,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_GETAVATARKEYWORDS:
{
ResGetAvatarKeywords *R = static_cast<ResGetAvatarKeywords *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
@@ -1494,7 +1494,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_SETAVATARKEYWORDS:
{
ResSetAvatarKeywords *R = static_cast<ResSetAvatarKeywords *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getAvatarID());
@@ -1510,8 +1510,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_SEARCHAVATARKEYWORDS:
{
ResSearchAvatarKeywords *R = static_cast<ResSearchAvatarKeywords *>(res);
ChatAvatar **avatarMatches = NULL;
ChatAvatarCore **avatarCoreMatches = NULL;
ChatAvatar **avatarMatches = nullptr;
ChatAvatarCore **avatarCoreMatches = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
@@ -1530,7 +1530,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_CONFIRMFRIEND:
{
ResFriendConfirm *R = static_cast<ResFriendConfirm *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getAvatarID());
@@ -1546,7 +1546,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_CONFIRMFRIEND_RECIPROCATE:
{
ResFriendConfirmReciprocate *R = static_cast<ResFriendConfirmReciprocate *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getAvatarID());
@@ -1616,7 +1616,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_ADDSNOOPAVATAR:
{
ResAddSnoopAvatar *R = static_cast<ResAddSnoopAvatar *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getSrcAvatarID());
@@ -1632,7 +1632,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_REMOVESNOOPAVATAR:
{
ResRemoveSnoopAvatar *R = static_cast<ResRemoveSnoopAvatar *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getSrcAvatarID());
@@ -1648,7 +1648,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_ADDSNOOPROOM:
{
ResAddSnoopRoom *R = static_cast<ResAddSnoopRoom *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getSrcAvatarID());
@@ -1664,7 +1664,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_REMOVESNOOPROOM:
{
ResRemoveSnoopRoom *R = static_cast<ResRemoveSnoopRoom *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getSrcAvatarID());
@@ -1680,7 +1680,7 @@ void ChatAPICore::responseCallback(GenericResponse *res)
case RESPONSE_GETSNOOPLIST:
{
ResGetSnoopList *R = static_cast<ResGetSnoopList *>(res);
ChatAvatar *avatar = NULL;
ChatAvatar *avatar = nullptr;
if(R->getResult() == CHATRESULT_SUCCESS)
{
avatar = getAvatar(R->getSrcAvatarID());
@@ -1691,8 +1691,8 @@ void ChatAPICore::responseCallback(GenericResponse *res)
_chatdebug_("ChatAPI:BadData: RESPONSE_REMOVESNOOPROOM: avatar=%p\n", avatar);
}
AvatarSnoopPair **avatarList = NULL;
ChatUnicodeString **roomList = NULL;
AvatarSnoopPair **avatarList = nullptr;
ChatUnicodeString **roomList = nullptr;
unsigned numAvatars = R->getAvatarSnoopListLength();
unsigned numRooms = R->getRoomSnoopListLength();
@@ -1763,7 +1763,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatAvatar *destAvatar = getAvatar(M.getDestList()[i]);
if (!destAvatar)
{
_chatdebug_("ChatAPI:BadData: MESSAGE_ROOMMESSAGE: destAvatar[%i]=NULL\n", i);
_chatdebug_("ChatAPI:BadData: MESSAGE_ROOMMESSAGE: destAvatar[%i]=nullptr\n", i);
continue;
}
m_api->OnReceiveRoomMessage(srcAvatar, destAvatar, destRoom, ChatUnicodeString(M.getMsg().data(), M.getMsg().size()), ChatUnicodeString(M.getOOB().data(), M.getOOB().size()));
@@ -1797,7 +1797,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatAvatar *destAvatar = getAvatar(M.getDestList()[i]);
if (!destAvatar)
{
_chatdebug_("ChatAPI:BadData: MESSAGE_BROADCASTMESSAGE: destAvatar[%i]=NULL\n", i);
_chatdebug_("ChatAPI:BadData: MESSAGE_BROADCASTMESSAGE: destAvatar[%i]=nullptr\n", i);
continue;
}
m_api->OnReceiveBroadcastMessage(srcAvatar, ChatUnicodeString(M.getSrcAddress().data(), M.getSrcAddress().size()), destAvatar, ChatUnicodeString(M.getMsg().data(), M.getMsg().size()), ChatUnicodeString(M.getOOB().data(), M.getOOB().size()));
@@ -1877,7 +1877,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatRoomCore *destRoomCore = getRoomCore(M.getRoomID());
if (!destRoomCore) {
_chatdebug_("ChatAPI:destroomCore is null!");
_chatdebug_("ChatAPI:destroomCore is nullptr!");
break;
}
@@ -1889,7 +1889,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatAvatar *destAvatar = M.getDestAvatar()->getNewChatAvatar();
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
ChatAvatarCore *kickedAvatar = destRoomCore ? destRoomCore->removeAvatar(destAvatar->getAvatarID()) : NULL;
ChatAvatarCore *kickedAvatar = destRoomCore ? destRoomCore->removeAvatar(destAvatar->getAvatarID()) : nullptr;
ChatRoom *destRoom = getRoom(M.getRoomID());
if (!srcAvatar || !destAvatar || !kickedAvatar || !destRoom)
@@ -2439,12 +2439,12 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
if (!srcAvatar)
{
_chatdebug_("ChatAPI:BadData: MESSAGE_ENTERROOM: srcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_ENTERROOM: srcAvatar=nullptr\n");
delete M.getSrcAvatar();
break;
}
bool isLocalAvatar = (getAvatar(srcAvatar->getAvatarID()) != NULL);
bool isLocalAvatar = (getAvatar(srcAvatar->getAvatarID()) != nullptr);
if(!destRoomCore->addAvatar(M.getSrcAvatar(),isLocalAvatar))
{
delete M.getSrcAvatar();
@@ -2492,10 +2492,10 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
if (destRoomCore)
{
ChatRoom *destRoom = getRoom(M.getRoomID());
ChatAvatar *srcAvatar = NULL;
ChatAvatar *srcAvatar = nullptr;
if (!M.getSrcAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_DESTROYROOM: M.getSrcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_DESTROYROOM: M.getSrcAvatar=nullptr\n");
}
else
{
@@ -2527,7 +2527,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatRoomCore *destRoomCore = getRoomCore(M.getRoomID());
if (!destRoomCore)
{
_chatdebug_("ChatAPI:BadData: MESSAGE_SETROOMPARAMS: destRoomCore=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_SETROOMPARAMS: destRoomCore=nullptr\n");
break;
}
@@ -2544,7 +2544,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
if (!M.getSrcAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_SETROOMPARAMS: M.getSrcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_SETROOMPARAMS: M.getSrcAvatar=nullptr\n");
break;
}
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
@@ -2686,7 +2686,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
{
MAddAdmin M(iter);
ChatRoomCore *destRoomCore = getRoomCore(M.getRoomID());
if (destRoomCore && (destRoomCore->addAdministrator(M.getAvatar()) == NULL))
if (destRoomCore && (destRoomCore->addAdministrator(M.getAvatar()) == nullptr))
{
delete (M.getAvatar());
}
@@ -2696,7 +2696,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
{
MRemoveAdmin M(iter);
ChatRoomCore *destRoomCore = getRoomCore(M.getRoomID());
ChatAvatarCore *admin = NULL;
ChatAvatarCore *admin = nullptr;
if (destRoomCore)
admin = destRoomCore->removeAdministrator(M.getAvatarID());
delete admin;
@@ -2707,7 +2707,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
MFriendConfirmRequest M(iter);
if (!M.getSrcAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMREQUEST: M.getSrcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMREQUEST: M.getSrcAvatar=nullptr\n");
break;
}
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
@@ -2730,7 +2730,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
if (!M.getSrcAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMRESPONSE: M.getSrcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMRESPONSE: M.getSrcAvatar=nullptr\n");
break;
}
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
@@ -2752,7 +2752,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
MFriendConfirmReciprocateRequest M(iter);
if (!M.getSrcAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMRECIPROCATE_REQUEST: M.getSrcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMRECIPROCATE_REQUEST: M.getSrcAvatar=nullptr\n");
break;
}
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
@@ -2775,7 +2775,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
if (!M.getSrcAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMRECIPROCATE_RESPONSE: M.getSrcAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_FRIENDCONFIRMRECIPROCATE_RESPONSE: M.getSrcAvatar=nullptr\n");
break;
}
ChatAvatar *srcAvatar = M.getSrcAvatar()->getNewChatAvatar();
@@ -2799,7 +2799,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
ChatRoomCore *destRoomCore = getRoomCore(M.getDestRoomID());
if (!destRoomCore)
{
_chatdebug_("ChatAPI:BadData: MESSAGE_CHANGEROOMOWNER: destRoomCore=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_CHANGEROOMOWNER: destRoomCore=nullptr\n");
break;
}
@@ -2822,7 +2822,7 @@ void ChatAPICore::responseCallback(short type, ByteStream::ReadIterator &iter)
if (!M.getRequestorAvatar())
{
_chatdebug_("ChatAPI:BadData: MESSAGE_REQUESTROOMENTRY: M.getRequestorAvatar=NULL\n");
_chatdebug_("ChatAPI:BadData: MESSAGE_REQUESTROOMENTRY: M.getRequestorAvatar=nullptr\n");
break;
}
ChatAvatar *srcAvatar = M.getRequestorAvatar()->getNewChatAvatar();
@@ -3025,7 +3025,7 @@ void ChatAPICore::processAPI()
}
// if we've been disconnected for at least a minute...
else if (!m_connected &&
time(NULL) - m_timeSinceLastDisconnect >= 60)
time(nullptr) - m_timeSinceLastDisconnect >= 60)
{
if (m_setToRegistrar)
{
@@ -3043,7 +3043,7 @@ void ChatAPICore::processAPI()
m_setToRegistrar = true;
}
m_timeSinceLastDisconnect = time(NULL);
m_timeSinceLastDisconnect = time(nullptr);
}
@@ -3072,7 +3072,7 @@ void ChatAPICore::OnConnect(const char *host, short port)
res->setTrack(m_currTrack);
m_currTrack++;
time_t timeout = time(NULL) + m_requestTimeout;
time_t timeout = time(nullptr) + m_requestTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
@@ -3103,7 +3103,7 @@ void ChatAPICore::OnConnect(const char *host, short port)
res->setTrack(m_currTrack);
m_currTrack++;
time_t timeout = time(NULL) + m_requestTimeout;
time_t timeout = time(nullptr) + m_requestTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
@@ -3147,7 +3147,7 @@ void ChatAPICore::OnDisconnect(const char *host, short port)
// stop processing immediately
suspendProcessing();
m_timeSinceLastDisconnect = time(NULL);
m_timeSinceLastDisconnect = time(nullptr);
// determine who we disconnected from and take appropriate action
if (strcmp(host, m_registrarHost.c_str()) == 0 &&
@@ -3214,7 +3214,7 @@ void ChatAPICore::failoverReloginOneAvatar(ChatAvatarCore * avatarCore)
res->setTrack(m_currTrack);
m_currTrack++;
time_t timeout = time(NULL) + m_requestTimeout;
time_t timeout = time(nullptr) + m_requestTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
@@ -3241,7 +3241,7 @@ void ChatAPICore::failoverRecreateRooms()
{
// first build multimap of rooms keyed by their node level (ascending order is default).
multimap<unsigned, ChatRoomCore *> levelMap;
ChatRoomCore *roomCore = NULL;
ChatRoomCore *roomCore = nullptr;
for (roomIter = m_roomCoreCache.begin(); roomIter != m_roomCoreCache.end(); ++roomIter)
{
roomCore = (*roomIter).second;
@@ -3268,7 +3268,7 @@ void ChatAPICore::failoverRecreateRooms()
res->setTrack(m_currTrack);
m_currTrack++;
time_t timeout = time(NULL) + m_requestTimeout;
time_t timeout = time(nullptr) + m_requestTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
@@ -3296,7 +3296,7 @@ void ChatAPICore::failoverRecreateRooms()
ChatAvatar *ChatAPICore::getAvatar(const ChatUnicodeString &avatarName, const ChatUnicodeString &avatarAddress)
{
ChatAvatar *returnVal = NULL;
ChatAvatar *returnVal = nullptr;
map<unsigned, ChatAvatar *>::iterator iter = m_avatarCache.begin();
@@ -3317,7 +3317,7 @@ ChatAvatar *ChatAPICore::getAvatar(const ChatUnicodeString &avatarName, const Ch
ChatRoom *ChatAPICore::getRoom(const ChatUnicodeString &roomAddress)
{
ChatRoom *returnVal = NULL;
ChatRoom *returnVal = nullptr;
map<unsigned, ChatRoom *>::iterator iter = m_roomCache.begin();
@@ -43,7 +43,7 @@ ChatUnicodeString::ChatUnicodeString(const std::string& nSrc)
ChatUnicodeString::ChatUnicodeString(const char *nStrSrc)
{
if (nStrSrc==NULL)
if (nStrSrc==nullptr)
{
m_wideString = getEmptyString();
m_cString = wideToNarrow(m_wideString);
@@ -7,7 +7,7 @@ namespace ChatSystem
using namespace Base;
using namespace Plat_Unicode;
ChatFriendStatusCore::ChatFriendStatusCore()
: m_interface(NULL),
: m_interface(nullptr),
m_status(0)
{
}
@@ -31,7 +31,7 @@ ChatFriendStatusCore::~ChatFriendStatusCore()
}
ChatFriendStatus::ChatFriendStatus()
: m_core(NULL)
: m_core(nullptr)
{
}
@@ -7,7 +7,7 @@ namespace ChatSystem
using namespace Plat_Unicode;
ChatIgnoreStatus::ChatIgnoreStatus()
: m_core(NULL)
: m_core(nullptr)
{
}
@@ -16,7 +16,7 @@ namespace ChatSystem
}
ChatIgnoreStatusCore::ChatIgnoreStatusCore()
: m_interface(NULL)
: m_interface(nullptr)
{
}
@@ -581,7 +581,7 @@ unsigned RoomSummary::getRoomMaxSize() const
ChatRoom::ChatRoom()
{
m_core = NULL;
m_core = nullptr;
}
ChatRoom::ChatRoom(ChatRoomCore *core)
@@ -189,7 +189,7 @@ ChatRoomCore::~ChatRoomCore()
ChatAvatarCore *ChatRoomCore::getAvatarCore(unsigned avatarID)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
map<unsigned, ChatAvatarCore *>::iterator iterCore = m_inroomAvatarsCore.find(avatarID);
@@ -202,7 +202,7 @@ ChatAvatarCore *ChatRoomCore::getAvatarCore(unsigned avatarID)
ChatAvatar *ChatRoomCore::getAvatar(unsigned avatarID)
{
ChatAvatar *returnAvatar = NULL;
ChatAvatar *returnAvatar = nullptr;
map<unsigned, ChatAvatar *>::iterator iter = m_inroomAvatars.find(avatarID);
@@ -215,7 +215,7 @@ ChatAvatar *ChatRoomCore::getAvatar(unsigned avatarID)
ChatAvatarCore *ChatRoomCore::getModeratorCore(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_moderatorAvatarsCore.begin();
@@ -238,7 +238,7 @@ ChatAvatarCore *ChatRoomCore::getModeratorCore(const Plat_Unicode::String &name,
ChatAvatar *ChatRoomCore::getModerator(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatar *returnAvatar = NULL;
ChatAvatar *returnAvatar = nullptr;
set<ChatAvatar *>::iterator iter = m_moderatorAvatars.begin();
@@ -263,7 +263,7 @@ ChatAvatar *ChatRoomCore::getModerator(const Plat_Unicode::String &name, const P
ChatAvatarCore *ChatRoomCore::getBannedCore(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_banAvatarsCore.begin();
@@ -286,7 +286,7 @@ ChatAvatarCore *ChatRoomCore::getBannedCore(const Plat_Unicode::String &name, co
ChatAvatar *ChatRoomCore::getBanned(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatar *returnAvatar = NULL;
ChatAvatar *returnAvatar = nullptr;
set<ChatAvatar *>::iterator iter = m_banAvatars.begin();
@@ -311,7 +311,7 @@ ChatAvatar *ChatRoomCore::getBanned(const Plat_Unicode::String &name, const Plat
ChatAvatarCore *ChatRoomCore::getInvitedCore(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_inviteAvatarsCore.begin();
@@ -334,7 +334,7 @@ ChatAvatarCore *ChatRoomCore::getInvitedCore(const Plat_Unicode::String &name, c
ChatAvatar *ChatRoomCore::getInvited(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatar *returnAvatar = NULL;
ChatAvatar *returnAvatar = nullptr;
set<ChatAvatar *>::iterator iter = m_inviteAvatars.begin();
@@ -359,7 +359,7 @@ ChatAvatar *ChatRoomCore::getInvited(const Plat_Unicode::String &name, const Pla
ChatAvatarCore *ChatRoomCore::addAvatar(ChatAvatarCore *newAvatar, bool local)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -394,7 +394,7 @@ void ChatRoomCore::addLocalAvatar(unsigned avatarID)
ChatAvatarCore *ChatRoomCore::removeAvatar(unsigned avatarID)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
map<unsigned, ChatAvatarCore *>::iterator iterCore = m_inroomAvatarsCore.find(avatarID);
@@ -422,7 +422,7 @@ ChatAvatarCore *ChatRoomCore::removeAvatar(unsigned avatarID)
ChatAvatarCore *ChatRoomCore::addBan(ChatAvatarCore *newAvatar)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -446,7 +446,7 @@ ChatAvatarCore *ChatRoomCore::addBan(ChatAvatarCore *newAvatar)
ChatAvatarCore *ChatRoomCore::removeBan(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_banAvatarsCore.begin();
@@ -494,7 +494,7 @@ ChatAvatarCore *ChatRoomCore::removeBan(const Plat_Unicode::String &name, const
ChatAvatarCore *ChatRoomCore::addAdministrator(ChatAvatarCore *newAvatar)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -518,7 +518,7 @@ ChatAvatarCore *ChatRoomCore::addAdministrator(ChatAvatarCore *newAvatar)
ChatAvatarCore *ChatRoomCore::removeAdministrator(unsigned avatarID)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
map<unsigned, ChatAvatarCore *>::iterator iterCore = m_adminAvatarsCore.find(avatarID);
@@ -541,7 +541,7 @@ ChatAvatarCore *ChatRoomCore::removeAdministrator(unsigned avatarID)
ChatAvatarCore *ChatRoomCore::addModerator(ChatAvatarCore *newAvatar)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -565,7 +565,7 @@ ChatAvatarCore *ChatRoomCore::addModerator(ChatAvatarCore *newAvatar)
ChatAvatarCore *ChatRoomCore::removeModerator(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_moderatorAvatarsCore.begin();
@@ -613,7 +613,7 @@ ChatAvatarCore *ChatRoomCore::removeModerator(const Plat_Unicode::String &name,
ChatAvatarCore *ChatRoomCore::addTempModerator(ChatAvatarCore *newAvatar)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -637,7 +637,7 @@ ChatAvatarCore *ChatRoomCore::addTempModerator(ChatAvatarCore *newAvatar)
ChatAvatarCore *ChatRoomCore::removeTempModerator(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_tempModeratorAvatarsCore.begin();
@@ -685,7 +685,7 @@ ChatAvatarCore *ChatRoomCore::removeTempModerator(const Plat_Unicode::String &na
ChatAvatarCore *ChatRoomCore::addInvite(ChatAvatarCore* newAvatar)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -709,7 +709,7 @@ ChatAvatarCore *ChatRoomCore::addInvite(ChatAvatarCore* newAvatar)
ChatAvatarCore *ChatRoomCore::removeInvite(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_inviteAvatarsCore.begin();
@@ -757,7 +757,7 @@ ChatAvatarCore *ChatRoomCore::removeInvite(const Plat_Unicode::String &name, con
ChatAvatarCore *ChatRoomCore::addVoice(ChatAvatarCore* newAvatar)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
if(newAvatar)
{
@@ -781,7 +781,7 @@ ChatAvatarCore *ChatRoomCore::addVoice(ChatAvatarCore* newAvatar)
ChatAvatarCore *ChatRoomCore::removeVoice(const Plat_Unicode::String &name, const Plat_Unicode::String &address)
{
ChatAvatarCore *returnAvatar = NULL;
ChatAvatarCore *returnAvatar = nullptr;
set<ChatAvatarCore *>::iterator iterCore = m_voiceAvatarsCore.begin();
@@ -1053,7 +1053,7 @@ void ChatRoomCore::serializeWithLocalAvatarsOnly(Base::ByteStream &msg)
for (avatarIter = m_inroomAvatarsCore.begin(); avatarIter != m_inroomAvatarsCore.end(); ++avatarIter)
{
// include only the avatars that are on this API
if ( this->getAvatar((*avatarIter).second->getAvatarID()) != NULL )
if ( this->getAvatar((*avatarIter).second->getAvatarID()) != nullptr )
{
avatarsToSend.insert((*avatarIter).second);
}
@@ -21,7 +21,7 @@ namespace ChatSystem
MRoomMessage::MRoomMessage(ByteStream::ReadIterator &iter)
: GenericMessage(MESSAGE_ROOMMESSAGE),
m_destList(NULL),
m_destList(nullptr),
m_srcAvatar(iter),
m_messageID(0)
{
@@ -45,13 +45,13 @@ namespace ChatSystem
MRoomMessage::~MRoomMessage()
{
delete[] m_destList;
m_destList = NULL;
m_destList = nullptr;
}
MBroadcastMessage::MBroadcastMessage(ByteStream::ReadIterator &iter)
: GenericMessage(MESSAGE_BROADCASTMESSAGE),
m_srcAvatar(iter),
m_destList(NULL)
m_destList(nullptr)
{
ASSERT_VALID_STRING_LENGTH(get(iter, m_srcAddress));
get(iter, m_listLength);
@@ -68,7 +68,7 @@ namespace ChatSystem
MBroadcastMessage::~MBroadcastMessage()
{
delete[] m_destList;
m_destList = NULL;
m_destList = nullptr;
}
MFilterMessage::MFilterMessage(ByteStream::ReadIterator &iter)
@@ -8,7 +8,7 @@ using namespace Base;
using namespace Plat_Unicode;
PersistentHeader::PersistentHeader()
: m_core(NULL)
: m_core(nullptr)
{
}
@@ -66,7 +66,7 @@ PersistentHeaderCore::PersistentHeaderCore()
m_avatarID(0),
m_sentTime(0),
m_status(0),
m_interface(NULL)
m_interface(nullptr)
{
}
@@ -127,7 +127,7 @@ void RGetAvatarKeywords::pack(ByteStream &msg)
RSearchAvatarKeywords::RSearchAvatarKeywords(const ChatUnicodeString &nodeAddress, const ChatUnicodeString *keywordsList, unsigned keywordsLength)
: GenericRequest(REQUEST_SEARCHAVATARKEYWORDS),
m_keywordsLength(keywordsLength),
m_keywordsList(NULL)
m_keywordsList(nullptr)
{
m_nodeAddress.assign(nodeAddress.string_data);
m_keywordsList = new String[keywordsLength];
@@ -898,7 +898,7 @@ m_srcAddress(srcAddress.string_data, srcAddress.string_length),
m_destRoomAddress(destRoomAddress.string_data, destRoomAddress.string_length)
{
// we take in a const RoomParams, so make our own and guarantee
// null-terminated char buffers.
// nullptr-terminated char buffers.
m_newRoomName.assign(params->getRoomName().string_data, params->getRoomName().string_length);
m_newRoomTopic.assign(params->getRoomTopic().string_data, params->getRoomTopic().string_length);
m_newRoomPassword.assign(params->getRoomPassword().string_data, params->getRoomPassword().string_length);
@@ -20,7 +20,7 @@ using namespace Plat_Unicode;
ResLoginAvatar::ResLoginAvatar(void *user, int avatarLoginPriority)
: GenericResponse(RESPONSE_LOGINAVATAR, CHATRESULT_TIMEOUT, user),
m_avatar(NULL),
m_avatar(nullptr),
m_submittedPriority(avatarLoginPriority),
m_requiredPriority(INT_MAX)
{
@@ -63,7 +63,7 @@ void ResLoginAvatar::unpack(ByteStream::ReadIterator &iter)
ResTemporaryAvatar::ResTemporaryAvatar(void *user)
: GenericResponse(RESPONSE_TEMPORARYAVATAR, CHATRESULT_TIMEOUT, user)
, m_avatar(NULL)
, m_avatar(nullptr)
{
}
@@ -110,7 +110,7 @@ void ResDestroyAvatar::unpack(ByteStream::ReadIterator &iter)
ResGetAvatar::ResGetAvatar(void *user)
: GenericResponse(RESPONSE_GETAVATAR, CHATRESULT_TIMEOUT, user),
m_avatar(NULL)
m_avatar(nullptr)
{
}
@@ -144,7 +144,7 @@ void ResGetAvatar::unpack(ByteStream::ReadIterator &iter)
ResGetAnyAvatar::ResGetAnyAvatar(void* user)
: GenericResponse( RESPONSE_GETANYAVATAR, CHATRESULT_TIMEOUT, user )
, m_avatar( NULL )
, m_avatar( nullptr )
{
}
@@ -181,8 +181,8 @@ void ResGetAnyAvatar::unpack(Base::ByteStream::ReadIterator& iter)
ResAvatarList::ResAvatarList(void *user)
: GenericResponse(RESPONSE_AVATARLIST, CHATRESULT_TIMEOUT, user)
, m_listLength(0)
, m_avatarList(NULL)
, m_cores(NULL)
, m_avatarList(nullptr)
, m_cores(nullptr)
{
}
@@ -214,7 +214,7 @@ void ResAvatarList::unpack(ByteStream::ReadIterator &iter)
ResSetAvatarAttributes::ResSetAvatarAttributes(void *user)
: GenericResponse(RESPONSE_SETAVATARATTRIBUTES, CHATRESULT_TIMEOUT, user),
m_avatar(NULL)
m_avatar(nullptr)
{
}
@@ -248,7 +248,7 @@ void ResSetAvatarAttributes::unpack(ByteStream::ReadIterator &iter)
ResSetAvatarStatusMessage::ResSetAvatarStatusMessage(void *user)
: GenericResponse(RESPONSE_SETSTATUSMESSAGE, CHATRESULT_TIMEOUT, user),
m_avatar(NULL)
m_avatar(nullptr)
{
}
@@ -285,7 +285,7 @@ void ResSetAvatarStatusMessage::unpack(ByteStream::ReadIterator &iter)
ResSetAvatarForwardingEmail::ResSetAvatarForwardingEmail(void *user)
: GenericResponse(RESPONSE_SETAVATAREMAIL, CHATRESULT_TIMEOUT, user),
m_avatar(NULL)
m_avatar(nullptr)
{
}
@@ -312,7 +312,7 @@ void ResSetAvatarForwardingEmail::unpack(ByteStream::ReadIterator &iter)
ResSetAvatarInboxLimit::ResSetAvatarInboxLimit(void *user)
: GenericResponse(RESPONSE_SETAVATARINBOXLIMIT, CHATRESULT_TIMEOUT, user),
m_avatar(NULL)
m_avatar(nullptr)
{
}
@@ -340,7 +340,7 @@ void ResSetAvatarInboxLimit::unpack(ByteStream::ReadIterator &iter)
ResSearchAvatarKeywords::ResSearchAvatarKeywords(void *user)
: GenericResponse(RESPONSE_SETAVATARKEYWORDS, CHATRESULT_TIMEOUT, user),
m_numMatches(0),
m_avatarMatches(NULL)
m_avatarMatches(nullptr)
{
}
@@ -388,8 +388,8 @@ void ResSetAvatarKeywords::unpack(ByteStream::ReadIterator &iter)
ResGetAvatarKeywords::ResGetAvatarKeywords(void *user, unsigned avatarID)
: GenericResponse(RESPONSE_GETAVATARKEYWORDS, CHATRESULT_TIMEOUT, user),
m_avatarID(avatarID),
m_keywordList(NULL),
m_chatStrList(NULL)
m_keywordList(nullptr),
m_chatStrList(nullptr)
{
}
@@ -420,7 +420,7 @@ void ResGetAvatarKeywords::unpack(ByteStream::ReadIterator &iter)
ResGetRoom::ResGetRoom(void *user)
: GenericResponse(RESPONSE_GETROOM, CHATRESULT_TIMEOUT, user),
m_room(NULL),
m_room(nullptr),
m_numExtraRooms(0)
{
}
@@ -448,7 +448,7 @@ void ResGetRoom::unpack(ByteStream::ReadIterator &iter)
ResCreateRoom::ResCreateRoom(void *user, unsigned avatarID)
: GenericResponse(RESPONSE_CREATEROOM, CHATRESULT_TIMEOUT, user),
m_srcAvatarID(avatarID),
m_room(NULL),
m_room(nullptr),
m_numExtraRooms(0)
{
}
@@ -637,8 +637,8 @@ ResFriendStatus::ResFriendStatus(void *user, unsigned avatarID)
: GenericResponse(RESPONSE_FRIENDSTATUS, CHATRESULT_TIMEOUT, user),
m_avatarID(avatarID),
m_listLength(0),
m_friendList(NULL),
m_cores(NULL)
m_friendList(nullptr),
m_cores(nullptr)
{
}
@@ -704,8 +704,8 @@ ResIgnoreStatus::ResIgnoreStatus(void *user, unsigned avatarID)
: GenericResponse(RESPONSE_IGNORESTATUS, CHATRESULT_TIMEOUT, user),
m_avatarID(avatarID),
m_listLength(0),
m_ignoreList(NULL),
m_cores(NULL)
m_ignoreList(nullptr),
m_cores(nullptr)
{
}
@@ -740,7 +740,7 @@ ResEnterRoom::ResEnterRoom(void *user, unsigned avatarID, const ChatUnicodeStrin
m_avatarID(avatarID),
m_destAddress(destAddress.string_data, destAddress.string_length),
m_gotRoomObj(false),
m_room(NULL),
m_room(nullptr),
m_numExtraRooms(0)
{
}
@@ -1012,7 +1012,7 @@ void ResChangeRoomOwner::unpack(ByteStream::ReadIterator &iter)
ResGetRoomSummaries::ResGetRoomSummaries(void *user)
: GenericResponse(RESPONSE_GETROOMSUMMARIES, CHATRESULT_TIMEOUT, user),
m_numRooms(0),
m_roomSummaries(NULL)
m_roomSummaries(nullptr)
{
}
@@ -1132,8 +1132,8 @@ ResGetPersistentMessage::ResGetPersistentMessage(void *user, unsigned srcAvatarI
: GenericResponse(RESPONSE_GETPERSISTENTMESSAGE, CHATRESULT_TIMEOUT, user),
m_srcAvatarID(srcAvatarID),
m_messageID(messageID),
m_core(NULL),
m_header(NULL)
m_core(nullptr),
m_header(nullptr)
{
}
@@ -1167,7 +1167,7 @@ void ResGetPersistentMessage::unpack(ByteStream::ReadIterator &iter)
ResGetMultiplePersistentMessages::ResGetMultiplePersistentMessages(void *user, unsigned srcAvatarID)
: GenericResponse(RESPONSE_GETMULTIPLEPERSISTENTMESSAGES, CHATRESULT_TIMEOUT, user),
m_srcAvatarID(srcAvatarID),
m_messages(NULL)
m_messages(nullptr)
{
}
@@ -1217,8 +1217,8 @@ ResGetPersistentHeaders::ResGetPersistentHeaders(void *user, unsigned srcAvatarI
: GenericResponse(RESPONSE_GETPERSISTENTHEADERS, CHATRESULT_TIMEOUT, user),
m_srcAvatarID(srcAvatarID),
m_listLength(0),
m_headers(NULL),
m_cores(NULL)
m_headers(nullptr),
m_cores(nullptr)
{
}
@@ -1263,8 +1263,8 @@ ResGetPartialPersistentHeaders::ResGetPartialPersistentHeaders(void *user, unsig
: GenericResponse(RESPONSE_PARTIALPERSISTENTHEADERS, CHATRESULT_TIMEOUT, user),
m_srcAvatarID(srcAvatarID),
m_listLength(0),
m_headers(NULL),
m_cores(NULL)
m_headers(nullptr),
m_cores(nullptr)
{
}
@@ -1396,7 +1396,7 @@ void ResUnregisterRoom::unpack(ByteStream::ReadIterator &iter)
}
ResFailoverReloginAvatar::ResFailoverReloginAvatar(unsigned avatarID)
: GenericResponse(RESPONSE_FAILOVER_RELOGINAVATAR, CHATRESULT_TIMEOUT, NULL),
: GenericResponse(RESPONSE_FAILOVER_RELOGINAVATAR, CHATRESULT_TIMEOUT, nullptr),
m_avatarID(avatarID)
{
}
@@ -1414,9 +1414,9 @@ void ResFailoverReloginAvatar::unpack(ByteStream::ReadIterator &iter)
}
ResFailoverRecreateRoom::ResFailoverRecreateRoom(unsigned roomID, bool forced)
: GenericResponse(RESPONSE_FAILOVER_RECREATEROOM, CHATRESULT_TIMEOUT, NULL),
: GenericResponse(RESPONSE_FAILOVER_RECREATEROOM, CHATRESULT_TIMEOUT, nullptr),
m_roomID(roomID),
m_room(NULL),
m_room(nullptr),
m_forced(forced)
{
}
@@ -1478,7 +1478,7 @@ void ResGetFanClubHandle::unpack(ByteStream::ReadIterator &iter)
ResFindAvatarByUID::ResFindAvatarByUID(void *user)
: GenericResponse(RESPONSE_FINDAVATARBYUID, CHATRESULT_TIMEOUT, user),
m_numAvatarsOnline(0),
m_avatars(NULL)
m_avatars(nullptr)
{
}
@@ -1512,7 +1512,7 @@ void ResFindAvatarByUID::unpack(ByteStream::ReadIterator &iter)
}
ResRegistrarGetChatServer::ResRegistrarGetChatServer()
: GenericResponse(RESPONSE_REGISTRAR_GETCHATSERVER, CHATRESULT_TIMEOUT, NULL)
: GenericResponse(RESPONSE_REGISTRAR_GETCHATSERVER, CHATRESULT_TIMEOUT, nullptr)
{
}
@@ -1527,7 +1527,7 @@ void ResRegistrarGetChatServer::unpack(ByteStream::ReadIterator &iter)
}
ResSendApiVersion::ResSendApiVersion()
: GenericResponse(RESPONSE_SETAPIVERSION, CHATRESULT_TIMEOUT, NULL)
: GenericResponse(RESPONSE_SETAPIVERSION, CHATRESULT_TIMEOUT, nullptr)
{
}
@@ -1600,8 +1600,8 @@ void ResRemoveSnoopRoom::unpack(ByteStream::ReadIterator &iter)
ResGetSnoopList::ResGetSnoopList(void *user, unsigned srcAvatarID)
: GenericResponse(RESPONSE_GETSNOOPLIST, CHATRESULT_TIMEOUT, user),
m_srcAvatarID(srcAvatarID),
m_avatarSnoops(NULL),
m_roomSnoops(NULL)
m_avatarSnoops(nullptr),
m_roomSnoops(nullptr)
{
}
@@ -107,7 +107,7 @@ namespace Base
ByteStream::ByteStream() :
allocatedSize(0),
beginReadIterator(),
data(NULL),
data(nullptr),
size(0),
lastPutSize(0)
{
@@ -224,7 +224,7 @@ namespace Base
if(data->size < allocatedSize)
{
unsigned char * tmp = new unsigned char[newSize];
if(data->buffer != NULL)
if(data->buffer != nullptr)
memcpy(tmp, data->buffer, size);
delete[] data->buffer;
data->buffer = tmp;
@@ -35,7 +35,7 @@ bool CAutoLog::Open(const char * filename)
//-------------------------------------
{
if( NULL == filename)
if( nullptr == filename)
return false;
if (pFilename)
@@ -45,13 +45,13 @@ bool CAutoLog::Open(const char * filename)
// Sanitize slashes
char *ptr;
while ((ptr = strchr(pFilename,WRONGSLASH)) != NULL)
while ((ptr = strchr(pFilename,WRONGSLASH)) != nullptr)
*ptr = SLASHCHAR[0];
char strPath[1024];
strcpy(strPath,pFilename);
ptr = strrchr(strPath, SLASHCHAR[0]);
if (ptr != NULL)
if (ptr != nullptr)
{
*ptr = 0;
@@ -59,11 +59,11 @@ bool CAutoLog::Open(const char * filename)
char curdir[128];
// remember current directory
if( getcwd(curdir,sizeof(curdir)) == NULL )
if( getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
return false; // error, can't proceed
}
@@ -74,7 +74,7 @@ bool CAutoLog::Open(const char * filename)
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
return false; // error, can't proceed
}
}
@@ -94,7 +94,7 @@ bool CAutoLog::Open(const char * filename)
{
fprintf(stderr,"CAutoLog::Archive failed to make directory: %s\n", strPath);
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
return false; // error, can't proceed
}
}
@@ -103,7 +103,7 @@ bool CAutoLog::Open(const char * filename)
pFile = fopen(pFilename,"a+");
if( pFile == NULL || pFile == (FILE *)-1)
if( pFile == nullptr || pFile == (FILE *)-1)
{
//fprintf(stderr,"CAutoLog::Open failed to open log file: %s\n",pFilename);
Close();
@@ -123,7 +123,7 @@ bool CAutoLog::Open(const char * filename)
void CAutoLog::Close(void)
//-------------------------------------
{
if( pFile != (FILE *)-1 && pFile != NULL)
if( pFile != (FILE *)-1 && pFile != nullptr)
{
fclose(pFile);
}
@@ -131,7 +131,7 @@ void CAutoLog::Close(void)
free(pFilename);
pFilename = NULL;
pFilename = nullptr;
}
//-------------------------------------
@@ -194,7 +194,7 @@ void CAutoLog::LogDebug(char * format, ...)
void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
//-------------------------------------
{
if (pFile == (FILE *)-1 || pFile == NULL)
if (pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Log called with no file open!\n");
return;
@@ -250,7 +250,7 @@ void CAutoLog::Log(eLogLevel severity, char *fmt, ...)
void CAutoLog::Archive(void)
//-------------------------------------
{
if( pFile == (FILE *)-1 || pFile == NULL)
if( pFile == (FILE *)-1 || pFile == nullptr)
{
//fprintf(stderr,"CAutoLog::Archive called with no file open!\n");
return;
@@ -281,7 +281,7 @@ void CAutoLog::Archive(void)
strcpy(strCurrent,pFilename);
pCurrent = strrchr(strCurrent, SLASHCHAR[0]);
if (pCurrent != NULL)
if (pCurrent != nullptr)
*pCurrent = 0;
else
sprintf(strCurrent,".");
@@ -290,7 +290,7 @@ void CAutoLog::Archive(void)
#ifdef WIN32
// remember current directory
if( getcwd(curdir,sizeof(curdir)) == NULL )
if( getcwd(curdir,sizeof(curdir)) == nullptr )
{
fprintf(stderr,"CAutoLog::Archive failed to get current directory!\n");
return; // error, can't proceed
@@ -324,7 +324,7 @@ void CAutoLog::Archive(void)
#endif
pCurrent = strrchr(pFilename, SLASHCHAR[0]);
if (pCurrent == NULL)
if (pCurrent == nullptr)
pCurrent = pFilename;
else
pCurrent++;
@@ -92,14 +92,14 @@ namespace Base
//-------------------------------------
inline CAutoLog::CAutoLog()
{
pFilename = NULL;
pFilename = nullptr;
pFile = (FILE *)-1;
}
//-------------------------------------
inline CAutoLog::CAutoLog(const char * file)
{
pFilename = NULL;
pFilename = nullptr;
pFile = (FILE *)-1;
Open(file);
}
@@ -135,7 +135,7 @@ int CCmdLine::SplitLine(int argc, char **argv)
bool CCmdLine::IsSwitch(const char *pParam)
{
if (pParam==NULL)
if (pParam==nullptr)
return false;
// switches must non-empty
@@ -204,7 +204,7 @@ StringType CCmdLine::GetSafeArgument(const char *pSwitch, int iIdx, const char *
{
StringType sRet;
if (pDefault!=NULL)
if (pDefault!=nullptr)
sRet = pDefault;
try
@@ -28,7 +28,7 @@ bool CConfig::LoadFile(char * file)
// open file
fp = fopen(file, "r");
if (fp == NULL || fp == (FILE *)-1)
if (fp == nullptr || fp == (FILE *)-1)
{
//fprintf(stderr,"Failed to open config file %s!",file);
return false;
@@ -71,21 +71,21 @@ void CConfig::UnloadFile(void)
//-----------------------------------
{
delete[] pConfig;
pConfig = NULL;
pConfig = nullptr;
}
//-----------------------------------
/// finds a key of the config in memory
// key argument is case-insensitive, but must be upper case in config file
// Returns true for success (passing NULL is a special case returned as success)
// Returns true for success (passing nullptr is a special case returned as success)
bool CConfig::FindKey(char *key)
//-----------------------------------
{
if (pConfig == NULL)
if (pConfig == nullptr)
return false;
// special case...continue with existing key
if (key == NULL)
if (key == nullptr)
return true;
// form the search key
@@ -96,12 +96,12 @@ bool CConfig::FindKey(char *key)
// find the key heading
pCursor = strstr(pConfig,strBuffer);
if (pCursor==NULL)
if (pCursor==nullptr)
return false;
// find the closing bracket of key heading
pCursor = strchr(pCursor,']');
if (pCursor==NULL)
if (pCursor==nullptr)
return false;
pCursor++;
@@ -110,7 +110,7 @@ bool CConfig::FindKey(char *key)
//-----------------------------------
/// extract a number from the config string
// pass the key to find the first number in the list, else NULL to find the next number in the list
// pass the key to find the first number in the list, else nullptr to find the next number in the list
// returns 0 if no number is found, else returns the number
long CConfig::GetLong(char *key)
//-----------------------------------
@@ -133,20 +133,20 @@ long CConfig::GetLong(char *key)
//-----------------------------------
/// extract string (in double-quotes) from the list.
// pass the key to find the first string in the list, else NULL to find the next string in the list
// returns NULL if no string found, else returns a temporary copy of the string (without quotes)
// pass the key to find the first string in the list, else nullptr to find the next string in the list
// returns nullptr if no string found, else returns a temporary copy of the string (without quotes)
char * CConfig::GetString(char *key)
//-----------------------------------
{
if (!FindKey(key))
return NULL;
return nullptr;
// look for start of string or end of key
while (*pCursor && *pCursor != '"' && *pCursor != '[')
pCursor++;
if (*(pCursor++) != '"')
return NULL;
return nullptr;
// until closing quote
int c = 0;
@@ -160,7 +160,7 @@ char * CConfig::GetString(char *key)
}
}
return NULL;
return nullptr;
}
+12 -12
View File
@@ -10,7 +10,7 @@
; list of strings, with code example
# config.FindKey("NUMBERS");
# while (number = config.GetLong(NULL))
# while (number = config.GetLong(nullptr))
# YourHandleNumber(number);
[NUMBERS] 100
200, 300 ; formatting is very flexible as long as numbers are delimited by non-numbers
@@ -23,7 +23,7 @@
; list of strings, with code example
# config.FindKey("HOSTS");
# while (string = config.GetString(NULL))
# while (string = config.GetString(nullptr))
# YourHandleString(string);
[HOSTS]
"127.0.0.1:5999"
@@ -68,16 +68,16 @@ namespace Base
// returns TRUE if key is found.
bool FindKey(char *key);
// extract string from config. If key is NULL, extract next string in list, else extract first string.
// if key was not found, returns NULL
char * GetString(char *key = NULL);
// extract string from config. If key is nullptr, extract next string in list, else extract first string.
// if key was not found, returns nullptr
char * GetString(char *key = nullptr);
// extract number from config. If key is NULL, extract next number in list, else extract first number.
// extract number from config. If key is nullptr, extract next number in list, else extract first number.
// if key was not found, returns 0
long GetLong(char *key = NULL); // extract number from config.
long GetLong(char *key = nullptr); // extract number from config.
// indicate if config file has been loaded
inline bool FileLoaded() { return pConfig == NULL ? false : true; }
inline bool FileLoaded() { return pConfig == nullptr ? false : true; }
private:
char * pConfig; // pointer to file memory
@@ -87,14 +87,14 @@ namespace Base
inline CConfig::CConfig()
{
pConfig = NULL;
pCursor = NULL;
pConfig = nullptr;
pCursor = nullptr;
}
inline CConfig::CConfig(char * file)
{
pConfig = NULL;
pCursor = NULL;
pConfig = nullptr;
pCursor = nullptr;
LoadFile(file);
}
@@ -120,7 +120,7 @@ Logger::Logger(const char *programName,
void Logger::LoggerInit(const char *programName)
{
char buf[1024];
FILE *logDir = NULL;
FILE *logDir = nullptr;
if (0 != (m_combinedLogType & eUseLocalFile))
{
@@ -129,13 +129,13 @@ void Logger::LoggerInit(const char *programName)
{
cmkdir(m_dirPrefix.c_str(), 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
tm now;
time_t t = time(NULL);
time_t t = time(nullptr);
LOGGER_GET_CURR_TIME(now, t);
@@ -153,7 +153,7 @@ void Logger::LoggerInit(const char *programName)
{
cmkdir(buf, 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
@@ -279,7 +279,7 @@ void Logger::addLog(const char *id, unsigned logenum, int level, unsigned size)
else
{
newLog->file = fopen(newLog->filename.c_str(), "a+");
if(newLog->file == NULL)
if(newLog->file == nullptr)
{
printf("Open file %s failed\n", newLog->filename.c_str());
}
@@ -313,7 +313,7 @@ void Logger::addLog(const char *id, unsigned logenum)
else
{
newLog->file = fopen(newLog->filename.c_str(), "a+");
if(newLog->file == NULL)
if(newLog->file == nullptr)
{
printf("Open file %s failed\n", newLog->filename.c_str());
}
@@ -368,7 +368,7 @@ void Logger::logSimple(unsigned logenum, int level, const char *message)
{
return;
}
time_t t = time(NULL);
time_t t = time(nullptr);
LogInfo *info = (*iter).second;
if(level >= info->level)
{
@@ -444,7 +444,7 @@ void Logger::logSimpleWithSys(unsigned logenum, unsigned priority, int level, co
{
return;
}
time_t t = time(NULL);
time_t t = time(nullptr);
LogInfo *info = (*iter).second;
if(level >= info->level)
@@ -514,7 +514,7 @@ void Logger::log(unsigned logenum, int level, const char *message, ...)
// ensure that the buf does not contain any '%' characters.
// prevent crash problem
char *rv;
while((rv = strchr(buf, '%')) != NULL)
while((rv = strchr(buf, '%')) != nullptr)
{
*rv = ' '; // replace with space
}
@@ -546,7 +546,7 @@ void Logger::logWithSys(unsigned logenum, unsigned priority, int level, const ch
{
return;
}
time_t t = time(NULL);
time_t t = time(nullptr);
LogInfo *info = (*iter).second;
if(level >= info->level)
@@ -604,14 +604,14 @@ void Logger::logWithSys(unsigned logenum, unsigned priority, int level, const ch
void Logger::rollDate(time_t t)
{
char buf[80];
FILE *logDir = NULL;
FILE *logDir = nullptr;
logDir = fopen(m_dirPrefix.c_str(), "r+");
if(errno == ENOENT)
{
cmkdir(m_dirPrefix.c_str(), 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
@@ -627,7 +627,7 @@ void Logger::rollDate(time_t t)
{
cmkdir(buf, 0755);
}
else if(logDir != NULL)
else if(logDir != nullptr)
{
fclose(logDir);
}
@@ -711,7 +711,7 @@ void Logger::rollLog(LogInfo *logInfo)
{
std::string newLogName;
char timeStampBuffer[256];
time_t t = time(NULL);
time_t t = time(nullptr);
tm now;
int r;
int nTries = 10;
@@ -34,9 +34,9 @@ namespace Base
bool commit = false;
if (!mLastSampleTime)
mLastSampleTime = time(NULL);
mLastSampleTime = time(nullptr);
if (!mSampleFrequency || mLastSampleTime + mSampleFrequency < (unsigned)time(NULL))
if (!mSampleFrequency || mLastSampleTime + mSampleFrequency < (unsigned)time(nullptr))
{
mSampleTotal++;
mAggregateTotal += value;
@@ -93,7 +93,7 @@ namespace Base
void Destroy(TYPE *object)
{
if (object == NULL)
if (object == nullptr)
return;
#ifdef USE_ALLOCATOR_MUTEX
@@ -142,7 +142,7 @@ namespace Base
void FastDestroy(TYPE *object)
{
if (object == NULL)
if (object == nullptr)
return;
object->~TYPE();
@@ -94,12 +94,12 @@ namespace ucs2
}
////////////////////////////////////////
// target string is a null-terminated C string
// target string is a nullptr-terminated C string
inline string::string(const char * copy) :
mLength(0),
mData(8,0)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!copy)
{
return;
@@ -111,12 +111,12 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *copy++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
}
////////////////////////////////////////
// target string is a C string that may or may not include null characters
// target string is a C string that may or may not include nullptr characters
inline string::string(const std::string & copy) :
mLength(copy.length()),
mData(8,0)
@@ -126,17 +126,17 @@ namespace ucs2
// (2) perform transform to copy the narrow string to our
// wide string
std::transform(copy.begin(), copy.end(), mData.begin(), NarrowToWide);
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength] = 0;
}
////////////////////////////////////////
// target string is a wide null-terminated C string
// target string is a wide nullptr-terminated C string
inline string::string(const char_type * copy) :
mLength(0),
mData(8,0)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!copy)
{
return;
@@ -148,7 +148,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *copy++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
}
@@ -169,7 +169,7 @@ namespace ucs2
inline string & string::operator=(const char * rhs)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
mData[0] = 0;
@@ -182,7 +182,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -195,7 +195,7 @@ namespace ucs2
// (2) perform transform to copy the narrow string to our
// wide string
std::transform(rhs.begin(), rhs.end(), mData.begin(), NarrowToWide);
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength] = 0;
return *this;
}
@@ -203,7 +203,7 @@ namespace ucs2
inline string & string::operator=(const char_type * rhs)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
mData[0] = 0;
@@ -216,7 +216,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -235,7 +235,7 @@ namespace ucs2
inline string & string::operator+=(const char * rhs)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
return *this;
@@ -247,7 +247,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -259,7 +259,7 @@ namespace ucs2
// (2) perform transform to copy the narrow string to our
// wide string
std::transform(rhs.begin(), rhs.end(), mData.begin()+mLength, NarrowToWide);
// (3) ensure null termination
// (3) ensure nullptr termination
mLength += rhs.length();
mData[mLength] = 0;
return *this;
@@ -267,7 +267,7 @@ namespace ucs2
inline string & string::operator+=(const char_type * rhs)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
return *this;
@@ -279,7 +279,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -388,7 +388,7 @@ namespace ucs2
inline string & string::assign(const char_type * rhs)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
mData[0] = 0;
@@ -401,7 +401,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -409,7 +409,7 @@ namespace ucs2
inline string & string::assign(const char_type * rhs, size_type count)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
mData[0] = 0;
@@ -422,7 +422,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -463,7 +463,7 @@ namespace ucs2
inline string & string::assign(const char_type * first, const char_type * last)
{
mLength = 0;
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!first || !last)
{
mData[0] = 0;
@@ -476,14 +476,14 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *first++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
inline string & string::append(const char_type * rhs)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
return *this;
@@ -495,14 +495,14 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
inline string & string::append(const char_type * rhs, size_type count)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!rhs)
{
return *this;
@@ -514,7 +514,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *rhs++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -558,7 +558,7 @@ namespace ucs2
inline string & string::append(const char_type * first, const char_type * last)
{
// (1) protect from null pointer
// (1) protect from nullptr pointer
if (!first || !last)
{
return *this;
@@ -570,7 +570,7 @@ namespace ucs2
reserve(mLength+1);
mData[mLength++] = *first++;
}
// (3) ensure null termination
// (3) ensure nullptr termination
mData[mLength]=0;
return *this;
}
@@ -12,7 +12,7 @@ namespace Base
{
for(unsigned i = 0; i < 31; i++)
{
m_blocks[i] = NULL;
m_blocks[i] = nullptr;
}
}
@@ -21,7 +21,7 @@ namespace Base
// free all allocated memory blocks
for(unsigned i = 0; i < 31; i++)
{
while(m_blocks[i] != NULL)
while(m_blocks[i] != nullptr)
{
unsigned *tmp = m_blocks[i];
m_blocks[i] = (unsigned *)*m_blocks[i];
@@ -36,7 +36,7 @@ namespace Base
void *BlockAllocator::getBlock(unsigned bytes)
{
unsigned accum = 16, bits = 16;
unsigned *handle = NULL;
unsigned *handle = nullptr;
// Perform a binary search looking for the highest bit.
@@ -96,7 +96,7 @@ namespace Base
void BlockAllocator::returnBlock(unsigned *handle)
{
// C++ allows for safe deletion of a NULL pointer
// C++ allows for safe deletion of a nullptr pointer
if(handle)
{
// Update the allocator linked list, insert this entry at the head
@@ -26,8 +26,8 @@ namespace Base
mCond(),
mThreadCount(0)
{
pthread_mutex_init(&mMutex, NULL);
pthread_cond_init(&mCond, NULL);
pthread_mutex_init(&mMutex, nullptr);
pthread_cond_init(&mCond, nullptr);
}
CEvent::~CEvent()
@@ -74,7 +74,7 @@ namespace Base
struct timeval now;
struct timespec abs_timeout;
gettimeofday(&now, NULL);
gettimeofday(&now, nullptr);
abs_timeout.tv_sec = now.tv_sec + timeout/1000;
abs_timeout.tv_nsec = now.tv_usec * 1000 + (timeout%1000)*1000000;
abs_timeout.tv_sec += abs_timeout.tv_nsec / 1000000000;
@@ -77,8 +77,8 @@ namespace Base
CThreadPool::CMember::CMember(CThreadPool * parent) :
mParent(parent),
mFunction(NULL),
mArgument(NULL),
mFunction(nullptr),
mArgument(nullptr),
mSemaphore()
{
StartThread();
@@ -117,8 +117,8 @@ namespace Base
if (mFunction)
{
mFunction(mArgument);
mArgument = NULL;
mFunction = NULL;
mArgument = nullptr;
mFunction = nullptr;
}
else if (mParent->OnDestory(this))
mThreadContinue = false;
@@ -173,7 +173,7 @@ namespace Base
}
////////////////////////////////////////
// (3) Delete the null member threads
// (3) Delete the nullptr member threads
mMutex.Lock();
while (!mNullMember.empty())
{
@@ -224,7 +224,7 @@ namespace Base
}
////////////////////////////////////////
// (2) Delete any null member threads.
// (2) Delete any nullptr member threads.
while (!mNullMember.empty())
{
delete mNullMember.front();
@@ -501,8 +501,8 @@ namespace soe
}
else
{
//find null terminator, if don't find it before maxLen, then err
const unsigned char *strEnd = NULL;
//find nullptr terminator, if don't find it before maxLen, then err
const unsigned char *strEnd = nullptr;
unsigned strLen = 0;
for (;strLen<maxLen && strLen < size;strLen++)
{
@@ -513,7 +513,7 @@ namespace soe
break;
}
}
if (strEnd == NULL)
if (strEnd == nullptr)
return 0;
data.assign((const char *)stream, (const char *)strEnd);
@@ -107,7 +107,7 @@ unsigned GenericAPICore::submitRequest(GenericRequest *req, GenericResponse *res
}
req->setTrack(m_currTrack);
res->setTrack(m_currTrack);
time_t timeout = time(NULL) + m_requestTimeout;
time_t timeout = time(nullptr) + m_requestTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
@@ -125,7 +125,7 @@ unsigned GenericAPICore::submitRequest(GenericRequest *req, GenericResponse *res
}
req->setTrack(m_currTrack);
res->setTrack(m_currTrack);
time_t timeout = time(NULL) + reqTimeout;
time_t timeout = time(nullptr) + reqTimeout;
req->setTimeout(timeout);
res->setTimeout(timeout);
@@ -140,7 +140,7 @@ void GenericAPICore::process()
GenericResponse *res;
// Process timeout on pending requests - regardless of whether processing is suspended or not
while((m_outCount > 0) && ((req = m_outboundQueue.front().first)->getTimeout() <= time(NULL)))
while((m_outCount > 0) && ((req = m_outboundQueue.front().first)->getTimeout() <= time(nullptr)))
{
--m_outCount;
res = m_outboundQueue.front().second;
@@ -152,7 +152,7 @@ void GenericAPICore::process()
}
// Process timeout on pending responses
while((m_pendingCount > 0) && ((res = (*m_pending.begin()).second)->getTimeout() <= time(NULL)))
while((m_pendingCount > 0) && ((res = (*m_pending.begin()).second)->getTimeout() <= time(nullptr)))
{
--m_pendingCount;
m_pending.erase(m_pending.begin());
@@ -165,7 +165,7 @@ void GenericAPICore::process()
while(m_outCount > 0)
{
GenericConnection *con = getNextActiveConnection();
if (con != NULL)
if (con != nullptr)
{
pair<GenericRequest *, GenericResponse *> out_pair = m_outboundQueue.front();
@@ -184,7 +184,7 @@ void GenericAPICore::process()
else
{
#ifdef USE_SERIALIZE_LIB
const unsigned char *msgBuf = NULL;
const unsigned char *msgBuf = nullptr;
unsigned msgSize = 0;
msgBuf = req->pack(msgSize);
con->Send(msgBuf, msgSize);
@@ -222,7 +222,7 @@ GenericConnection *GenericAPICore::getNextActiveConnection()
unsigned startIndex = m_nextConnectionIndex;
unsigned maxIndex = m_serverConnections.size() - 1;
GenericConnection *con = NULL;
GenericConnection *con = nullptr;
//loop until we find an active connection, or until we get back
// to where we started
@@ -242,7 +242,7 @@ GenericConnection *GenericAPICore::getNextActiveConnection()
//went past end of vector, start back at 0
m_nextConnectionIndex = 0;
}
}while (con == NULL && m_nextConnectionIndex != startIndex);
}while (con == nullptr && m_nextConnectionIndex != startIndex);
return con;
}
@@ -28,7 +28,7 @@ unsigned GenericConnection::ms_crcBytes = 0;
GenericConnection::GenericConnection(const char *host, short port, GenericAPICore *apiCore, unsigned reconnectTimeout, unsigned noDataTimeoutSecs, unsigned noAckTimeoutSecs, unsigned incomingBufSizeInKB, unsigned outgoingBufSizeInKB, unsigned keepAlive, unsigned maxRecvMessageSizeInKB, unsigned holdTime)
: m_bConnected(false),
m_apiCore(apiCore),
m_con(NULL),
m_con(nullptr),
m_host(host),
m_nextHost(host),
m_port(port),
@@ -72,8 +72,8 @@ GenericConnection::~GenericConnection()
{
if(m_con)
{
m_con->SetHandler(NULL);
m_con->Disconnect();//don't worry about onterminated being called, we've set it's handler to null, so it wont
m_con->SetHandler(nullptr);
m_con->Disconnect();//don't worry about onterminated being called, we've set it's handler to nullptr, so it wont
m_con->Release();
}
@@ -96,7 +96,7 @@ void GenericConnection::disconnect()
{
m_con->Disconnect();
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
m_con = NULL;
m_con = nullptr;
}
m_conState = CON_DISCONNECT;
m_bConnected = false;
@@ -112,7 +112,7 @@ void GenericConnection::OnTerminated(UdpConnection *con)
if(m_con)
{
m_con->Release();
m_con = NULL;
m_con = nullptr;
}
m_conState = CON_DISCONNECT;
m_bConnected = false;
@@ -146,7 +146,7 @@ void GenericConnection::OnRoutePacket(UdpConnection *con, const unsigned char *d
get(iter, type);
get(iter, track);
#endif
GenericResponse *res = NULL;
GenericResponse *res = nullptr;
// the following if block is a temporary fix that prevents
// a crash with a game team in which they occasionally find
@@ -208,7 +208,7 @@ void GenericConnection::process(bool giveTime)
{
m_con->SetHandler(this);
m_conState = CON_NEGOTIATE;
m_conTimeout = time(NULL) + m_reconnectTimeout;
m_conTimeout = time(nullptr) + m_reconnectTimeout;
}
break;
case CON_NEGOTIATE:
@@ -225,12 +225,12 @@ void GenericConnection::process(bool giveTime)
m_apiCore->OnConnect(m_host.c_str(), m_port);
m_bConnected = true;
}
else if(time(NULL) > m_conTimeout)
else if(time(nullptr) > m_conTimeout)
{
// we did not connect
m_con->Disconnect();
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
m_con = NULL;
m_con = nullptr;
m_conState = CON_DISCONNECT;
m_bConnected = false;
}
@@ -246,7 +246,7 @@ void GenericConnection::process(bool giveTime)
{
m_con->Disconnect();
//no need to release, since callback to onTerminated releases it, and callback is allways made m_con->Release();
m_con = NULL;
m_con = nullptr;
}
}
@@ -96,7 +96,7 @@ void UdpConnection::Init(UdpManager *udpManager, UdpPlatformAddress destIp, int
mLastClockSyncTime = 0;
mDataHoldTime = 0;
mGettingTime = false;
mHandler = NULL;
mHandler = nullptr;
mOtherSideProtocolVersion = 0;
mNoDataTimeout = mUdpManager->mParams.noDataTimeout;
@@ -108,7 +108,7 @@ void UdpConnection::Init(UdpManager *udpManager, UdpPlatformAddress destIp, int
mIcmpErrorRetryStartStamp = 0; // when the timer started for ICMP error retry delay (gets reset on a successful packet receive)
mPortRemapRequestStartStamp = 0;
mEncryptXorBuffer = NULL;
mEncryptXorBuffer = nullptr;
mEncryptExpansionBytes = 0;
mOrderedCountOutgoing = 0;
mOrderedCountOutgoing2 = 0;
@@ -120,7 +120,7 @@ void UdpConnection::Init(UdpManager *udpManager, UdpPlatformAddress destIp, int
mConnectAttemptTimeout = 0;
mConnectionCreateTime = mUdpManager->CachedClock();
mSimulateOutgoingQueueBytes = 0;
mPassThroughData = NULL;
mPassThroughData = nullptr;
mSilentDisconnect = false;
mLastSendBin = 0;
@@ -140,7 +140,7 @@ UdpConnection::~UdpConnection()
{
UdpGuard myGuard(&mGuard);
assert(mUdpManager == NULL); // this should not be possible, since the UdpManager holds a reference to us until we are disconnected and disassociated from the manager. If you are hitting this, then odds are the application is releasing the UdpConnection object more times than it should
assert(mUdpManager == nullptr); // this should not be possible, since the UdpManager holds a reference to us until we are disconnected and disassociated from the manager. If you are hitting this, then odds are the application is releasing the UdpConnection object more times than it should
for (int i = 0; i < cReliableChannelCount; i++)
delete mChannel[i];
@@ -189,7 +189,7 @@ void UdpConnection::InternalDisconnect(int flushTimeout, DisconnectReason reason
if (mStatus == cStatusNegotiating)
flushTimeout = 0;
if (mUdpManager != NULL)
if (mUdpManager != nullptr)
{
if (flushTimeout > 0)
{
@@ -219,7 +219,7 @@ void UdpConnection::InternalDisconnect(int flushTimeout, DisconnectReason reason
}
UdpManager *holdUdpManager = mUdpManager;
mUdpManager = NULL;
mUdpManager = nullptr;
mStatus = cStatusDisconnected;
// only hold a reference to the UdpManager if it is not currently being destructed.
@@ -274,7 +274,7 @@ bool UdpConnection::Send(UdpChannel channel, const void *data, int dataLen)
if (dataLen == 0) // zero length packets are ignored
return(false);
assert(data != NULL); // can't send a null packet
assert(data != nullptr); // can't send a nullptr packet
// zero-escape application packets that start with 0
if ((*(const udp_uchar *)data) == 0)
@@ -290,7 +290,7 @@ bool UdpConnection::Send(UdpChannel channel, const LogicalPacket *packet)
{
UdpGuard myGuard(&mGuard);
assert(packet != NULL); // can't send a null packet
assert(packet != nullptr); // can't send a nullptr packet
if (mStatus != cStatusConnected) // if we are no longer connected
return(false);
@@ -337,7 +337,7 @@ bool UdpConnection::InternalSend(UdpChannel channel, const udp_uchar *data, int
{
udp_uchar *bufPtr = tempBuffer;
memcpy(bufPtr, data, dataLen);
if (data2 != NULL)
if (data2 != nullptr)
memcpy(bufPtr + dataLen, data2, dataLen2);
PhysicalSend(bufPtr, totalDataLen, true);
return(true);
@@ -350,9 +350,9 @@ bool UdpConnection::InternalSend(UdpChannel channel, const udp_uchar *data, int
bufPtr[1] = cUdpPacketOrdered;
UdpMisc::PutValue16(bufPtr + 2, (udp_ushort)(++mOrderedCountOutgoing & 0xffff));
memcpy(bufPtr + 4, data, dataLen);
if (data2 != NULL)
if (data2 != nullptr)
memcpy(bufPtr + 4 + dataLen, data2, dataLen2);
BufferedSend(bufPtr, totalDataLen + 4, NULL, 0, true);
BufferedSend(bufPtr, totalDataLen + 4, nullptr, 0, true);
return(true);
break;
}
@@ -363,7 +363,7 @@ bool UdpConnection::InternalSend(UdpChannel channel, const udp_uchar *data, int
bufPtr[1] = cUdpPacketOrdered2;
UdpMisc::PutValue16(bufPtr + 2, (udp_ushort)(++mOrderedCountOutgoing2 & 0xffff));
memcpy(bufPtr + 4, data, dataLen);
if (data2 != NULL)
if (data2 != nullptr)
memcpy(bufPtr + 4 + dataLen, data2, dataLen2);
PhysicalSend(bufPtr, totalDataLen + 4, true);
return(true);
@@ -375,7 +375,7 @@ bool UdpConnection::InternalSend(UdpChannel channel, const udp_uchar *data, int
case cUdpChannelReliable4:
{
int num = channel - cUdpChannelReliable1;
if (mChannel[num] == NULL)
if (mChannel[num] == nullptr)
mChannel[num] = new UdpReliableChannel(num, this, &mUdpManager->mParams.reliable[num]);
mChannel[num]->Send(data, dataLen, data2, dataLen2);
return(true);
@@ -410,9 +410,9 @@ void UdpConnection::GetStats(UdpConnectionStatistics *cs)
{
UdpGuard myGuard(&mGuard);
assert(cs != NULL);
assert(cs != nullptr);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
*cs = mConnectionStats;
@@ -428,7 +428,7 @@ void UdpConnection::GetStats(UdpConnectionStatistics *cs)
if (cs->syncTheirSent > 0)
cs->percentReceivedSuccess = (float)cs->syncOurReceived / (float)cs->syncTheirSent;
cs->reliableAveragePing = 0;
if (mChannel[0] != NULL)
if (mChannel[0] != nullptr)
cs->reliableAveragePing = mChannel[0]->GetAveragePing();
}
@@ -437,7 +437,7 @@ void UdpConnection::ProcessRawPacket(const UdpManager::PacketHistoryEntry *e)
UdpRef ref(this);
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
if (e->mLen == 0)
@@ -572,7 +572,7 @@ void UdpConnection::ProcessRawPacket(const UdpManager::PacketHistoryEntry *e)
*decryptPtr++ = finalStart[1];
int len = (this->*(mDecryptFunction[j]))(decryptPtr, finalStart + 2, finalLen - 2);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
if (len == -1)
@@ -627,7 +627,7 @@ void UdpConnection::ProcessCookedPacket(const udp_uchar *data, int dataLen)
{
udp_uchar buf[256];
udp_uchar *bufPtr;
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
if (data[0] == 0 && dataLen > 1)
@@ -826,7 +826,7 @@ void UdpConnection::ProcessCookedPacket(const udp_uchar *data, int dataLen)
// (while processing this packet) ended up touching the packet-data and corrupting the next
// packet in the multi-sequence.
CallbackCorruptPacket(data, dataLen, cUdpCorruptionReasonMultiPacket);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
}
else
@@ -943,7 +943,7 @@ void UdpConnection::ProcessCookedPacket(const udp_uchar *data, int dataLen)
case cUdpPacketFragment4:
{
int num = (data[1] - cUdpPacketReliable1) % cReliableChannelCount;
if (mChannel[num] == NULL)
if (mChannel[num] == nullptr)
mChannel[num] = new UdpReliableChannel(num, this, &mUdpManager->mParams.reliable[num]);
mChannel[num]->ReliablePacket(data, dataLen);
break;
@@ -954,7 +954,7 @@ void UdpConnection::ProcessCookedPacket(const udp_uchar *data, int dataLen)
case cUdpPacketAck4:
{
int num = data[1] - cUdpPacketAck1;
if (mChannel[num] != NULL)
if (mChannel[num] != nullptr)
mChannel[num]->AckPacket(data, dataLen);
break;
}
@@ -964,7 +964,7 @@ void UdpConnection::ProcessCookedPacket(const udp_uchar *data, int dataLen)
case cUdpPacketAckAll4:
{
int num = data[1] - cUdpPacketAckAll1;
if (mChannel[num] != NULL)
if (mChannel[num] != nullptr)
mChannel[num]->AckAllPacket(data, dataLen);
break;
}
@@ -1015,7 +1015,7 @@ void UdpConnection::FlagPortUnreachable()
void UdpConnection::GiveTime(bool fromManager)
{
UdpGuard myGuard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
if (fromManager && GetRefCount() == 2)
@@ -1115,11 +1115,11 @@ void UdpConnection::InternalGiveTime()
int totalPendingBytes = 0;
for (int i = 0; i < cReliableChannelCount; i++)
{
if (mChannel[i] != NULL)
if (mChannel[i] != nullptr)
{
totalPendingBytes += mChannel[i]->TotalPendingBytes();
int myNext = mChannel[i]->GiveTime();
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return; // giving the reliable channel time caused it to callback the application which may disconnect us
nextSchedule = udpMin(nextSchedule, myNext);
}
@@ -1208,7 +1208,7 @@ void UdpConnection::InternalGiveTime()
break;
}
if (mUdpManager != NULL)
if (mUdpManager != nullptr)
{
// safety to prevent us for scheduling ourselves for a time period that has already passed,
// as doing so could result in infinite looping in the priority queue processing.
@@ -1227,7 +1227,7 @@ int UdpConnection::TotalPendingBytes() const
int total = 0;
for (int i = 0; i < cReliableChannelCount; i++)
{
if (mChannel[i] != NULL)
if (mChannel[i] != nullptr)
total += mChannel[i]->TotalPendingBytes();
}
return(total);
@@ -1293,7 +1293,7 @@ void UdpConnection::ExpireReceiveBin()
void UdpConnection::PhysicalSend(const udp_uchar *data, int dataLen, bool appendAllowed)
{
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
// if we attempt to do a physical send (ie. encrypt/compress/crc a packet) while we are not connected
@@ -1322,7 +1322,7 @@ void UdpConnection::PhysicalSend(const udp_uchar *data, int dataLen, bool append
// we know this internal packet will not be a connect or confirm packet since they are sent directly to RawSend to avoid getting encrypted
*destPtr++ = finalStart[1];
int len = (this->*(mEncryptFunction[j]))(destPtr, finalStart + 2, finalLen - 2);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return;
// if this assert triggers, it means the encryption pass expanded the size of the encrypted
@@ -1393,8 +1393,8 @@ void UdpConnection::PhysicalSend(const udp_uchar *data, int dataLen, bool append
// can note where the ack was placed and replace it
udp_uchar *UdpConnection::BufferedSend(const udp_uchar *data, int dataLen, const udp_uchar *data2, int dataLen2, bool appendAllowed)
{
if (mUdpManager == NULL)
return(NULL);
if (mUdpManager == nullptr)
return(nullptr);
int used = (int)(mMultiBufferPtr - mMultiBufferData);
int actualMaxDataHoldSize = udpMin(mUdpManager->mParams.maxDataHoldSize, mConnectionConfig.maxRawPacketSize);
@@ -1409,7 +1409,7 @@ udp_uchar *UdpConnection::BufferedSend(const udp_uchar *data, int dataLen, const
FlushMultiBuffer();
// now send it (the multi-buffer is empty if you need to use it temporarily to concatenate two data chunks -- it is large enough to hold the largest raw packet)
if (data2 != NULL)
if (data2 != nullptr)
{
memcpy(mMultiBufferData, data, dataLen);
memcpy(mMultiBufferData + dataLen, data2, dataLen2);
@@ -1417,7 +1417,7 @@ udp_uchar *UdpConnection::BufferedSend(const udp_uchar *data, int dataLen, const
}
else
PhysicalSend(data, dataLen, appendAllowed);
return(NULL);
return(nullptr);
}
// if this data will not fit into buffer
@@ -1445,7 +1445,7 @@ udp_uchar *UdpConnection::BufferedSend(const udp_uchar *data, int dataLen, const
udp_uchar *placementPtr = mMultiBufferPtr;
memcpy(mMultiBufferPtr, data, dataLen);
mMultiBufferPtr += dataLen;
if (data2 != NULL)
if (data2 != nullptr)
{
memcpy(mMultiBufferPtr, data2, dataLen2);
mMultiBufferPtr += dataLen2;
@@ -1454,7 +1454,7 @@ udp_uchar *UdpConnection::BufferedSend(const udp_uchar *data, int dataLen, const
if ((mMultiBufferPtr - mMultiBufferData) >= actualMaxDataHoldSize)
{
FlushMultiBuffer();
placementPtr = NULL; // it got flushed
placementPtr = nullptr; // it got flushed
}
return(placementPtr);
}
@@ -1474,7 +1474,7 @@ void UdpConnection::FlushMultiBuffer()
// notify all the reliable channels to clear their buffered acks
for (int i = 0; i < cReliableChannelCount; i++)
{
if (mChannel[i] != NULL)
if (mChannel[i] != nullptr)
{
mChannel[i]->ClearBufferedAck();
}
@@ -1684,7 +1684,7 @@ void UdpConnection::SetupEncryptModel()
mEncryptExpansionBytes += 0;
// set up encrypt buffer (random numbers generated based on seed)
if (mEncryptXorBuffer == NULL)
if (mEncryptXorBuffer == nullptr)
{
int len = ((mUdpManager->mParams.maxRawPacketSize + 1) / 4) * 4;
mEncryptXorBuffer = new udp_uchar[len];
@@ -1718,7 +1718,7 @@ void UdpConnection::GetChannelStatus(UdpChannel channel, ChannelStatus *channelS
case cUdpChannelReliable2:
case cUdpChannelReliable3:
case cUdpChannelReliable4:
if (mChannel[channel - cUdpChannelReliable1] != NULL)
if (mChannel[channel - cUdpChannelReliable1] != nullptr)
{
mChannel[channel - cUdpChannelReliable1]->GetChannelStatus(channelStatus);
}
@@ -1763,7 +1763,7 @@ char *UdpConnection::GetDestinationString(char *buf, int bufLen) const
UdpGuard myGuard(&mGuard);
if (bufLen < 22)
return(NULL);
return(nullptr);
UdpPlatformAddress ip = GetDestinationIp();
int port = GetDestinationPort();
char hold[256];
@@ -1794,7 +1794,7 @@ void UdpConnection::OnRoutePacket(const udp_uchar *data, int dataLen)
{
UdpGuard myGuard(&mHandlerGuard);
if (mHandler != NULL)
if (mHandler != nullptr)
{
mHandler->OnRoutePacket(this, data, dataLen);
}
@@ -1814,7 +1814,7 @@ void UdpConnection::OnRoutePacket(const udp_uchar *data, int dataLen)
void UdpConnection::OnConnectComplete()
{
UdpGuard myGuard(&mHandlerGuard);
if (mHandler != NULL)
if (mHandler != nullptr)
{
mHandler->OnConnectComplete(this);
}
@@ -1823,7 +1823,7 @@ void UdpConnection::OnConnectComplete()
void UdpConnection::OnTerminated()
{
UdpGuard myGuard(&mHandlerGuard);
if (mHandler != NULL)
if (mHandler != nullptr)
{
mHandler->OnTerminated(this);
}
@@ -1832,7 +1832,7 @@ void UdpConnection::OnTerminated()
void UdpConnection::OnCrcReject(const udp_uchar *data, int dataLen)
{
UdpGuard myGuard(&mHandlerGuard);
if (mHandler != NULL)
if (mHandler != nullptr)
{
mHandler->OnCrcReject(this, data, dataLen);
}
@@ -1841,7 +1841,7 @@ void UdpConnection::OnCrcReject(const udp_uchar *data, int dataLen)
void UdpConnection::OnPacketCorrupt(const udp_uchar *data, int dataLen, UdpCorruptionReason reason)
{
UdpGuard myGuard(&mHandlerGuard);
if (mHandler != NULL)
if (mHandler != nullptr)
{
mHandler->OnPacketCorrupt(this, data, dataLen, reason);
}
@@ -153,7 +153,7 @@ class UdpConnection : public UdpGuardedRefCount, public PriorityQueueMember, pub
int ConnectionAge() const;
// returns the UdpManager object that is managing this connection
// will return NULL if the connection has been disconnected for some reason (because disconnecting severes the link to UdpManager)
// will return nullptr if the connection has been disconnected for some reason (because disconnecting severes the link to UdpManager)
UdpManager *GetUdpManager() const;
// returns the 32-bit encryption-code that was negotiated as part of the connection-establishment process.
@@ -234,9 +234,9 @@ class UdpConnection : public UdpGuardedRefCount, public PriorityQueueMember, pub
friend class UdpManager;
friend class UdpReliableChannel;
// note: if connectPacket is NULL, that means this connection object is being created to establish
// note: if connectPacket is nullptr, that means this connection object is being created to establish
// a new connection to the specified ip/port (ie. the connection starts out in cStatusNegotiating mode)
// if connectPacket is non-NULL, that menas this connection object is being created to handle an
// if connectPacket is non-nullptr, that menas this connection object is being created to handle an
// incoming connect request and it will start out in cStatusConnected mode.
UdpConnection(UdpManager *udpManager, UdpPlatformAddress destIp, int destPort, int timeout); // starts connection-establishment protocol
UdpConnection(UdpManager *udpManager, const UdpManager::PacketHistoryEntry *e); // starts already connected, replying to connection request
@@ -281,7 +281,7 @@ class UdpConnection : public UdpGuardedRefCount, public PriorityQueueMember, pub
void RawSend(const udp_uchar *data, int dataLen); // nothing happens to the data here, it is given to the udpmanager and sent out the port
void PhysicalSend(const udp_uchar *data, int dataLen, bool appendAllowed); // sends a physical packet (encrypts and adds crc bytes)
udp_uchar *BufferedSend(const udp_uchar *data, int dataLen, const udp_uchar *data2, int dataLen2, bool appendAllowed); // buffers logical packets waiting til we have more data (makes multi-packets)
bool InternalSend(UdpChannel channel, const udp_uchar *data, int dataLen, const udp_uchar *data2 = NULL, int dataLen2 = 0);
bool InternalSend(UdpChannel channel, const udp_uchar *data, int dataLen, const udp_uchar *data2 = nullptr, int dataLen2 = 0);
void InternalGiveTime();
void InternalDisconnect(int flushTimeout, DisconnectReason reason);
@@ -527,7 +527,7 @@ inline void UdpConnection::ScheduleTimeNow()
// prevents us from reprioritizing to 0, only to shortly thereafter be reprioritized to where we actually belong.
if (!mGettingTime)
{
if (mUdpManager != NULL)
if (mUdpManager != nullptr)
mUdpManager->SetPriority(this, 0);
}
}
@@ -575,7 +575,7 @@ inline int UdpConnection::LastReceive(UdpClockStamp useStamp) const
inline int UdpConnection::LastReceive() const
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
return(mUdpManager->CachedClockElapsed(mLastReceiveTime));
}
@@ -583,7 +583,7 @@ inline int UdpConnection::LastReceive() const
inline int UdpConnection::ConnectionAge() const
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
return(mUdpManager->CachedClockElapsed(mConnectionCreateTime));
}
@@ -591,7 +591,7 @@ inline int UdpConnection::ConnectionAge() const
inline int UdpConnection::LastSend() const
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
return(mUdpManager->CachedClockElapsed(mLastSendTime));
}
@@ -599,7 +599,7 @@ inline int UdpConnection::LastSend() const
inline udp_ushort UdpConnection::ServerSyncStampShort() const
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
return((udp_ushort)(mUdpManager->LocalSyncStampShort() + (mSyncTimeDelta & 0xffff)));
}
@@ -607,7 +607,7 @@ inline udp_ushort UdpConnection::ServerSyncStampShort() const
inline udp_uint UdpConnection::ServerSyncStampLong() const
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
return(mUdpManager->LocalSyncStampLong() + mSyncTimeDelta);
}
@@ -649,7 +649,7 @@ inline UdpConnection::DisconnectReason UdpConnection::GetOtherSideDisconnectReas
inline int UdpConnection::OutgoingBytesLastSecond()
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
ExpireSendBin();
@@ -659,7 +659,7 @@ inline int UdpConnection::OutgoingBytesLastSecond()
inline int UdpConnection::IncomingBytesLastSecond()
{
UdpGuard guard(&mGuard);
if (mUdpManager == NULL)
if (mUdpManager == nullptr)
return(0);
ExpireReceiveBin();
@@ -101,7 +101,7 @@ bool UdpPlatformDriver::SocketOpen(int port, int incomingBufferSize, int outgoin
addr_loc.sin_family = PF_INET;
addr_loc.sin_port = htons((unsigned short)port);
addr_loc.sin_addr.s_addr = htonl(INADDR_ANY);
if (bindIpAddress != NULL && bindIpAddress[0] != 0)
if (bindIpAddress != nullptr && bindIpAddress[0] != 0)
{
unsigned long address = inet_addr(bindIpAddress);
if (address != INADDR_NONE)
@@ -201,7 +201,7 @@ bool UdpPlatformDriver::GetHostByName(UdpPlatformAddress *ipAddress, const char
{
struct hostent *lphp;
lphp = gethostbyname(hostName);
if (lphp == NULL)
if (lphp == nullptr)
{
address = 0;
}
@@ -223,7 +223,7 @@ bool UdpPlatformDriver::GetSelfAddress(UdpPlatformAddress *ipAddress, bool prefe
if (gethostname(hostname, sizeof(hostname)) == 0)
{
struct hostent *entry = gethostbyname(hostname);
if (entry != NULL)
if (entry != nullptr)
{
for (int i = 0; entry->h_addr_list[i] != 0; i++)
{
@@ -273,7 +273,7 @@ UdpClockStamp UdpPlatformDriver::Clock()
UdpGuard guard(&mData->clockGuard);
struct timeval tv;
gettimeofday(&tv, NULL);
gettimeofday(&tv, nullptr);
UdpClockStamp cs = static_cast<UdpClockStamp>(tv.tv_sec) * 1000 + static_cast<UdpClockStamp>(tv.tv_usec / 1000);
cs += mData->currentCorrection;
if (cs < mData->lastStamp)
@@ -319,7 +319,7 @@ int IcmpReceive(SOCKET socket, unsigned *address, int *port)
return(-1);
struct cmsghdr *cmsg;
for(cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(&msgh, cmsg))
for(cmsg = CMSG_FIRSTHDR(&msgh); cmsg != nullptr; cmsg = CMSG_NXTHDR(&msgh, cmsg))
{
if(cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_RECVERR)
{
@@ -378,7 +378,7 @@ void *GoThread(void *param)
thread->mThreadData->running = false;
thread->mThreadData->handle = 0;
thread->Release();
return(NULL);
return(nullptr);
}
UdpPlatformThreadObject::~UdpPlatformThreadObject()
@@ -435,7 +435,7 @@ char *UdpPlatformAddress::GetAddress(char *buffer, int bufferLen) const
*buffer = 0;
return(buffer);
}
assert(buffer != NULL);
assert(buffer != nullptr);
sprintf(buffer, "%d.%d.%d.%d", mData[0], mData[1], mData[2], mData[3]);
return(buffer);
}
@@ -444,7 +444,7 @@ void UdpPlatformAddress::SetAddress(const char *address)
{
for (int i = 0; i < 4; i++)
{
mData[i] = (unsigned char)strtol(address, NULL, 10);
mData[i] = (unsigned char)strtol(address, nullptr, 10);
while (*address >= '0' && *address <= '9')
address++;
if (*address != 0)
@@ -102,7 +102,7 @@ bool UdpPlatformDriver::SocketOpen(int port, int incomingBufferSize, int outgoin
addr_loc.sin_family = PF_INET;
addr_loc.sin_port = htons((unsigned short)port);
addr_loc.sin_addr.s_addr = htonl(INADDR_ANY);
if (bindIpAddress != NULL && bindIpAddress[0] != 0)
if (bindIpAddress != nullptr && bindIpAddress[0] != 0)
{
unsigned long address = inet_addr(bindIpAddress);
if (address != INADDR_NONE)
@@ -205,7 +205,7 @@ bool UdpPlatformDriver::GetHostByName(UdpPlatformAddress *ipAddress, const char
{
struct hostent *lphp;
lphp = gethostbyname(hostName);
if (lphp == NULL)
if (lphp == nullptr)
{
address = 0;
}
@@ -227,7 +227,7 @@ bool UdpPlatformDriver::GetSelfAddress(UdpPlatformAddress *ipAddress, bool prefe
if (gethostname(hostname, sizeof(hostname)) == 0)
{
struct hostent *entry = gethostbyname(hostname);
if (entry != NULL)
if (entry != nullptr)
{
for (int i = 0; entry->h_addr_list[i] != 0; i++)
{
@@ -329,10 +329,10 @@ unsigned __stdcall GoThread(void *param)
UdpPlatformThreadObject::~UdpPlatformThreadObject()
{
#ifndef UDPLIBRARY_SINGLE_THREAD
if (mThreadData->handle != NULL)
if (mThreadData->handle != nullptr)
{
CloseHandle(mThreadData->handle);
mThreadData->handle = NULL;
mThreadData->handle = nullptr;
}
#endif
delete mThreadData;
@@ -343,7 +343,7 @@ void UdpPlatformThreadObject::Start()
AddRef();
#ifndef UDPLIBRARY_SINGLE_THREAD
unsigned threadId;
mThreadData->handle = (HANDLE)_beginthreadex(NULL, 0, &GoThread, this, 0, &threadId);
mThreadData->handle = (HANDLE)_beginthreadex(nullptr, 0, &GoThread, this, 0, &threadId);
#else
GoThread(this); // run it inline in main thread (blocks til it's finished, so odds are it won't work, but they shouldn't be using it anyhow in this mode)
#endif
@@ -352,7 +352,7 @@ void UdpPlatformThreadObject::Start()
UdpPlatformThreadObject::UdpPlatformThreadObject()
{
mThreadData = new UdpPlatformThreadData;
mThreadData->handle = NULL;
mThreadData->handle = nullptr;
mThreadData->running = false;
}
@@ -389,7 +389,7 @@ char *UdpPlatformAddress::GetAddress(char *buffer, int bufferLen) const
*buffer = 0;
return(buffer);
}
assert(buffer != NULL);
assert(buffer != nullptr);
sprintf(buffer, "%d.%d.%d.%d", mData[0], mData[1], mData[2], mData[3]);
return(buffer);
}
@@ -38,11 +38,11 @@ template<typename T> class HashTable
bool Remove(T& obj, int hashValue);
void Reset(); // removes all entries from the table
T *FindFirst(int hashValue) const; // returns NULL if not found
T *FindNext(T *prevResult) const; // returns NULL if not found
T *FindFirst(int hashValue) const; // returns nullptr if not found
T *FindNext(T *prevResult) const; // returns nullptr if not found
T *WalkFirst() const; // returns NULL if not found
T *WalkNext(T *prevResult) const; // returns NULL if not found
T *WalkFirst() const; // returns nullptr if not found
T *WalkNext(T *prevResult) const; // returns nullptr if not found
void Resize(int hashSize); // the actual hash size will be rounded up to the next larger prime number (very slow, not recommended)
void GetStatistics(HashTableStatistics *stats) const;
@@ -64,7 +64,7 @@ template<typename T> class HashTable
template<typename T> HashTable<T>::HashTable(int hashSize)
{
mTable = NULL;
mTable = nullptr;
mTableSize = 0;
mEntryCount = 0;
mStatUsedSlots = 0;
@@ -84,9 +84,9 @@ template<typename T> void HashTable<T>::Insert(T& obj, int hashValue)
entry->hashValue = hashValue;
int spot = ((unsigned)hashValue) % mTableSize;
if (mTable[spot] == NULL)
if (mTable[spot] == nullptr)
{
entry->nextEntry = NULL;
entry->nextEntry = nullptr;
mTable[spot] = entry;
mStatUsedSlots++;
}
@@ -103,14 +103,14 @@ template<typename T> bool HashTable<T>::Remove(T& obj, int hashValue)
int spot = ((unsigned)hashValue) % mTableSize;
HashEntry* next = mTable[spot];
HashEntry** prev = &mTable[spot];
while (next != NULL)
while (next != nullptr)
{
if (next->obj == obj && next->hashValue == hashValue)
{
*prev = next->nextEntry;
delete next;
mEntryCount--;
if (mTable[spot] == NULL)
if (mTable[spot] == nullptr)
mStatUsedSlots--;
return(true);
break;
@@ -127,17 +127,17 @@ template<typename T> void HashTable<T>::Reset()
for (int spot = 0; spot < mTableSize; spot++)
{
HashEntry *curr = mTable[spot];
if (curr != NULL)
if (curr != nullptr)
{
mStatUsedSlots--;
while (curr != NULL)
while (curr != nullptr)
{
HashEntry *next = curr->nextEntry;
delete curr;
mEntryCount--;
curr = next;
}
mTable[spot] = NULL;
mTable[spot] = nullptr;
}
}
}
@@ -145,13 +145,13 @@ template<typename T> void HashTable<T>::Reset()
template<typename T> T *HashTable<T>::FindFirst(int hashValue) const
{
HashEntry *entry = mTable[((unsigned)hashValue) % mTableSize];
while (entry != NULL)
while (entry != nullptr)
{
if (entry->hashValue == hashValue)
return(&entry->obj);
entry = entry->nextEntry;
}
return(NULL);
return(nullptr);
}
template<typename T> T *HashTable<T>::FindNext(T *prevResult) const
@@ -159,13 +159,13 @@ template<typename T> T *HashTable<T>::FindNext(T *prevResult) const
HashEntry *entry = (HashEntry *)(((char *)prevResult) - offsetof(HashEntry, obj));
int hashValue = entry->hashValue;
entry = entry->nextEntry;
while (entry != NULL)
while (entry != nullptr)
{
if (entry->hashValue == hashValue)
return(&entry->obj);
entry = entry->nextEntry;
}
return(NULL);
return(nullptr);
}
template<typename T> T *HashTable<T>::WalkFirst() const
@@ -173,10 +173,10 @@ template<typename T> T *HashTable<T>::WalkFirst() const
for (int bucket = 0; bucket < mTableSize; bucket++)
{
HashEntry *entry = mTable[bucket];
if (entry != NULL)
if (entry != nullptr)
return(&entry->obj);
}
return(NULL);
return(nullptr);
}
template<typename T> T *HashTable<T>::WalkNext(T *prevResult) const
@@ -185,17 +185,17 @@ template<typename T> T *HashTable<T>::WalkNext(T *prevResult) const
int bucket = ((unsigned)entry->hashValue) % mTableSize;
entry = entry->nextEntry;
if (entry != NULL)
if (entry != nullptr)
return(&entry->obj);
bucket++; // go onto next bucket
for (; bucket < mTableSize; bucket++)
{
HashEntry *entry = mTable[bucket];
if (entry != NULL)
if (entry != nullptr)
return(&entry->obj);
}
return(NULL);
return(nullptr);
}
template<typename T> void HashTable<T>::Resize(int hashSize)
@@ -215,16 +215,16 @@ template<typename T> void HashTable<T>::Resize(int hashSize)
for (int i = 0; i < oldSize; i++)
{
HashEntry* next = oldTable[i];
while (next != NULL)
while (next != nullptr)
{
HashEntry* hold = next;
next = next->nextEntry;
// insert hold into new table
int spot = ((unsigned)hold->hashValue) % mTableSize;
if (mTable[spot] == NULL)
if (mTable[spot] == nullptr)
{
hold->nextEntry = NULL;
hold->nextEntry = nullptr;
mTable[spot] = hold;
mStatUsedSlots++;
}
@@ -284,11 +284,11 @@ template<typename T, typename C = T> class ObjectHashTable
bool Remove(T *obj);
void Reset(); // removes all entries from the table
T *FindFirst(int hashValue) const; // returns NULL if not found
T *FindNext(T *prevResult) const; // returns NULL if not found
T *FindFirst(int hashValue) const; // returns nullptr if not found
T *FindNext(T *prevResult) const; // returns nullptr if not found
T *WalkFirst() const; // returns NULL if not found
T *WalkNext(T *prevResult) const; // returns NULL if not found
T *WalkFirst() const; // returns nullptr if not found
T *WalkNext(T *prevResult) const; // returns nullptr if not found
void Resize(int hashSize); // the actual hash size will be rounded up to the next larger prime number (very slow, not recommended)
void GetStatistics(HashTableStatistics *stats) const;
@@ -303,7 +303,7 @@ template<typename T, typename C = T> class ObjectHashTable
template<typename T, typename C> ObjectHashTable<T, C>::ObjectHashTable(int hashSize)
{
mTable = NULL;
mTable = nullptr;
mTableSize = 0;
mEntryCount = 0;
mStatUsedSlots = 0;
@@ -320,9 +320,9 @@ template<typename T, typename C> void ObjectHashTable<T, C>::Insert(T *obj, int
static_cast<C *>(obj)->mHashValue = hashValue;
int spot = ((unsigned)hashValue) % mTableSize;
if (mTable[spot] == NULL)
if (mTable[spot] == nullptr)
{
static_cast<C *>(obj)->mHashNextEntry = NULL;
static_cast<C *>(obj)->mHashNextEntry = nullptr;
mTable[spot] = obj;
mStatUsedSlots++;
}
@@ -339,14 +339,14 @@ template<typename T, typename C> bool ObjectHashTable<T, C>::Remove(T *obj)
int spot = ((unsigned)static_cast<C *>(obj)->mHashValue) % mTableSize;
T *cur = mTable[spot];
T **prev = &mTable[spot];
while (cur != NULL)
while (cur != nullptr)
{
if (cur == obj)
{
*prev = static_cast<C *>(cur)->mHashNextEntry;
static_cast<C *>(cur)->mHashNextEntry = NULL;
static_cast<C *>(cur)->mHashNextEntry = nullptr;
mEntryCount--;
if (mTable[spot] == NULL)
if (mTable[spot] == nullptr)
mStatUsedSlots--;
return(true);
break;
@@ -368,13 +368,13 @@ template<typename T, typename C> void ObjectHashTable<T, C>::Reset()
template<typename T, typename C> T *ObjectHashTable<T, C>::FindFirst(int hashValue) const
{
T *entry = mTable[((unsigned)hashValue) % mTableSize];
while (entry != NULL)
while (entry != nullptr)
{
if (static_cast<C *>(entry)->mHashValue == hashValue)
return(entry);
entry = static_cast<C *>(entry)->mHashNextEntry;
}
return(NULL);
return(nullptr);
}
template<typename T, typename C> T *ObjectHashTable<T, C>::FindNext(T *prevResult) const
@@ -382,13 +382,13 @@ template<typename T, typename C> T *ObjectHashTable<T, C>::FindNext(T *prevResul
T *entry = prevResult;
int hashValue = static_cast<C *>(entry)->mHashValue;
entry = static_cast<C *>(entry)->mHashNextEntry;
while (entry != NULL)
while (entry != nullptr)
{
if (static_cast<C *>(entry)->mHashValue == hashValue)
return(entry);
entry = static_cast<C *>(entry)->mHashNextEntry;
}
return(NULL);
return(nullptr);
}
template<typename T, typename C> T *ObjectHashTable<T, C>::WalkFirst() const
@@ -396,10 +396,10 @@ template<typename T, typename C> T *ObjectHashTable<T, C>::WalkFirst() const
for (int bucket = 0; bucket < mTableSize; bucket++)
{
T *entry = mTable[bucket];
if (entry != NULL)
if (entry != nullptr)
return(entry);
}
return(NULL);
return(nullptr);
}
template<typename T, typename C> T *ObjectHashTable<T, C>::WalkNext(T *prevResult) const
@@ -408,17 +408,17 @@ template<typename T, typename C> T *ObjectHashTable<T, C>::WalkNext(T *prevResul
int bucket = ((unsigned)static_cast<C *>(entry)->mHashValue) % mTableSize;
entry = static_cast<C *>(entry)->mHashNextEntry;
if (entry != NULL)
if (entry != nullptr)
return(entry);
bucket++; // go onto next bucket
for (; bucket < mTableSize; bucket++)
{
entry = mTable[bucket];
if (entry != NULL)
if (entry != nullptr)
return(entry);
}
return(NULL);
return(nullptr);
}
template<typename T, typename C> void ObjectHashTable<T, C>::Resize(int hashSize)
@@ -438,16 +438,16 @@ template<typename T, typename C> void ObjectHashTable<T, C>::Resize(int hashSize
for (int i = 0; i < oldSize; i++)
{
T *cur = oldTable[i];
while (cur != NULL)
while (cur != nullptr)
{
T *hold = cur;
cur = static_cast<C *>(cur)->mHashNextEntry;
// insert hold into new table
int spot = ((unsigned)static_cast<C *>(hold)->mHashValue) % mTableSize;
if (mTable[spot] == NULL)
if (mTable[spot] == nullptr)
{
static_cast<C *>(hold)->mHashNextEntry = NULL;
static_cast<C *>(hold)->mHashNextEntry = nullptr;
mTable[spot] = hold;
mStatUsedSlots++;
}
@@ -14,8 +14,8 @@ template<typename T> class UdpLinkedList;
template<typename M> class UdpLinkedListMember
{
public:
UdpLinkedListMember() { mPrev = NULL; mNext = NULL; }
UdpLinkedListMember(const UdpLinkedListMember &) { mPrev = NULL; mNext = NULL; }
UdpLinkedListMember() { mPrev = nullptr; mNext = nullptr; }
UdpLinkedListMember(const UdpLinkedListMember &) { mPrev = nullptr; mNext = nullptr; }
~UdpLinkedListMember() {}
#if defined(_MSC_VER) && (_MSC_VER < 1300) // MSVC 7.0 is the first version to support friend templates
@@ -60,8 +60,8 @@ template<typename T> class UdpLinkedList
template<typename T> UdpLinkedList<T>::UdpLinkedList(UdpLinkedListMember<T> T::*node)
{
mHead = NULL;
mTail = NULL;
mHead = nullptr;
mTail = nullptr;
mNode = node;
mCount = 0;
}
@@ -98,7 +98,7 @@ template<typename T> int UdpLinkedList<T>::Count() const
template<typename T> T *UdpLinkedList<T>::Position(int index) const
{
T *cur = mHead;
while (cur != NULL && index > 0)
while (cur != nullptr && index > 0)
{
cur = Next(cur);
index--;
@@ -109,43 +109,43 @@ template<typename T> T *UdpLinkedList<T>::Position(int index) const
template<typename T> T *UdpLinkedList<T>::Remove(T *cur)
{
UdpLinkedListMember<T> *node = &(cur->*mNode);
if (node->mPrev == NULL)
if (node->mPrev == nullptr)
mHead = node->mNext;
else
((node->mPrev)->*mNode).mNext = node->mNext;
if (node->mNext == NULL)
if (node->mNext == nullptr)
mTail = node->mPrev;
else
((node->mNext)->*mNode).mPrev = node->mPrev;
node->mNext = NULL;
node->mPrev = NULL;
node->mNext = nullptr;
node->mPrev = nullptr;
mCount--;
return(cur);
}
template<typename T> T *UdpLinkedList<T>::RemoveHead()
{
if (mHead == NULL)
return(NULL);
if (mHead == nullptr)
return(nullptr);
return(Remove(mHead));
}
template<typename T> T *UdpLinkedList<T>::RemoveTail()
{
if (mTail == NULL)
return(NULL);
if (mTail == nullptr)
return(nullptr);
return(Remove(mTail));
}
template<typename T> T *UdpLinkedList<T>::InsertHead(T *cur)
{
assert((cur->*mNode).mPrev == NULL);
assert((cur->*mNode).mNext == NULL);
assert((cur->*mNode).mPrev == nullptr);
assert((cur->*mNode).mNext == nullptr);
(cur->*mNode).mNext = mHead;
if (mHead != NULL)
if (mHead != nullptr)
{
(mHead->*mNode).mPrev = cur;
mHead = cur;
@@ -161,12 +161,12 @@ template<typename T> T *UdpLinkedList<T>::InsertHead(T *cur)
template<typename T> T *UdpLinkedList<T>::InsertTail(T *cur)
{
assert((cur->*mNode).mPrev == NULL);
assert((cur->*mNode).mNext == NULL);
assert((cur->*mNode).mPrev == nullptr);
assert((cur->*mNode).mNext == nullptr);
(cur->*mNode).mPrev = mTail;
if (mTail != NULL)
if (mTail != nullptr)
{
(mTail->*mNode).mNext = cur;
mTail = cur;
@@ -182,17 +182,17 @@ template<typename T> T *UdpLinkedList<T>::InsertTail(T *cur)
template<typename T> T *UdpLinkedList<T>::InsertAfter(T *cur, T *prev)
{
assert((cur->*mNode).mPrev == NULL);
assert((cur->*mNode).mNext == NULL);
assert((cur->*mNode).mPrev == nullptr);
assert((cur->*mNode).mNext == nullptr);
if (prev == NULL)
if (prev == nullptr)
return(InsertHead(cur));
(cur->*mNode).mPrev = prev;
(cur->*mNode).mNext = (prev->*mNode).mNext;
(prev->*mNode).mNext = cur;
if ((cur->*mNode).mNext != NULL)
if ((cur->*mNode).mNext != nullptr)
(((cur->*mNode).mNext)->*mNode).mPrev = cur;
else
mTail = cur;
@@ -204,7 +204,7 @@ template<typename T> T *UdpLinkedList<T>::InsertAfter(T *cur, T *prev)
template<typename T> void UdpLinkedList<T>::DeleteAll()
{
T *cur = First();
while (cur != NULL)
while (cur != nullptr)
{
T *next = Next(cur);
Remove(cur);
@@ -216,7 +216,7 @@ template<typename T> void UdpLinkedList<T>::DeleteAll()
template<typename T> void UdpLinkedList<T>::ReleaseAll()
{
T *cur = First();
while (cur != NULL)
while (cur != nullptr)
{
T *next = Next(cur);
Remove(cur);
@@ -31,7 +31,7 @@ SimpleLogicalPacket::SimpleLogicalPacket(const void *data, int dataLen)
{
mDataLen = dataLen;
mData = new udp_uchar[mDataLen];
if (data != NULL)
if (data != nullptr)
memcpy(mData, data, mDataLen);
}
@@ -66,7 +66,7 @@ void SimpleLogicalPacket::SetDataLen(int len)
GroupLogicalPacket::GroupLogicalPacket() : LogicalPacket()
{
mDataLen = 0;
mData = NULL;
mData = nullptr;
}
GroupLogicalPacket::~GroupLogicalPacket()
@@ -76,13 +76,13 @@ GroupLogicalPacket::~GroupLogicalPacket()
void GroupLogicalPacket::AddPacket(const LogicalPacket *packet)
{
assert(packet != NULL);
assert(packet != nullptr);
AddPacketInternal(packet->GetDataPtr(), packet->GetDataLen(), packet->IsInternalPacket());
}
void GroupLogicalPacket::AddPacket(const void *data, int dataLen)
{
assert(data != NULL);
assert(data != nullptr);
assert(dataLen >= 0);
AddPacketInternal(data, dataLen, false);
}
@@ -152,10 +152,10 @@ PooledLogicalPacket::PooledLogicalPacket(UdpManager *manager, int len)
PooledLogicalPacket::~PooledLogicalPacket()
{
if (mUdpManager != NULL)
if (mUdpManager != nullptr)
{
mUdpManager->PoolDestroyed(this);
mUdpManager = NULL;
mUdpManager = nullptr;
}
delete[] mData;
@@ -168,7 +168,7 @@ void PooledLogicalPacket::AddRef() const
void PooledLogicalPacket::Release() const
{
if (GetRefCount() == 1 && mUdpManager != NULL)
if (GetRefCount() == 1 && mUdpManager != nullptr)
{
// the PoolReturn function steals our reference (ie, we don't release, they don't addref), this is for thread safety reasons
mUdpManager->PoolReturn(const_cast<PooledLogicalPacket *>(this));
@@ -208,9 +208,9 @@ void PooledLogicalPacket::SetDataLen(int len)
void PooledLogicalPacket::SetData(const void *data, int dataLen, const void *data2, int dataLen2)
{
mDataLen = dataLen + dataLen2;
if (data != NULL)
if (data != nullptr)
memcpy(mData, data, dataLen);
if (data2 != NULL)
if (data2 != nullptr)
memcpy(mData + dataLen, data2, dataLen2);
}
@@ -81,7 +81,7 @@ class SimpleLogicalPacket : public LogicalPacket
// it was originally created to allow the internal code to handle reliable data that was sent
// via the Send(char *, int) api call.
public:
SimpleLogicalPacket(const void *data, int dataLen); // data can be NULL if you want to populate it after it is allocated (get the pointer and write to it)
SimpleLogicalPacket(const void *data, int dataLen); // data can be nullptr if you want to populate it after it is allocated (get the pointer and write to it)
virtual void *GetDataPtr();
virtual const void *GetDataPtr() const;
virtual int GetDataLen() const;
@@ -152,7 +152,7 @@ template<typename T> class StructLogicalPacket : public LogicalPacket
// with virtual functions) via this method as they may contain hidden data-members (such as pointers
// to vtables).
public:
StructLogicalPacket(T *initData = NULL);
StructLogicalPacket(T *initData = nullptr);
virtual void *GetDataPtr();
virtual const void *GetDataPtr() const;
virtual int GetDataLen() const;
@@ -226,7 +226,7 @@ class PooledLogicalPacket : public LogicalPacket
protected:
friend class UdpManager;
void TrueRelease() const;
void SetData(const void *data, int dataLen, const void *data2 = NULL, int dataLen2 = 0);
void SetData(const void *data, int dataLen, const void *data2 = nullptr, int dataLen2 = 0);
UdpManager *mUdpManager;
UdpLinkedListMember<PooledLogicalPacket> mAvailableLink; // for available linked list in manager
UdpLinkedListMember<PooledLogicalPacket> mCreatedLink; // for created linked list in manager
@@ -240,7 +240,7 @@ class PooledLogicalPacket : public LogicalPacket
template<int t_quickSize> FixedLogicalPacket<t_quickSize>::FixedLogicalPacket(const void *data, int dataLen)
{
mDataLen = dataLen;
if (data != NULL)
if (data != nullptr)
memcpy(mData, data, mDataLen);
}
@@ -270,7 +270,7 @@ template<int t_quickSize> void FixedLogicalPacket<t_quickSize>::SetDataLen(int l
/////////////////////////////////////////////////////////////////////////
template<typename T> StructLogicalPacket<T>::StructLogicalPacket(T *initData)
{
if (initData != NULL)
if (initData != nullptr)
mStruct = *initData;
}
@@ -111,10 +111,10 @@ UdpManager::UdpManager(const UdpParams *params) : mConnectionList(&UdpConnection
mParams.maxDataHoldSize = udpMin(mParams.maxDataHoldSize, mParams.maxRawPacketSize);
mParams.packetHistoryMax = udpMax(1, mParams.packetHistoryMax);
mPacketHistoryPosition = 0;
mPassThroughData = NULL;
mBackgroundThread = NULL;
mPassThroughData = nullptr;
mBackgroundThread = nullptr;
if (mParams.udpDriver != NULL)
if (mParams.udpDriver != nullptr)
{
mDriver = mParams.udpDriver;
}
@@ -154,7 +154,7 @@ UdpManager::UdpManager(const UdpParams *params) : mConnectionList(&UdpConnection
mSimulateOutgoingQueueBytes = 0;
if (mParams.avoidPriorityQueue)
mPriorityQueue = NULL;
mPriorityQueue = nullptr;
else
mPriorityQueue = new PriorityQueue<UdpConnection, UdpClockStamp>(mParams.maxConnections);
@@ -181,7 +181,7 @@ UdpManager::~UdpManager()
{
// Since the background thread holds a reference to the UdpManager while it is running, this should
// not be possible. The only way it could happen is if somebody released the manager who should not have.
assert(mBackgroundThread == NULL);
assert(mBackgroundThread == nullptr);
// next thing we must do is tell all the connections to disconnect (which severs their link to this dying manager)
// this has to be done first since they will call back into us and have themselves removed from our connection-list/priority-queue/etc
@@ -191,7 +191,7 @@ UdpManager::~UdpManager()
UdpGuard cg(&mConnectionGuard);
UdpConnection *cur = mConnectionList.First();
while (cur != NULL)
while (cur != nullptr)
{
cur->AddRef();
cur->InternalDisconnect(0, UdpConnection::cDisconnectReasonManagerDeleted); // this will cause it to remove us from the mConnectionList
@@ -216,9 +216,9 @@ UdpManager::~UdpManager()
UdpGuard guard(&mPoolGuard);
PooledLogicalPacket *walk = mPoolCreatedList.RemoveHead();
while (walk != NULL)
while (walk != nullptr)
{
walk->mUdpManager = NULL;
walk->mUdpManager = nullptr;
walk = mPoolCreatedList.RemoveHead();
}
// next release the ones we have in our available pool
@@ -232,11 +232,11 @@ UdpManager::~UdpManager()
CloseSocket();
if (mParams.udpDriver == NULL)
if (mParams.udpDriver == nullptr)
{
delete mDriver; // we were not given a driver to use, so we must own this driver we have, so destroy it
}
mDriver = NULL;
mDriver = nullptr;
delete mAddressHashTable;
delete mConnectCodeHashTable;
@@ -295,7 +295,7 @@ void UdpManager::ProcessDisconnectPending()
UdpGuard guard(&mDisconnectPendingGuard);
UdpConnection *entry = mDisconnectPendingList.First();
while (entry != NULL)
while (entry != nullptr)
{
UdpConnection *next = mDisconnectPendingList.Next(entry);
if (entry->GetStatus() == UdpConnection::cStatusDisconnected)
@@ -309,12 +309,12 @@ void UdpManager::ProcessDisconnectPending()
void UdpManager::RemoveConnection(UdpConnection *con)
{
assert(con != NULL); // attemped to remove a NULL connection object
assert(con != nullptr); // attemped to remove a nullptr connection object
// note: it's a bug to Remove a connection object that is already removed...should never be able to happen.
UdpGuard cg(&mConnectionGuard);
if (mPriorityQueue != NULL)
if (mPriorityQueue != nullptr)
{
mPriorityQueue->Remove(con);
}
@@ -326,7 +326,7 @@ void UdpManager::RemoveConnection(UdpConnection *con)
void UdpManager::AddConnection(UdpConnection *con)
{
assert(con != NULL); // attemped to add a NULL connection object
assert(con != nullptr); // attemped to add a nullptr connection object
UdpGuard cg(&mConnectionGuard);
con->AddRef(); // UdpManager keeps a soft reference to the connection (ie. if it sees it is the only one holding a reference, it releases it)
@@ -341,17 +341,17 @@ void UdpManager::FlushAllMultiBuffer()
mConnectionGuard.Enter();
UdpConnection *cur = mConnectionList.First();
if (cur != NULL)
if (cur != nullptr)
cur->AddRef();
mConnectionGuard.Leave();
while (cur != NULL)
while (cur != nullptr)
{
cur->FlushMultiBuffer();
mConnectionGuard.Enter();
UdpConnection *next = mConnectionList.Next(cur);
if (next != NULL)
if (next != nullptr)
next->AddRef();
mConnectionGuard.Leave();
@@ -366,15 +366,15 @@ void UdpManager::DisconnectAll()
mConnectionGuard.Enter();
UdpConnection *cur = mConnectionList.First();
if (cur != NULL)
if (cur != nullptr)
cur->AddRef();
mConnectionGuard.Leave();
while (cur != NULL)
while (cur != nullptr)
{
mConnectionGuard.Enter();
UdpConnection *next = mConnectionList.Next(cur);
if (next != NULL)
if (next != nullptr)
next->AddRef();
mConnectionGuard.Leave();
@@ -392,7 +392,7 @@ void UdpManager::DeliverEvents(int maxProcessingTime)
for (;;)
{
CallbackEvent *ce = EventListPop();
if (ce == NULL)
if (ce == nullptr)
break;
switch(ce->mEventType)
@@ -426,13 +426,13 @@ void UdpManager::DeliverEvents(int maxProcessingTime)
{
{ // guard block
UdpGuard hguard(&mHandlerGuard);
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
mParams.handler->OnConnectRequest(ce->mSource);
}
}
if (ce->mSource->GetHandler() == NULL) // if application did not set a handler, then the connection is considered refused
if (ce->mSource->GetHandler() == nullptr) // if application did not set a handler, then the connection is considered refused
{
ce->mSource->InternalDisconnect(0, UdpConnection::cDisconnectReasonConnectionRefused);
}
@@ -513,7 +513,7 @@ bool UdpManager::GiveTime(int maxPollingTime, bool giveConnectionsTime)
PacketHistoryEntry *e = SimulationReceive();
#endif
if (e == NULL)
if (e == nullptr)
{
mLastEmptySocketBufferStamp = CachedClock();
break;
@@ -545,7 +545,7 @@ bool UdpManager::GiveTime(int maxPollingTime, bool giveConnectionsTime)
if (giveConnectionsTime)
{
if (mPriorityQueue != NULL)
if (mPriorityQueue != nullptr)
{
// give time to everybody in the priority-queue that needs it
UdpClockStamp curPriority = CachedClock();
@@ -570,10 +570,10 @@ bool UdpManager::GiveTime(int maxPollingTime, bool giveConnectionsTime)
mConnectionGuard.Enter();
top = mPriorityQueue->TopRemove(curPriority);
if (top != NULL)
if (top != nullptr)
top->AddRef(); // must always addref connections while inside the connection guard
mConnectionGuard.Leave();
if (top == NULL)
if (top == nullptr)
break;
top->GiveTime(true);
@@ -593,17 +593,17 @@ bool UdpManager::GiveTime(int maxPollingTime, bool giveConnectionsTime)
// give time to everybody
mConnectionGuard.Enter();
UdpConnection *cur = mConnectionList.First();
if (cur != NULL)
if (cur != nullptr)
cur->AddRef();
mConnectionGuard.Leave();
while (cur != NULL)
while (cur != nullptr)
{
cur->GiveTime(true);
mConnectionGuard.Enter();
UdpConnection *next = mConnectionList.Next(cur);
if (next != NULL)
if (next != nullptr)
next->AddRef();
mConnectionGuard.Leave();
@@ -621,13 +621,13 @@ bool UdpManager::GiveTime(int maxPollingTime, bool giveConnectionsTime)
UdpClockStamp curStamp = CachedClock();
SimulateQueueEntry *entry = mSimulateOutgoingList.First();
while (entry != NULL && curStamp >= mSimulateNextOutgoingTime)
while (entry != nullptr && curStamp >= mSimulateNextOutgoingTime)
{
mSimulateOutgoingList.Remove(entry);
SimulateQueueEntry *next = mSimulateOutgoingList.First();
// simulate a delay before next packet is considered (ie. simple lag)
if (next != NULL)
if (next != nullptr)
{
int latencyDelay = (mSimulation.simulateOutgoingLatency - CachedClockElapsed(next->mQueueTime));
mSimulateNextOutgoingTime = curStamp + latencyDelay;
@@ -644,7 +644,7 @@ bool UdpManager::GiveTime(int maxPollingTime, bool giveConnectionsTime)
ActualSendHelper(entry->mData, entry->mDataLen, entry->mIp, entry->mPort);
UdpConnection *con = AddressGetConnection(entry->mIp, entry->mPort);
if (con != NULL)
if (con != nullptr)
{
con->mSimulateOutgoingQueueBytes -= entry->mDataLen;
con->Release();
@@ -664,12 +664,12 @@ UdpConnection *UdpManager::EstablishConnection(const char *serverAddress, int se
{
UdpGuard guard(&mGiveTimeGuard); // probably not needed, I don't see any reason we can't do this while GiveTime is happening in the background...the connection list is protected independently...still, better safe than sorry
assert(serverAddress != NULL);
assert(serverAddress != nullptr);
char useServerAddress[512];
UdpLibrary::UdpMisc::Strncpy(useServerAddress, serverAddress, sizeof(useServerAddress));
char *portPtr = strchr(useServerAddress, ':');
if (portPtr != NULL)
if (portPtr != nullptr)
{
*portPtr++ = 0;
serverPort = atoi(portPtr);
@@ -679,21 +679,21 @@ UdpConnection *UdpManager::EstablishConnection(const char *serverAddress, int se
assert(serverPort != 0); // can't connect to no port
if (mConnectionList.Count() >= mParams.maxConnections)
return(NULL);
return(nullptr);
// get server address
UdpPlatformAddress destIp;
if (!mDriver->GetHostByName(&destIp, useServerAddress))
{
return(NULL); // could not resolve name
return(nullptr); // could not resolve name
}
// first, see if we already have a connection object managing this ip/port, if we do, then fail
UdpConnection *con = AddressGetConnection(destIp, serverPort);
if (con != NULL)
if (con != nullptr)
{
con->Release();
return(NULL); // already connected to this address/port
return(nullptr); // already connected to this address/port
}
return(new UdpConnection(this, destIp, serverPort, timeout));
}
@@ -709,7 +709,7 @@ void UdpManager::GetStats(UdpManagerStatistics *stats)
{
UdpGuard sg(&mStatsGuard);
assert(stats != NULL);
assert(stats != nullptr);
*stats = mManagerStats;
stats->poolAvailable = mPoolAvailableList.Count();
stats->poolCreated = mPoolCreatedList.Count();
@@ -737,10 +737,10 @@ void UdpManager::DumpPacketHistory(const char *filename) const
{
UdpGuard guard(&mGiveTimeGuard);
assert(filename != NULL);
assert(filename != nullptr);
assert(filename[0] != 0);
FILE *file = fopen(filename, "wt");
if (file != NULL)
if (file != nullptr)
{
// dump history of packets...
for (int i = 0; i < mParams.packetHistoryMax; i++)
@@ -789,7 +789,7 @@ UdpManager::PacketHistoryEntry *UdpManager::SimulationReceive()
for (;;)
{
PacketHistoryEntry *entry = ActualReceive();
if (entry == NULL)
if (entry == nullptr)
break;
SimulateQueueEntry *qe = new SimulateQueueEntry(entry->mBuffer, entry->mLen, entry->mIp, entry->mPort, curStamp);
@@ -797,7 +797,7 @@ UdpManager::PacketHistoryEntry *UdpManager::SimulationReceive()
}
SimulateQueueEntry *winner = mSimulateIncomingList.First();
if (winner != NULL && CachedClockElapsed(winner->mQueueTime) >= mSimulation.simulateIncomingLatency)
if (winner != nullptr && CachedClockElapsed(winner->mQueueTime) >= mSimulation.simulateIncomingLatency)
{
mSimulateIncomingList.Remove(winner);
int pos = mPacketHistoryPosition;
@@ -809,14 +809,14 @@ UdpManager::PacketHistoryEntry *UdpManager::SimulationReceive()
delete winner;
return(mPacketHistory[pos]);
}
return(NULL);
return(nullptr);
}
UdpManager::PacketHistoryEntry *UdpManager::ActualReceive()
{
UdpClockStamp curStamp = CachedClock();
if (mSimulation.simulateIncomingByteRate > 0 && curStamp < mSimulateNextIncomingTime)
return(NULL);
return(nullptr);
UdpPlatformAddress fromAddress;
int fromPort = 0;
@@ -855,7 +855,7 @@ UdpManager::PacketHistoryEntry *UdpManager::ActualReceive()
}
return(mPacketHistory[pos]);
}
return(NULL);
return(nullptr);
}
void UdpManager::ActualSend(const udp_uchar *data, int dataLen, UdpPlatformAddress ip, int port)
@@ -876,7 +876,7 @@ void UdpManager::ActualSend(const udp_uchar *data, int dataLen, UdpPlatformAddre
return; // no room, packet gets lost
UdpConnection *con = AddressGetConnection(ip, port);
if (con != NULL)
if (con != nullptr)
{
if (mSimulation.simulateDestinationOverloadLevel > 0 && con->mSimulateOutgoingQueueBytes + dataLen > mSimulation.simulateDestinationOverloadLevel)
{
@@ -928,7 +928,7 @@ void UdpManager::ProcessRawPacket(const PacketHistoryEntry *e)
UdpConnection *con = AddressGetConnection(e->mIp, e->mPort);
if (con == NULL)
if (con == nullptr)
{
if (e->mLen == 0) // len = 0 = ICMP error
{
@@ -946,7 +946,7 @@ void UdpManager::ProcessRawPacket(const PacketHistoryEntry *e)
if (mConnectionList.Count() >= mParams.maxConnections)
return; // can't handle any more connections, so ignore this request entirely
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
UdpConnection *newcon = new UdpConnection(this, e);
CallbackConnectRequest(newcon);
@@ -968,7 +968,7 @@ void UdpManager::ProcessRawPacket(const PacketHistoryEntry *e)
int encryptCode = UdpMisc::GetValue32(ptr);
UdpConnection *con = ConnectCodeGetConnection(connectCode);
if (con != NULL)
if (con != nullptr)
{
if (mParams.allowAddressRemapping || con->mIp == e->mIp)
{
@@ -1025,7 +1025,7 @@ UdpConnection *UdpManager::AddressGetConnection(UdpPlatformAddress ip, int port)
UdpGuard guard(&mConnectionGuard);
UdpConnection *found = mAddressHashTable->FindFirst(AddressHashValue(ip, port));
while (found != NULL)
while (found != nullptr)
{
if (found->mIp == ip && found->mPort == port)
{
@@ -1034,7 +1034,7 @@ UdpConnection *UdpManager::AddressGetConnection(UdpPlatformAddress ip, int port)
}
found = mAddressHashTable->FindNext(found);
}
return(NULL);
return(nullptr);
}
UdpConnection *UdpManager::ConnectCodeGetConnection(int connectCode) const
@@ -1042,7 +1042,7 @@ UdpConnection *UdpManager::ConnectCodeGetConnection(int connectCode) const
UdpGuard guard(&mConnectionGuard);
UdpConnection *found = mConnectCodeHashTable->FindFirst(connectCode);
while (found != NULL)
while (found != nullptr)
{
if (found->mConnectCode == connectCode)
{
@@ -1051,7 +1051,7 @@ UdpConnection *UdpManager::ConnectCodeGetConnection(int connectCode) const
}
found = mConnectCodeHashTable->FindNext(found);
}
return(NULL);
return(nullptr);
}
LogicalPacket *UdpManager::CreatePacket(const void *data, int dataLen, const void *data2, int dataLen2)
@@ -1063,7 +1063,7 @@ LogicalPacket *UdpManager::CreatePacket(const void *data, int dataLen, const voi
{
UdpGuard guard(&mPoolGuard);
PooledLogicalPacket *lp = mPoolAvailableList.RemoveHead();
if (lp == NULL)
if (lp == nullptr)
{
// create a new pooled packet to fulfil request
lp = new PooledLogicalPacket(this, mParams.pooledPacketSize);
@@ -1091,7 +1091,7 @@ void UdpManager::PoolDestroyed(PooledLogicalPacket *packet)
char *UdpManager::GetLocalString(char *buf, int bufLen) const
{
if (bufLen < 22)
return(NULL);
return(nullptr);
UdpPlatformAddress ip = GetLocalIp();
int port = GetLocalPort();
char hold[256];
@@ -1103,7 +1103,7 @@ UdpManager::CallbackEvent *UdpManager::AvailableEventBorrow()
{
UdpGuard guard(&mAvailableEventGuard);
CallbackEvent *ce = mAvailableEventList.RemoveHead();
if (ce == NULL)
if (ce == nullptr)
{
ce = new CallbackEvent();
}
@@ -1127,7 +1127,7 @@ void UdpManager::EventListAppend(CallbackEvent *ce)
{
UdpGuard guard(&mEventListGuard);
mEventList.InsertTail(ce);
if (ce->mPayload != NULL)
if (ce->mPayload != nullptr)
{
mEventListBytes += ce->mPayload->GetDataLen();
}
@@ -1137,7 +1137,7 @@ UdpManager::CallbackEvent *UdpManager::EventListPop()
{
UdpGuard guard(&mEventListGuard);
CallbackEvent *event = mEventList.RemoveHead();
if (event != NULL && event->mPayload != NULL)
if (event != nullptr && event->mPayload != nullptr)
{
mEventListBytes -= event->mPayload->GetDataLen();
}
@@ -1148,7 +1148,7 @@ UdpManager::CallbackEvent *UdpManager::EventListPop()
void UdpManager::ThreadStart()
{
UdpGuard guard(&mThreadGuard);
if (mBackgroundThread == NULL)
if (mBackgroundThread == nullptr)
{
mBackgroundThread = new UdpManagerThread(this, mParams.threadSleepTime);
mBackgroundThread->Start();
@@ -1158,12 +1158,12 @@ void UdpManager::ThreadStart()
void UdpManager::ThreadStop()
{
UdpGuard guard(&mThreadGuard);
if (mBackgroundThread != NULL)
if (mBackgroundThread != nullptr)
{
assert(mRefCount > 1); // caller must hold a reference, and thread must hold a reference, so this should be true. If it asserts, it means the caller is using a UdpManager that it does not hold a reference to.
mBackgroundThread->Stop(true);
mBackgroundThread->Release();
mBackgroundThread = NULL;
mBackgroundThread = nullptr;
}
}
@@ -1256,13 +1256,13 @@ void UdpManager::CallbackConnectRequest(UdpConnection *con)
{
{ // guard block
UdpGuard hguard(&mHandlerGuard);
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
mParams.handler->OnConnectRequest(con);
}
}
if (con->GetHandler() == NULL) // if application did not set a handler, then the connection is considered refused
if (con->GetHandler() == nullptr) // if application did not set a handler, then the connection is considered refused
{
con->InternalDisconnect(0, UdpConnection::cDisconnectReasonConnectionRefused);
}
@@ -1276,8 +1276,8 @@ void UdpManager::CallbackConnectRequest(UdpConnection *con)
UdpManager::CallbackEvent::CallbackEvent()
{
mEventType = cCallbackEventNone;
mSource = NULL;
mPayload = NULL;
mSource = nullptr;
mPayload = nullptr;
mReason = cUdpCorruptionReasonNone;
}
@@ -1291,7 +1291,7 @@ void UdpManager::CallbackEvent::SetEventData(CallbackEventType eventType, UdpCon
mEventType = eventType;
mSource = con;
mSource->AddRef();
if (payload != NULL)
if (payload != nullptr)
{
mPayload = payload;
mPayload->AddRef();
@@ -1300,16 +1300,16 @@ void UdpManager::CallbackEvent::SetEventData(CallbackEventType eventType, UdpCon
void UdpManager::CallbackEvent::ClearEventData()
{
if (mSource != NULL)
if (mSource != nullptr)
{
mSource->Release();
mSource = NULL;
mSource = nullptr;
}
if (mPayload != NULL)
if (mPayload != nullptr)
{
mPayload->Release();
mPayload = NULL;
mPayload = nullptr;
}
}
@@ -178,7 +178,7 @@ struct UdpParams
// pointer equal to your object and the UdpManager will call it as appropriate. The UdpConnection object
// also has a handler mechanism that replaces the other callback functions below, see UdpConnection::SetHandler
// if a handler is specified, the callback function is ignored, even if specified.
// default = NULL (not used)
// default = nullptr (not used)
UdpManagerHandler *handler;
// this is the maximum number of connections that can be established by this manager, any incoming/outgoing connections
@@ -496,7 +496,7 @@ struct UdpParams
// the UdpPlatformDriver object itself and chain the calls on through, plus do whatever else it wants;
// however, that is not required. The application maintains ownership of this object and the object must
// not be destroyed by the application until the UdpManager using it is destroyed.
// default = NULL, meaning the UdpManager it will create it's own UdpPlatformDriver for use.
// default = nullptr, meaning the UdpManager it will create it's own UdpPlatformDriver for use.
UdpDriver *udpDriver;
@@ -642,7 +642,7 @@ class UdpManager : public UdpGuardedRefCount
// will call EstablishConnection, then sit in a loop calling UdpManager::GiveTime and checking to see
// if the status of the returned UdpConnection object is changed from cStatusNegotiating. This allows
// the application to look for the ESC key or timeout an attempted connection.
// This function will return NULL if the manager object has exceeded its maximum number of connections
// This function will return nullptr if the manager object has exceeded its maximum number of connections
// or if the serverAddress cannot be resolved to an IP address
// as is noted in the declaration, it is the responsibility of the application establishing the connection to delete it
// setting the timeout value (in milliseconds) to something greater than 0 will cause the UdpConnection object to change
@@ -685,13 +685,13 @@ class UdpManager : public UdpGuardedRefCount
// a terminated packet.
void DisconnectAll();
// creates a logical packet and populates it with data. data can be NULL, in which case it gives you logical packet
// creates a logical packet and populates it with data. data can be nullptr, in which case it gives you logical packet
// of the size specified, but copies no data into it. If you are using pool management (see Params::poolPacketMax),
// it will give you a packet out of the pool if possible, otherwise it will create a packet for you. When logical
// are packets are needed internally for various things (like reliable channel sends that use the (void *, int) interface)
// they are gotten from this function, so your application can likely take advantage of pooling, even if it never bothers
// to explicitly call this function.
LogicalPacket *CreatePacket(const void *data, int dataLen, const void *data2 = NULL, int dataLen2 = 0);
LogicalPacket *CreatePacket(const void *data, int dataLen, const void *data2 = nullptr, int dataLen2 = 0);
void GetSimulation(UdpSimulationParameters *simulationParameters) const;
void SetSimulation(const UdpSimulationParameters *simulationParameters);
@@ -796,7 +796,7 @@ class UdpManager : public UdpGuardedRefCount
CallbackEvent();
~CallbackEvent();
void SetEventData(CallbackEventType eventType, UdpConnection *con, const LogicalPacket *payload = NULL);
void SetEventData(CallbackEventType eventType, UdpConnection *con, const LogicalPacket *payload = nullptr);
void ClearEventData();
CallbackEventType mEventType;
@@ -926,7 +926,7 @@ inline void UdpManager::SetPriority(UdpConnection *con, UdpClockStamp stamp)
if (stamp < mMinimumScheduledStamp)
stamp = mMinimumScheduledStamp;
if (mPriorityQueue != NULL)
if (mPriorityQueue != nullptr)
{
mPriorityQueue->Add(con, stamp);
}
@@ -1025,7 +1025,7 @@ inline int UdpManager::CachedClockElapsed(UdpClockStamp start)
inline int UdpManager::EncryptUserSupplied(UdpConnection *con, udp_uchar *destData, const udp_uchar *sourceData, int sourceLen)
{
UdpGuard guard(&mHandlerGuard);
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
return(mParams.handler->OnUserSuppliedEncrypt(con, destData, sourceData, sourceLen));
}
@@ -1035,7 +1035,7 @@ inline int UdpManager::EncryptUserSupplied(UdpConnection *con, udp_uchar *destDa
inline int UdpManager::EncryptUserSupplied2(UdpConnection *con, udp_uchar *destData, const udp_uchar *sourceData, int sourceLen)
{
UdpGuard guard(&mHandlerGuard);
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
return(mParams.handler->OnUserSuppliedEncrypt2(con, destData, sourceData, sourceLen));
}
@@ -1045,7 +1045,7 @@ inline int UdpManager::EncryptUserSupplied2(UdpConnection *con, udp_uchar *destD
inline int UdpManager::DecryptUserSupplied(UdpConnection *con, udp_uchar *destData, const udp_uchar *sourceData, int sourceLen)
{
UdpGuard guard(&mHandlerGuard);
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
return(mParams.handler->OnUserSuppliedDecrypt(con, destData, sourceData, sourceLen));
}
@@ -1055,7 +1055,7 @@ inline int UdpManager::DecryptUserSupplied(UdpConnection *con, udp_uchar *destDa
inline int UdpManager::DecryptUserSupplied2(UdpConnection *con, udp_uchar *destData, const udp_uchar *sourceData, int sourceLen)
{
UdpGuard guard(&mHandlerGuard);
if (mParams.handler != NULL)
if (mParams.handler != nullptr)
{
return(mParams.handler->OnUserSuppliedDecrypt2(con, destData, sourceData, sourceLen));
}
@@ -1070,7 +1070,7 @@ inline int UdpManager::DecryptUserSupplied2(UdpConnection *con, udp_uchar *destD
/////////////////////////////////////////////////////////////////////////////////////////////////////
inline UdpParams::UdpParams(ManagerRole role)
{
handler = NULL;
handler = nullptr;
outgoingBufferSize = 64 * 1024;
incomingBufferSize = 64 * 1024;
packetHistoryMax = 4;
@@ -1103,7 +1103,7 @@ inline UdpParams::UdpParams(ManagerRole role)
reliableOverflowBytes = 0;
lingerDelay = 10;
bindIpAddress[0] = 0;
udpDriver = NULL;
udpDriver = nullptr;
callbackEventPoolMax = 5000;
eventQueuing = false;
threadSleepTime = 20;
@@ -113,19 +113,19 @@ void *UdpMisc::SmartResize(void *ptr, int bytes, int round)
if (bytes == 0)
{
if (ptr != NULL)
if (ptr != nullptr)
{
free((udp_uchar *)ptr - cAlignment);
}
return(NULL);
return(nullptr);
}
udp_uchar *ptr2;
if (ptr == NULL)
if (ptr == nullptr)
{
ptr2 = (udp_uchar *)malloc(bytes + cAlignment);
if (ptr2 == NULL)
return(NULL);
if (ptr2 == nullptr)
return(nullptr);
*(int *)ptr2 = bytes;
return(ptr2 + cAlignment);
}
@@ -135,8 +135,8 @@ void *UdpMisc::SmartResize(void *ptr, int bytes, int round)
return(ptr);
ptr2 = (udp_uchar *)realloc((udp_uchar *)ptr - cAlignment, bytes + cAlignment);
if (ptr2 == NULL)
return(NULL);
if (ptr2 == nullptr)
return(nullptr);
*(int *)ptr2 = bytes;
return(ptr2 + cAlignment);
@@ -199,30 +199,30 @@ LogicalPacket *UdpMisc::CreateQuickLogicalPacket(const void *data, int dataLen,
switch(q)
{
case 0:
tlp = new FixedLogicalPacket<cQuickFactor>(NULL, totalDataLen);
tlp = new FixedLogicalPacket<cQuickFactor>(nullptr, totalDataLen);
break;
case 1:
tlp = new FixedLogicalPacket<cQuickFactor * 2>(NULL, totalDataLen);
tlp = new FixedLogicalPacket<cQuickFactor * 2>(nullptr, totalDataLen);
break;
case 2:
case 3:
tlp = new FixedLogicalPacket<cQuickFactor * 4>(NULL, totalDataLen);
tlp = new FixedLogicalPacket<cQuickFactor * 4>(nullptr, totalDataLen);
break;
case 4:
case 5:
case 6:
case 7:
tlp = new FixedLogicalPacket<cQuickFactor * 8>(NULL, totalDataLen);
tlp = new FixedLogicalPacket<cQuickFactor * 8>(nullptr, totalDataLen);
break;
default:
tlp = new SimpleLogicalPacket(NULL, totalDataLen);
tlp = new SimpleLogicalPacket(nullptr, totalDataLen);
break;
}
udp_uchar *dest = (udp_uchar *)tlp->GetDataPtr();
if (data != NULL)
if (data != nullptr)
memcpy(dest, data, dataLen);
if (data2 != NULL)
if (data2 != nullptr)
memcpy(dest + dataLen, data2, dataLen2);
return(tlp);
}
@@ -57,7 +57,7 @@ class UdpMisc
// memory manager does a little bit of this, but if you know you have an allocation that is likely
// to grow quite a bit, you can set the round'ing size up to a fairly large number and avoid
// unnecessary reallocs at the cost of a little potentially wasted space
// initial allocations are done by passing in ptr==NULL, freeing is done by passing in bytes==0
// initial allocations are done by passing in ptr==nullptr, freeing is done by passing in bytes==0
static void *SmartResize(void *ptr, int bytes, int round = 1);
// the following two functions store values in the buffer as a variable length (B1, 0xffB2B1, 0xffffffB4B3B2B1)
@@ -78,7 +78,7 @@ class UdpMisc
static udp_uint GetValue24(const void *buffer); // gets a 24-bit value from the buffer in big-endian format
static udp_ushort GetValue16(const void *buffer); // gets a 16-bit value from the buffer in big-endian format
static LogicalPacket *CreateQuickLogicalPacket(const void *data, int dataLen, const void *data2 = NULL, int dataLen2 = 0);
static LogicalPacket *CreateQuickLogicalPacket(const void *data, int dataLen, const void *data2 = nullptr, int dataLen2 = 0);
// looks up the specified name and translates it to an IP address
// this is a blocking call that can at times take a significant amount of time, but will generally be fast (less than 300ms)
@@ -43,12 +43,12 @@ template<typename T, typename P> class PriorityQueue
PriorityQueue(int queueSize);
~PriorityQueue();
T* Top(); // returns NULL if queue is empty
T* TopRemove(); // returns NULL if queue is empty
T* TopRemove(P priority); // removes item from queue if it has a lower priority value, otherwise return NULL
T* Top(); // returns nullptr if queue is empty
T* TopRemove(); // returns nullptr if queue is empty
T* TopRemove(P priority); // removes item from queue if it has a lower priority value, otherwise return nullptr
T* Add(T* entry, P priority); // reprioritizes if already in queue, returns entry always
T* Remove(T* entry); // returns entry always (even if it was not in the queue)
P *GetPriority(T* entry); // returns NULL if entry is not in the queue
P *GetPriority(T* entry); // returns nullptr if entry is not in the queue
int QueueUsed(); // returns how many entries are in the queue
protected:
struct QueueEntry
@@ -94,14 +94,14 @@ template<typename T, typename P> PriorityQueue<T, P>::~PriorityQueue()
template<typename T, typename P> T* PriorityQueue<T, P>::Top()
{
if (mQueueEnd == 0)
return(NULL);
return(nullptr);
return(mQueue[0].entry);
}
template<typename T, typename P> T* PriorityQueue<T, P>::TopRemove()
{
if (mQueueEnd == 0)
return(NULL);
return(nullptr);
T* top = mQueue[0].entry;
Remove(top);
return(top);
@@ -111,14 +111,14 @@ template<typename T, typename P> T* PriorityQueue<T, P>::TopRemove(P priority)
{
if (mQueueEnd > 0 && mQueue[0].priority <= priority)
return(Remove(mQueue[0].entry));
return(NULL);
return(nullptr);
}
template<typename T, typename P> P* PriorityQueue<T, P>::GetPriority(T* entry)
{
if (entry->mPriorityQueuePosition >= 0)
return(&mQueue[entry->mPriorityQueuePosition].priority);
return(NULL);
return(nullptr);
}
template<typename T, typename P> T* PriorityQueue<T, P>::Add(T* entry, P priority)
@@ -127,7 +127,7 @@ template<typename T, typename P> T* PriorityQueue<T, P>::Add(T* entry, P priorit
{
// not in queue, so add it to the bottom
if (mQueueEnd >= mQueueSize)
return(NULL);
return(nullptr);
mQueue[mQueueEnd].entry = entry;
mQueue[mQueueEnd].priority = priority;
mQueue[mQueueEnd].entry->mPriorityQueuePosition = mQueueEnd;
@@ -48,12 +48,12 @@ UdpReliableChannel::UdpReliableChannel(int channelNumber, UdpConnection *con, Ud
mReliableOutgoingBytes = 0;
mLogicalBytesQueued = 0;
mCoalescePacket = NULL;
mCoalesceStartPtr = NULL;
mCoalesceEndPtr = NULL;
mCoalescePacket = nullptr;
mCoalesceStartPtr = nullptr;
mCoalesceEndPtr = nullptr;
mCoalesceCount = 0;
mBufferedAckPtr = NULL;
mBufferedAckPtr = nullptr;
mStatDuplicatePacketsReceived = 0;
mStatResentPacketsAccelerated = 0;
@@ -69,7 +69,7 @@ UdpReliableChannel::UdpReliableChannel(int channelNumber, UdpConnection *con, Ud
mBigDataLen = 0;
mBigDataTargetLen = 0;
mBigDataPtr = NULL;
mBigDataPtr = nullptr;
mFragmentNextPos = 0;
mLastTimeStampAcknowledged = 0;
mMaxxedOutCurrentWindow = false;
@@ -81,14 +81,14 @@ UdpReliableChannel::UdpReliableChannel(int channelNumber, UdpConnection *con, Ud
UdpReliableChannel::~UdpReliableChannel()
{
if (mCoalescePacket != NULL)
if (mCoalescePacket != nullptr)
{
mCoalescePacket->Release();
mCoalescePacket = NULL;
mCoalescePacket = nullptr;
}
const LogicalPacket *cur = mLogicalPacketList.RemoveHead();
while (cur != NULL)
while (cur != nullptr)
{
cur->Release();
cur = mLogicalPacketList.RemoveHead();
@@ -103,7 +103,7 @@ UdpReliableChannel::~UdpReliableChannel()
void UdpReliableChannel::Send(const udp_uchar *data, int dataLen, const udp_uchar *data2, int dataLen2)
{
if (mLogicalPacketList.Count() == 0 && mCoalescePacket == NULL)
if (mLogicalPacketList.Count() == 0 && mCoalescePacket == nullptr)
{
// if we are adding something to a previously empty logical queue, then it is possible that
// we may be able to send it, so mark ourselves to take time the next time it is offered
@@ -126,7 +126,7 @@ void UdpReliableChannel::Send(const udp_uchar *data, int dataLen, const udp_ucha
void UdpReliableChannel::FlushCoalesce()
{
if (mCoalescePacket != NULL)
if (mCoalescePacket != nullptr)
{
if (mCoalesceCount == 1)
{
@@ -140,16 +140,16 @@ void UdpReliableChannel::FlushCoalesce()
mCoalescePacket->SetDataLen((int)(mCoalesceEndPtr - mCoalesceStartPtr));
QueueLogicalPacket(mCoalescePacket);
mCoalescePacket->Release();
mCoalescePacket = NULL;
mCoalescePacket = nullptr;
}
}
void UdpReliableChannel::SendCoalesce(const udp_uchar *data, int dataLen, const udp_uchar *data2, int dataLen2)
{
int totalLen = dataLen + dataLen2;
if (mCoalescePacket == NULL)
if (mCoalescePacket == nullptr)
{
mCoalescePacket = mUdpConnection->mUdpManager->CreatePacket(NULL, mMaxDataBytes);
mCoalescePacket = mUdpConnection->mUdpManager->CreatePacket(nullptr, mMaxDataBytes);
mCoalesceEndPtr = mCoalesceStartPtr = (udp_uchar *)mCoalescePacket->GetDataPtr();
*mCoalesceEndPtr++ = 0;
*mCoalesceEndPtr++ = UdpConnection::cUdpPacketGroup;
@@ -169,10 +169,10 @@ void UdpReliableChannel::SendCoalesce(const udp_uchar *data, int dataLen, const
// append on end of coalesce
mCoalesceCount++;
mCoalesceEndPtr += UdpMisc::PutVariableValue(mCoalesceEndPtr, totalLen);
if (data != NULL)
if (data != nullptr)
memcpy(mCoalesceEndPtr, data, dataLen);
mCoalesceEndPtr += dataLen;
if (data2 != NULL)
if (data2 != nullptr)
memcpy(mCoalesceEndPtr, data2, dataLen2);
mCoalesceEndPtr += dataLen2;
}
@@ -287,7 +287,7 @@ int UdpReliableChannel::GiveTime()
mMaxxedOutCurrentWindow = false;
int outstandingNextSendTime = 10 * 60000;
// if we have something to do
if (mReliableOutgoingPendingId < mReliableOutgoingId || mLogicalPacketList.Count() != 0 || mCoalescePacket != NULL)
if (mReliableOutgoingPendingId < mReliableOutgoingId || mLogicalPacketList.Count() != 0 || mCoalescePacket != nullptr)
{
// first, let's calculate how many bytes we figure is outstanding based on who is still waiting for an ack-packet
UdpClockStamp oldestResendTime = udpMax(hotClock - optimalResendDelay, mLastTimeStampAcknowledged); // anything older than this, we need to resend
@@ -317,7 +317,7 @@ int UdpReliableChannel::GiveTime()
// if this packet has not been acked and it is NOT ready to be sent (was recently sent) then we consider it outstanding
// note: packets needing re-sending probably got lost and are therefore not outstanding
PhysicalPacket *entry = &mPhysicalPackets[i % mConfig.maxOutstandingPackets];
if (entry->mDataPtr != NULL) // acked packets set the dataPtr to NULL
if (entry->mDataPtr != nullptr) // acked packets set the dataPtr to nullptr
{
// if this packet is ready to be sent (ie: needs time now, or some later packet has already been ack'ed)
windowSpaceLeft -= entry->mDataLen; // window-space is effectively taken whether we have sent it yet or not
@@ -524,7 +524,7 @@ int UdpReliableChannel::GiveTime()
void UdpReliableChannel::GetChannelStatus(UdpConnection::ChannelStatus *channelStatus) const
{
int coalesceBytes = 0;
if (mCoalescePacket != NULL)
if (mCoalescePacket != nullptr)
coalesceBytes = (int)(mCoalesceEndPtr - mCoalesceStartPtr);
channelStatus->totalPendingBytes = mLogicalBytesQueued + mReliableOutgoingBytes + coalesceBytes;
@@ -550,7 +550,7 @@ void UdpReliableChannel::GetChannelStatus(UdpConnection::ChannelStatus *channelS
PhysicalPacket *entry = &mPhysicalPackets[mReliableOutgoingPendingId % mConfig.maxOutstandingPackets];
if (entry->mFirstTimeStamp != 0) // if has been sent (we know it hasn't been acknowledged or we couldn't possibly be pointing at it as pending)
{
if (mUdpConnection->GetUdpManager() != NULL)
if (mUdpConnection->GetUdpManager() != nullptr)
{
channelStatus->oldestUnacknowledgedAge = mUdpConnection->GetUdpManager()->CachedClockElapsed(entry->mFirstTimeStamp);
}
@@ -588,7 +588,7 @@ void UdpReliableChannel::ReliablePacket(const udp_uchar *data, int dataLen)
mReliableIncomingId++;
// process other packets that have arrived
while (mReliableIncoming[mReliableIncomingId % mConfig.maxInstandingPackets].mPacket != NULL)
while (mReliableIncoming[mReliableIncomingId % mConfig.maxInstandingPackets].mPacket != nullptr)
{
int spot = (int)(mReliableIncomingId % mConfig.maxInstandingPackets);
if (mReliableIncoming[spot].mMode != cReliablePacketModeDelivered)
@@ -597,7 +597,7 @@ void UdpReliableChannel::ReliablePacket(const udp_uchar *data, int dataLen)
}
mReliableIncoming[spot].mPacket->Release();
mReliableIncoming[spot].mPacket = NULL;
mReliableIncoming[spot].mPacket = nullptr;
mReliableIncomingId++;
}
}
@@ -605,7 +605,7 @@ void UdpReliableChannel::ReliablePacket(const udp_uchar *data, int dataLen)
{
// not the one we need next, but it is later than the one we need , so store it in our buffer until it's turn comes up
int spot = (int)(reliableId % mConfig.maxInstandingPackets);
if (mReliableIncoming[spot].mPacket == NULL) // only make the copy of it if we don't already have it in our buffer (in cases where it was sent twice, there would be no harm in the copy again since it must be the same packet, it's just inefficient)
if (mReliableIncoming[spot].mPacket == nullptr) // only make the copy of it if we don't already have it in our buffer (in cases where it was sent twice, there would be no harm in the copy again since it must be the same packet, it's just inefficient)
{
mReliableIncoming[spot].mMode = mode;
mReliableIncoming[spot].mPacket = mUdpConnection->mUdpManager->CreatePacket(data + UdpConnection::cUdpPacketReliableSize, dataLen - UdpConnection::cUdpPacketReliableSize);
@@ -651,14 +651,14 @@ void UdpReliableChannel::ReliablePacket(const udp_uchar *data, int dataLen)
bufPtr += UdpMisc::PutValue16(bufPtr, (udp_ushort)(reliableId & 0xffff));
}
if (mBufferedAckPtr != NULL && mConfig.ackDeduping && ackAll)
if (mBufferedAckPtr != nullptr && mConfig.ackDeduping && ackAll)
{
memcpy(mBufferedAckPtr, buf, bufPtr - buf);
}
else
{
udp_uchar *ptr = mUdpConnection->BufferedSend(buf, (int)(bufPtr - buf), NULL, 0, true); // safe to append on our data, it is stack data
if (mBufferedAckPtr == NULL)
udp_uchar *ptr = mUdpConnection->BufferedSend(buf, (int)(bufPtr - buf), nullptr, 0, true); // safe to append on our data, it is stack data
if (mBufferedAckPtr == nullptr)
{
// the buffered-ack ptr should always point to the earliest ack in the buffer, such that
// a replacement ack-all will be processed by the receiver before any selective acks that may
@@ -676,7 +676,7 @@ void UdpReliableChannel::ProcessPacket(ReliablePacketMode mode, const udp_uchar
if (mode == cReliablePacketModeReliable)
{
// we are not a fragment, nor was there a fragment in progress, so we are a simple reliable packet, just send it to the app
if (mBigDataPtr != NULL)
if (mBigDataPtr != nullptr)
{
mUdpConnection->CallbackCorruptPacket(data, dataLen, cUdpCorruptionReasonFragmentExpected);
return;
@@ -687,7 +687,7 @@ void UdpReliableChannel::ProcessPacket(ReliablePacketMode mode, const udp_uchar
else if (mode == cReliablePacketModeFragment)
{
// append onto end of big packet (or create new big packet if not existing already)
if (mBigDataPtr == NULL)
if (mBigDataPtr == nullptr)
{
if (dataLen < 4)
{
@@ -729,7 +729,7 @@ void UdpReliableChannel::ProcessPacket(ReliablePacketMode mode, const udp_uchar
delete[] mBigDataPtr;
mBigDataLen = 0;
mBigDataTargetLen = 0;
mBigDataPtr = NULL;
mBigDataPtr = nullptr;
}
}
}
@@ -767,7 +767,7 @@ void UdpReliableChannel::Ack(udp_int64 reliableId)
int pos = (int)(reliableId % mConfig.maxOutstandingPackets);
PhysicalPacket *entry = &mPhysicalPackets[pos];
if (entry->mDataPtr != NULL) // if this packet has not been acknowledged yet (sometimes we get back two acks for the same packet)
if (entry->mDataPtr != nullptr) // if this packet has not been acknowledged yet (sometimes we get back two acks for the same packet)
{
mNextNeedTime = 0; // something got acked, so we actually need to take the time next time it is offered
@@ -829,14 +829,14 @@ void UdpReliableChannel::Ack(udp_int64 reliableId)
// this packet we have queued has been acknowledged, so delete it from queue
mReliableOutgoingBytes -= entry->mDataLen;
entry->mDataLen = 0;
entry->mDataPtr = NULL;
entry->mDataPtr = nullptr;
entry->mParent->Release();
entry->mParent = NULL;
entry->mParent = nullptr;
// advance the pending ptr until it reaches outgoingId or an entry that has yet to acknowledged
while (mReliableOutgoingPendingId < mReliableOutgoingId)
{
if (mPhysicalPackets[mReliableOutgoingPendingId % mConfig.maxOutstandingPackets].mDataPtr != NULL)
if (mPhysicalPackets[mReliableOutgoingPendingId % mConfig.maxOutstandingPackets].mDataPtr != nullptr)
break;
mReliableOutgoingPendingId++;
}
@@ -855,25 +855,25 @@ void UdpReliableChannel::Ack(udp_int64 reliableId)
UdpReliableChannel::IncomingQueueEntry::IncomingQueueEntry()
{
mPacket = NULL;
mPacket = nullptr;
mMode = UdpReliableChannel::cReliablePacketModeReliable;
}
UdpReliableChannel::IncomingQueueEntry::~IncomingQueueEntry()
{
if (mPacket != NULL)
if (mPacket != nullptr)
mPacket->Release();
}
UdpReliableChannel::PhysicalPacket::PhysicalPacket()
{
mParent = NULL;
mParent = nullptr;
}
UdpReliableChannel::PhysicalPacket::~PhysicalPacket()
{
if (mParent != NULL)
if (mParent != nullptr)
mParent->Release();
}
@@ -64,7 +64,7 @@ class UdpReliableChannel
void ProcessPacket(ReliablePacketMode mode, const udp_uchar *data, int dataLen);
bool PullDown(int windowSpaceLeft);
void FlushCoalesce();
void SendCoalesce(const udp_uchar *data, int dataLen, const udp_uchar *data2 = NULL, int dataLen2 = 0);
void SendCoalesce(const udp_uchar *data, int dataLen, const udp_uchar *data2 = nullptr, int dataLen2 = 0);
void QueueLogicalPacket(LogicalPacket *packet);
UdpReliableConfig mConfig;
@@ -138,7 +138,7 @@ inline int UdpReliableChannel::TotalPendingBytes() const
inline void UdpReliableChannel::ClearBufferedAck()
{
mBufferedAckPtr = NULL;
mBufferedAckPtr = nullptr;
}
inline udp_int64 UdpReliableChannel::GetReliableOutgoingId(int reliableStamp) const
@@ -122,7 +122,7 @@ namespace Plat_Unicode
/**
* Find a CharData for the given code point.
* @return null if no CharData exists for this code point
* @return nullptr if no CharData exists for this code point
*/
inline const CharData * CharDataMap::findCharData (const unicode_char_t code) const
@@ -87,7 +87,7 @@ int UTF8_convertCharToUTF16( char * ptr , UTF16 * ret )
int UTF8_convertToUTF16( char * ptr , UTF16 * ret, int limit )
{
int len = 0;
while (( *ptr != 0 ) && ( len < ( limit - 1 ) ))//we use limit -1 to leave room for the null terminator
while (( *ptr != 0 ) && ( len < ( limit - 1 ) ))//we use limit -1 to leave room for the nullptr terminator
{
int clen = UTF8_convertCharToUTF16( ptr, ret );
ptr += clen;