diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-10 13:49:11 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-10 13:49:11 +0000 |
commit | 73efaa00c6044d77a6c098bec38057b231ef8243 (patch) | |
tree | 07237735ddf83c6cb011188b6c4b067bdcd6b5e3 /protocols/JabberG/src/jabber_send_manager.h | |
parent | 183f4dfbadce9c687c66e5377274a464f6c9a72f (diff) |
Jabber:
- these long static buffers replaced with CMString;
- some crazy memory allocations in chats also replaced with CMString;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@7577 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_send_manager.h')
-rw-r--r-- | protocols/JabberG/src/jabber_send_manager.h | 63 |
1 files changed, 20 insertions, 43 deletions
diff --git a/protocols/JabberG/src/jabber_send_manager.h b/protocols/JabberG/src/jabber_send_manager.h index 12acf10cdb..eee8647ca2 100644 --- a/protocols/JabberG/src/jabber_send_manager.h +++ b/protocols/JabberG/src/jabber_send_manager.h @@ -98,16 +98,13 @@ public: }
~CJabberSendManager()
{
- Lock();
CJabberSendPermanentInfo *pInfo = m_pPermanentHandlers;
- while (pInfo)
- {
+ while (pInfo) {
CJabberSendPermanentInfo *pTmp = pInfo->m_pNext;
delete pInfo;
pInfo = pTmp;
}
m_pPermanentHandlers = NULL;
- Unlock();
DeleteCriticalSection(&m_cs);
}
BOOL Start()
@@ -118,18 +115,10 @@ public: {
return TRUE;
}
- void Lock()
- {
- EnterCriticalSection(&m_cs);
- }
- void Unlock()
- {
- LeaveCriticalSection(&m_cs);
- }
CJabberSendPermanentInfo* AddPermanentHandler(JABBER_SEND_HANDLER pHandler, void *pUserData = NULL, SEND_USER_DATA_FREE_FUNC pUserDataFree = NULL, int iPriority = JH_PRIORITY_DEFAULT)
{
CJabberSendPermanentInfo* pInfo = new CJabberSendPermanentInfo();
- if ( !pInfo)
+ if (!pInfo)
return NULL;
pInfo->m_pHandler = pHandler;
@@ -137,16 +126,15 @@ public: pInfo->m_pUserDataFree = pUserDataFree;
pInfo->m_iPriority = iPriority;
- Lock();
- if ( !m_pPermanentHandlers)
+ mir_cslock lck(m_cs);
+ if (!m_pPermanentHandlers)
m_pPermanentHandlers = pInfo;
- else
- {
+ else {
if (m_pPermanentHandlers->m_iPriority > pInfo->m_iPriority) {
pInfo->m_pNext = m_pPermanentHandlers;
m_pPermanentHandlers = pInfo;
- } else
- {
+ }
+ else {
CJabberSendPermanentInfo* pTmp = m_pPermanentHandlers;
while (pTmp->m_pNext && pTmp->m_pNext->m_iPriority <= pInfo->m_iPriority)
pTmp = pTmp->m_pNext;
@@ -154,40 +142,29 @@ public: pTmp->m_pNext = pInfo;
}
}
- Unlock();
-
return pInfo;
}
BOOL DeletePermanentHandler(CJabberSendPermanentInfo *pInfo)
{ // returns TRUE when pInfo found, or FALSE otherwise
- Lock();
- if ( !m_pPermanentHandlers)
- {
- Unlock();
+ mir_cslock lck(m_cs);
+ if (!m_pPermanentHandlers)
return FALSE;
- }
- if (m_pPermanentHandlers == pInfo) // check first item
- {
+
+ if (m_pPermanentHandlers == pInfo) { // check first item
m_pPermanentHandlers = m_pPermanentHandlers->m_pNext;
delete pInfo;
- Unlock();
return TRUE;
- } else
- {
- CJabberSendPermanentInfo* pTmp = m_pPermanentHandlers;
- while (pTmp->m_pNext)
- {
- if (pTmp->m_pNext == pInfo)
- {
- pTmp->m_pNext = pTmp->m_pNext->m_pNext;
- delete pInfo;
- Unlock();
- return TRUE;
- }
- pTmp = pTmp->m_pNext;
+ }
+
+ CJabberSendPermanentInfo* pTmp = m_pPermanentHandlers;
+ while (pTmp->m_pNext) {
+ if (pTmp->m_pNext == pInfo) {
+ pTmp->m_pNext = pTmp->m_pNext->m_pNext;
+ delete pInfo;
+ return TRUE;
}
+ pTmp = pTmp->m_pNext;
}
- Unlock();
return FALSE;
}
BOOL HandleSendPermanent(HXML node, ThreadData *pThreadData);
|