diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-15 21:05:06 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-15 21:05:06 +0300 |
commit | 59e6b15f513cc998ce13e9e49e2a6a3ace445ebb (patch) | |
tree | af52b73a17039ed1fbe398ba9f488c26a7071257 /protocols | |
parent | bdaa5cf8b48515af2ac39f3f3245dd1183cbad52 (diff) |
LIST<> iterators:
- new method LIST::removeItem added to save a pointer to removed record;
- code cleaning related to the fact that LIST::remove() shall be the last operation inside an iterator, because otherwise the reference to it will point to a record next to deleted one;
- a few remaining cycles converted to iterators
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Discord/src/dispatch.cpp | 4 | ||||
-rw-r--r-- | protocols/IRCG/src/commandmonitor.cpp | 7 | ||||
-rw-r--r-- | protocols/IRCG/src/irclib.cpp | 4 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/cookies.cpp | 2 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/icq_avatar.cpp | 45 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/icq_direct.cpp | 6 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/icq_rates.cpp | 20 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/utilities.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_frame.cpp | 13 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iq.cpp | 57 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iq.h | 8 | ||||
-rw-r--r-- | protocols/MSN/src/msn_avatar.cpp | 7 | ||||
-rw-r--r-- | protocols/MSN/src/msn_chat.cpp | 25 | ||||
-rw-r--r-- | protocols/MSN/src/msn_srv.cpp | 2 | ||||
-rw-r--r-- | protocols/MSN/src/msn_threads.cpp | 3 | ||||
-rw-r--r-- | protocols/Steam/src/steam_request.cpp | 12 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_chats.cpp | 12 |
17 files changed, 104 insertions, 125 deletions
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index 33cf2fe556..53c561aaf2 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -164,10 +164,10 @@ void CDiscordProto::OnCommandFriendRemoved(const JSONNode &pRoot) SnowFlake id = ::getId(pRoot["id"]); CDiscordUser *pUser = FindUser(id); if (pUser != nullptr) { - if (pUser->hContact) { + if (pUser->hContact) if (pUser->bIsPrivate) db_delete_contact(pUser->hContact); - } + arUsers.remove(pUser); } } diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index 72db70fc6f..05ca521f17 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -2081,9 +2081,10 @@ bool CIrcProto::OnIrc_USERHOST_REPLY(const CIrcMessage *pmsg) setWString(hContact, "Nick", nick);
// If user found, remove from checklist
- for (int i = 0; i < checklist.getCount(); i++)
- if (!mir_wstrcmpi(checklist[i], nick))
- checklist.remove(i);
+ auto T = checklist.rev_iter();
+ for (auto &it : T)
+ if (!mir_wstrcmpi(it->GetString(), nick))
+ checklist.remove(T.indexOf(&it));
}
}
break;
diff --git a/protocols/IRCG/src/irclib.cpp b/protocols/IRCG/src/irclib.cpp index 681e1b19ba..28db677271 100644 --- a/protocols/IRCG/src/irclib.cpp +++ b/protocols/IRCG/src/irclib.cpp @@ -470,7 +470,7 @@ void CIrcProto::RemoveDCCSession(MCONTACT hContact) for (auto &it : m_dcc_chats) if (it->di->hContact == hContact) { - m_dcc_chats.remove(it); + m_dcc_chats.removeItem(&it); break; } } @@ -481,7 +481,7 @@ void CIrcProto::RemoveDCCSession(DCCINFO *pdci) for (auto &it : m_dcc_xfers) { if (it->di == pdci) { - m_dcc_xfers.remove(it); + m_dcc_xfers.removeItem(&it); break; } } diff --git a/protocols/IcqOscarJ/src/cookies.cpp b/protocols/IcqOscarJ/src/cookies.cpp index a517f93923..0eb4dcc2fd 100644 --- a/protocols/IcqOscarJ/src/cookies.cpp +++ b/protocols/IcqOscarJ/src/cookies.cpp @@ -182,7 +182,7 @@ void CIcqProto::FreeCookieByData(BYTE bType, void *pvExtra) for (auto &it : cookies) {
if (bType == it->bType && pvExtra == it->pvExtra) {
// Cookie found, remove from list
- cookies.remove(it);
+ cookies.removeItem(&it);
break;
}
}
diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp index 28ef778680..c3d6b5792f 100644 --- a/protocols/IcqOscarJ/src/icq_avatar.cpp +++ b/protocols/IcqOscarJ/src/icq_avatar.cpp @@ -187,19 +187,18 @@ void CIcqProto::StartAvatarThread(HNETLIBCONN hConn, char *cookie, size_t cookie // check if any upload request are waiting in the queue
int bYet = 0;
- for (int i = 0; i < m_arAvatars.getCount();) {
- avatars_request *ar = m_arAvatars[i];
- if (ar->type == ART_UPLOAD) { // we found it, return error
+ auto T = m_arAvatars.rev_iter();
+ for (auto &it : T) {
+ if (it->type == ART_UPLOAD) { // we found it, return error
if (!bYet) {
icq_LogMessage(LOG_WARNING, LPGEN("Error uploading avatar to server, server temporarily unavailable."));
bYet = 1;
}
// remove upload request from queue
- m_arAvatars.remove(i);
- delete ar;
+ delete it;
+ m_arAvatars.remove(T.indexOf(&it));
}
- else i++;
}
SAFE_FREE((void**)&cookie);
@@ -489,11 +488,10 @@ void CIcqProto::handleAvatarContactHash(DWORD dwUIN, char *szUID, MCONTACT hCont if (bJob == TRUE) { // Remove possible block - hash changed, try again.
mir_cslock l(m_avatarsMutex);
- for (int i = 0; i < m_arAvatars.getCount(); i++) {
- avatars_request *ar = m_arAvatars[i];
- if (ar->hContact == hContact && ar->type == ART_BLOCK) { // found one, remove
- m_arAvatars.remove(i);
- delete ar;
+ for (auto &it : m_arAvatars) {
+ if (it->hContact == hContact && it->type == ART_BLOCK) { // found one, remove
+ delete it;
+ m_arAvatars.removeItem(&it);
break;
}
}
@@ -536,18 +534,17 @@ int CIcqProto::GetAvatarData(MCONTACT hContact, DWORD dwUin, const char *szUid, if (m_avatarsConnection && m_avatarsConnection->isReady()) { // check if we are ready
// check if requests for this user are not blocked
- for (int i = 0; i < m_arAvatars.getCount();) {
- avatars_request *ar = m_arAvatars[i];
+ auto T = m_arAvatars.rev_iter();
+ for (auto &ar : T) {
if (ar->hContact == hContact && ar->type == ART_BLOCK) { // found a block item
if (GetTickCount() > ar->timeOut) { // remove timeouted block
- m_arAvatars.remove(i);
delete ar;
+ m_arAvatars.remove(T.indexOf(&ar));
continue;
}
debugLogA("Avatars: Requests for %s avatar are blocked.", strUID(dwUin, pszUid));
return 0;
}
- i++;
}
mir_cslock l(m_avatarsConnection->getLock());
@@ -562,12 +559,12 @@ int CIcqProto::GetAvatarData(MCONTACT hContact, DWORD dwUin, const char *szUid, // we failed to send request, or avatar thread not ready
// check if any request for this user is not already in the queue
- for (int i = 0; i < m_arAvatars.getCount();) {
- avatars_request *ar = m_arAvatars[i];
+ auto T = m_arAvatars.rev_iter();
+ for (auto &ar : T) {
if (ar->hContact == hContact) { // we found it, return error
if (ar->type == ART_BLOCK && GetTickCount() > ar->timeOut) { // remove timeouted block
- m_arAvatars.remove(i);
delete ar;
+ m_arAvatars.remove(T.indexOf(&ar));
continue;
}
alck.unlock();
@@ -577,7 +574,6 @@ int CIcqProto::GetAvatarData(MCONTACT hContact, DWORD dwUin, const char *szUid, requestAvatarConnection();
return 0;
}
- i++;
}
// add request to queue, processed after successful login
@@ -728,12 +724,11 @@ void avatars_server_connection::shutdownConnection() DWORD avatars_server_connection::sendGetAvatarRequest(MCONTACT hContact, DWORD dwUin, char *szUid, const BYTE *hash, size_t hashlen, const wchar_t *file)
{
- int i;
DWORD dwNow = GetTickCount();
mir_cslockfull alck(ppro->m_avatarsMutex);
- for (i = 0; i < runCount;) { // look for timeouted requests
+ for (int i = 0; i < runCount;) { // look for timeouted requests
if (runTime[i] < dwNow) { // found outdated, remove
runContact[i] = runContact[runCount - 1];
runTime[i] = runTime[runCount - 1];
@@ -742,7 +737,7 @@ DWORD avatars_server_connection::sendGetAvatarRequest(MCONTACT hContact, DWORD d else i++;
}
- for (i = 0; i < runCount; i++) {
+ for (int i = 0; i < runCount; i++) {
if (runContact[i] == hContact) {
ppro->debugLogA("Ignoring duplicate get %s image request.", strUID(dwUin, szUid));
return -1; // Success: request ignored
@@ -849,11 +844,11 @@ void avatars_server_connection::checkRequestQueue() }
if (pRequest->type == ART_BLOCK) { // block contact processing
- for (int i = 0; i < ppro->m_arAvatars.getCount(); i++) {
- avatars_request *ar = ppro->m_arAvatars[i];
+ auto T = ppro->m_arAvatars.rev_iter();
+ for (auto &ar : T) {
if (GetTickCount() > ar->timeOut) { // expired contact block, remove
- ppro->m_arAvatars.remove(i);
delete ar;
+ ppro->m_arAvatars.remove(T.indexOf(&ar));
}
}
return; // end processing
diff --git a/protocols/IcqOscarJ/src/icq_direct.cpp b/protocols/IcqOscarJ/src/icq_direct.cpp index 3ecbbe8d92..9872dbd9d6 100644 --- a/protocols/IcqOscarJ/src/icq_direct.cpp +++ b/protocols/IcqOscarJ/src/icq_direct.cpp @@ -76,10 +76,8 @@ filetransfer* CIcqProto::FindExpectedFileRecv(DWORD dwUin, DWORD dwTotalSize) mir_cslock l(expectedFileRecvMutex);
for (auto &it : expectedFileRecvs)
- if (it->dwUin == dwUin && it->dwTotalSize == dwTotalSize) {
- expectedFileRecvs.remove(it);
- return it;
- }
+ if (it->dwUin == dwUin && it->dwTotalSize == dwTotalSize)
+ return expectedFileRecvs.removeItem(&it);
return nullptr;
}
diff --git a/protocols/IcqOscarJ/src/icq_rates.cpp b/protocols/IcqOscarJ/src/icq_rates.cpp index b2d3ee2823..e2dc3d569f 100644 --- a/protocols/IcqOscarJ/src/icq_rates.cpp +++ b/protocols/IcqOscarJ/src/icq_rates.cpp @@ -386,16 +386,16 @@ void rates_queue::putItem(rates_queue_item *pItem, int nMinDelay) ppro->debugLogA("Rates: Delaying %s.", szDescr);
{
mir_cslock l(csLists);
- if (lstPending.getCount()) {
- for (int i = 0; i < lstPending.getCount(); i++) {
- if (lstPending[i]->isEqual(pItem)) {
- if (duplicates == 1) // keep existing, ignore new
- return;
-
- if (duplicates == -1) { // discard existing, append new item
- delete lstPending[i];
- lstPending.remove(i);
- }
+
+ auto T = lstPending.rev_iter();
+ for (auto &it : T) {
+ if (it->isEqual(pItem)) {
+ if (duplicates == 1) // keep existing, ignore new
+ return;
+
+ if (duplicates == -1) { // discard existing, append new item
+ delete it;
+ lstPending.remove(T.indexOf(&it));
}
}
}
diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp index 97253e2cc1..e7af9c8a33 100644 --- a/protocols/IcqOscarJ/src/utilities.cpp +++ b/protocols/IcqOscarJ/src/utilities.cpp @@ -388,10 +388,10 @@ void CIcqProto::DeleteFromContactsCache(MCONTACT hContact) for (auto &it : contactsCache) {
if (it->hContact == hContact) {
- contactsCache.remove(it);
// Release memory
SAFE_FREE((void**)&it->szUid);
SAFE_FREE((void**)&it);
+ contactsCache.removeItem(&it);
break;
}
}
diff --git a/protocols/JabberG/src/jabber_frame.cpp b/protocols/JabberG/src/jabber_frame.cpp index 170147508c..9253442816 100644 --- a/protocols/JabberG/src/jabber_frame.cpp +++ b/protocols/JabberG/src/jabber_frame.cpp @@ -474,15 +474,14 @@ void CJabberInfoFrame::RemoveInfoItem(char *pszName) {
bool bUpdate = false;
size_t length = mir_strlen(pszName);
- for (int i = 0; i < m_pItems.getCount(); i++) {
- auto &p = m_pItems[i];
- if (!strncmp(p.m_pszName, pszName, length)) {
- if (!p.m_bShow)
+ auto T = m_pItems.rev_iter();
+ for (auto &p : T) {
+ if (!strncmp(p->m_pszName, pszName, length)) {
+ if (!p->m_bShow)
--m_hiddenItemCount;
- RemoveTooltip(p.m_tooltipId);
- m_pItems.remove(i);
+ RemoveTooltip(p->m_tooltipId);
+ m_pItems.remove(T.indexOf(&p));
bUpdate = true;
- --i;
}
}
diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp index 6474d0b5b9..2a0c5de4f0 100644 --- a/protocols/JabberG/src/jabber_iq.cpp +++ b/protocols/JabberG/src/jabber_iq.cpp @@ -143,7 +143,7 @@ void CJabberIqManager::ExpirerThread() Thread_SetName("Jabber: ExpirerThread");
while (!m_bExpirerThreadShutdownRequest) {
- CJabberIqInfo *pInfo = DetouchExpired();
+ CJabberIqInfo *pInfo = DetachExpired();
if (!pInfo) {
for (int i=0; !m_bExpirerThreadShutdownRequest && (i < 10); i++)
Sleep(50);
@@ -181,14 +181,14 @@ void CJabberIqManager::ExpireInfo(CJabberIqInfo *pInfo) void CJabberIqManager::ExpireIq(int nIqId)
{
- while (CJabberIqInfo *pInfo = DetouchInfo(nIqId))
+ while (CJabberIqInfo *pInfo = DetachInfo(nIqId))
ExpireInfo(pInfo);
}
bool CJabberIqManager::ExpireByUserData(void *pUserData)
{
bool bRet = false;
- while (CJabberIqInfo *pInfo = DetouchInfo(pUserData)) {
+ while (CJabberIqInfo *pInfo = DetachInfo(pUserData)) {
ExpireInfo(pInfo);
bRet = true;
}
@@ -197,7 +197,7 @@ bool CJabberIqManager::ExpireByUserData(void *pUserData) void CJabberIqManager::ExpireAll()
{
- while (CJabberIqInfo *pInfo = DetouchInfo())
+ while (CJabberIqInfo *pInfo = DetachInfo())
ExpireInfo(pInfo);
}
@@ -226,9 +226,9 @@ bool CJabberIqManager::DeleteHandler(CJabberIqInfo *pInfo) // returns TRUE when pInfo found, or FALSE otherwise
mir_cslockfull lck(m_cs);
- for (int i = 0; i < m_arIqs.getCount(); i++) {
- if (m_arIqs[i] == pInfo) {
- m_arIqs.remove(i);
+ for (auto &it : m_arIqs) {
+ if (it == pInfo) {
+ m_arIqs.removeItem(&it);
lck.unlock();
ExpireInfo(pInfo); // must expire it to allow the handler to free m_pUserData if necessary
return true;
@@ -255,7 +255,7 @@ bool CJabberIqManager::HandleIq(int nIqId, HXML pNode) else
return false;
- CJabberIqInfo *pInfo = DetouchInfo(nIqId);
+ CJabberIqInfo *pInfo = DetachInfo(nIqId);
if (pInfo == nullptr)
return false;
@@ -285,7 +285,7 @@ bool CJabberIqManager::HandleIq(int nIqId, HXML pNode) (ppro->*(pInfo->m_pHandler))(pNode, pInfo);
delete pInfo;
}
- while ((pInfo = DetouchInfo(nIqId)) != nullptr);
+ while ((pInfo = DetachInfo(nIqId)) != nullptr);
return true;
}
@@ -344,7 +344,7 @@ bool CJabberIqManager::HandleIqPermanent(HXML pNode) return false;
}
-CJabberIqInfo* CJabberIqManager::DetouchInfo()
+CJabberIqInfo* CJabberIqManager::DetachInfo()
{
mir_cslock lck(m_cs);
@@ -354,48 +354,37 @@ CJabberIqInfo* CJabberIqManager::DetouchInfo() return pInfo;
}
-CJabberIqInfo* CJabberIqManager::DetouchInfo(int nIqId)
+CJabberIqInfo* CJabberIqManager::DetachInfo(int nIqId)
{
mir_cslock lck(m_cs);
- for (int i = 0; i < m_arIqs.getCount(); i++) {
- CJabberIqInfo *pInfo = m_arIqs[i];
- if (pInfo->m_nIqId == nIqId) {
- m_arIqs.remove(i);
- return pInfo;
- }
- }
+ for (auto &it : m_arIqs)
+ if (it->m_nIqId == nIqId)
+ return m_arIqs.removeItem(&it);
return nullptr;
}
-CJabberIqInfo* CJabberIqManager::DetouchInfo(void *pUserData)
+CJabberIqInfo* CJabberIqManager::DetachInfo(void *pUserData)
{
mir_cslock lck(m_cs);
- for (int i = 0; i < m_arIqs.getCount(); i++) {
- CJabberIqInfo *pInfo = m_arIqs[i];
- if (pInfo->m_pUserData == pUserData) {
- m_arIqs.remove(i);
- return pInfo;
- }
- }
+ for (auto &it : m_arIqs)
+ if (it->m_pUserData == pUserData)
+ return m_arIqs.removeItem(&it);
+
return nullptr;
}
-CJabberIqInfo* CJabberIqManager::DetouchExpired()
+CJabberIqInfo* CJabberIqManager::DetachExpired()
{
DWORD dwCurrentTime = GetTickCount();
mir_cslock lck(m_cs);
- for (int i = 0; i < m_arIqs.getCount(); i++) {
- CJabberIqInfo *pInfo = m_arIqs[i];
- if (dwCurrentTime - pInfo->m_dwRequestTime > pInfo->m_dwTimeout) {
- m_arIqs.remove(i);
- return pInfo;
- }
- }
+ for (auto &it : m_arIqs)
+ if (dwCurrentTime - it->m_dwRequestTime > it->m_dwTimeout)
+ return m_arIqs.removeItem(&it);
return nullptr;
}
diff --git a/protocols/JabberG/src/jabber_iq.h b/protocols/JabberG/src/jabber_iq.h index 7248e0606d..bc252f4119 100644 --- a/protocols/JabberG/src/jabber_iq.h +++ b/protocols/JabberG/src/jabber_iq.h @@ -150,10 +150,10 @@ protected: LIST<CJabberIqInfo> m_arIqs;
OBJLIST<CJabberIqPermanentInfo> m_arHandlers;
- CJabberIqInfo* DetouchInfo();
- CJabberIqInfo* DetouchInfo(int nIqId);
- CJabberIqInfo* DetouchInfo(void *pUserData);
- CJabberIqInfo* DetouchExpired();
+ CJabberIqInfo* DetachInfo();
+ CJabberIqInfo* DetachInfo(int nIqId);
+ CJabberIqInfo* DetachInfo(void *pUserData);
+ CJabberIqInfo* DetachExpired();
void ExpireInfo(CJabberIqInfo *pInfo);
diff --git a/protocols/MSN/src/msn_avatar.cpp b/protocols/MSN/src/msn_avatar.cpp index cf520027a7..b2f1f36cb9 100644 --- a/protocols/MSN/src/msn_avatar.cpp +++ b/protocols/MSN/src/msn_avatar.cpp @@ -121,8 +121,7 @@ void __cdecl CMsnProto::MSN_AvatarsThread(void*) }
mir_cslock lck(csAvatarQueue);
- while (lsAvatarQueue.getCount() > 0) {
- delete lsAvatarQueue[0];
- lsAvatarQueue.remove(0);
- }
+ for (auto &it : lsAvatarQueue)
+ delete it;
+ lsAvatarQueue.destroy();
}
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index fe9b611941..804cb64951 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -118,12 +118,12 @@ void CMsnProto::MSN_ChatStart(ezxml_t xmli) }
// Remove contacts not on list (not tagged)
- for (int j = 0; j < info->mJoinedContacts.getCount(); j++) {
- if (!info->mJoinedContacts[j]->btag) {
- info->mJoinedContacts.remove(j);
- j--;
- }
- else info->mJoinedContacts[j]->btag = 0;
+ auto T = info->mJoinedContacts.rev_iter();
+ for (auto &it : T) {
+ if (!it->btag)
+ info->mJoinedContacts.remove(T.indexOf(&it));
+ else
+ it->btag = 0;
}
}
@@ -458,12 +458,13 @@ int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) case GC_SESSION_TERMINATE:
{
GCThreadData* thread = MSN_GetThreadByChatId(gch->ptszID);
- if (thread != nullptr) {
- m_arGCThreads.remove(thread);
- for (auto &it : thread->mJoinedContacts)
- delete it;
- delete thread;
- }
+ if (thread == nullptr)
+ break;
+
+ m_arGCThreads.remove(thread);
+ for (auto &it : thread->mJoinedContacts)
+ delete it;
+ delete thread;
}
break;
diff --git a/protocols/MSN/src/msn_srv.cpp b/protocols/MSN/src/msn_srv.cpp index cc9ff30f2b..b61fddd873 100644 --- a/protocols/MSN/src/msn_srv.cpp +++ b/protocols/MSN/src/msn_srv.cpp @@ -48,7 +48,7 @@ void CMsnProto::MSN_DeleteGroup(const char* pId) {
int i = m_arGroups.getIndex((ServerGroupItem*)&pId);
if (i > -1) {
- ServerGroupItem* p = m_arGroups[i];
+ ServerGroupItem *p = m_arGroups[i];
mir_free(p->id);
mir_free(p->name);
mir_free(p);
diff --git a/protocols/MSN/src/msn_threads.cpp b/protocols/MSN/src/msn_threads.cpp index c75e4b643c..4f762b02e8 100644 --- a/protocols/MSN/src/msn_threads.cpp +++ b/protocols/MSN/src/msn_threads.cpp @@ -453,9 +453,8 @@ void __cdecl CMsnProto::ThreadStub(void* arg) debugLogA("Leaving thread %08X (%08X)", GetCurrentThreadId(), info->mFunc);
{
mir_cslock lck(m_csThreads);
- m_arThreads.LIST<ThreadData>::remove(info);
+ m_arThreads.remove(info);
}
- delete info;
}
void ThreadData::startThread(MsnThreadFunc parFunc, CMsnProto *prt)
diff --git a/protocols/Steam/src/steam_request.cpp b/protocols/Steam/src/steam_request.cpp index 51b09ecfc3..06e83c4c25 100644 --- a/protocols/Steam/src/steam_request.cpp +++ b/protocols/Steam/src/steam_request.cpp @@ -91,13 +91,11 @@ void CSteamProto::RequestQueueThread(void*) ProcessRequestQueue();
WaitForSingleObject(m_hRequestsQueueEvent, 1000);
} while (!m_isTerminated);
- {
- mir_cslock lock(m_requestQueueLock);
- for (int i = 0; i < m_requestQueue.getCount(); i++) {
- delete m_requestQueue[i];
- m_requestQueue.remove(i);
- }
- }
+
m_hRequestQueueThread = nullptr;
+ mir_cslock lock(m_requestQueueLock);
+ for (auto &it : m_requestQueue)
+ delete it;
+ m_requestQueue.destroy();
}
\ No newline at end of file diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index 4e82018e1a..55460df3d5 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -174,22 +174,22 @@ void CVkProto::OnReceiveChatInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe }
}
- for (int i = cc->m_users.getCount() - 1; i >= 0; i--) {
- CVkChatUser &cu = cc->m_users[i];
- if (!cu.m_bDel)
+ auto T = cc->m_users.rev_iter();
+ for (auto &cu : T) {
+ if (!cu->m_bDel)
continue;
wchar_t wszId[20];
- _itow(cu.m_uid, wszId, 10);
+ _itow(cu->m_uid, wszId, 10);
GCEVENT gce = { m_szModuleName, cc->m_wszId, GC_EVENT_PART };
gce.ptszUID = wszId;
gce.dwFlags = GCEF_NOTNOTIFY;
gce.time = time(nullptr);
- gce.ptszNick = mir_wstrdup(CMStringW(FORMAT, L"%s (https://vk.com/id%s)", cu.m_wszNick, wszId));
+ gce.ptszNick = mir_wstrdup(CMStringW(FORMAT, L"%s (https://vk.com/id%s)", cu->m_wszNick, wszId));
Chat_Event(&gce);
- cc->m_users.remove(i);
+ cc->m_users.remove(T.indexOf(&cu));
}
}
|