summaryrefslogtreecommitdiff
path: root/protocols/MRA
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-12-14 14:33:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-12-14 14:33:17 +0000
commit56ecec5734194ccf709c3f57fe1a15a1b926c68d (patch)
treece049dc932a37e32a1e8810a70562d2b0a32d9df /protocols/MRA
parentffe922189b20daaf132ddfc24bfea9bf03a3a94b (diff)
let's operator new() clean the memory
git-svn-id: http://svn.miranda-ng.org/main/trunk@11406 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MRA')
-rw-r--r--protocols/MRA/src/MraAvatars.cpp48
-rw-r--r--protocols/MRA/src/MraFilesQueue.cpp18
-rw-r--r--protocols/MRA/src/MraMPop.cpp17
-rw-r--r--protocols/MRA/src/MraSendQueue.cpp11
-rw-r--r--protocols/MRA/src/Sdk/ListMT.h22
5 files changed, 37 insertions, 79 deletions
diff --git a/protocols/MRA/src/MraAvatars.cpp b/protocols/MRA/src/MraAvatars.cpp
index 2e757f7a66..2c709a8a3c 100644
--- a/protocols/MRA/src/MraAvatars.cpp
+++ b/protocols/MRA/src/MraAvatars.cpp
@@ -57,35 +57,30 @@ DWORD CMraProto::MraAvatarsQueueInitialize(HANDLE *phAvatarsQueueHandle)
return ERROR_INVALID_HANDLE;
MRA_AVATARS_QUEUE *pmraaqAvatarsQueue = new MRA_AVATARS_QUEUE();
- if (pmraaqAvatarsQueue == NULL)
- return GetLastError();
- DWORD dwRetErrorCode = ListMTInitialize(pmraaqAvatarsQueue);
- if (dwRetErrorCode == NO_ERROR) {
- char szBuffer[MAX_PATH];
- mir_snprintf(szBuffer, SIZEOF(szBuffer), "%s %s", m_szModuleName, Translate("Avatars' plugin connections"));
-
- NETLIBUSER nlu = { sizeof(nlu) };
- nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS;
- nlu.szSettingsModule = MRA_AVT_SECT_NAME;
- nlu.szDescriptiveName = szBuffer;
- pmraaqAvatarsQueue->hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
- if (pmraaqAvatarsQueue->hNetlibUser) {
- InterlockedExchange((volatile LONG*)&pmraaqAvatarsQueue->bIsRunning, TRUE);
- pmraaqAvatarsQueue->hThreadEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- pmraaqAvatarsQueue->iThreadsCount = db_get_dw(NULL, MRA_AVT_SECT_NAME, "WorkThreadsCount", MRA_AVT_DEFAULT_WRK_THREAD_COUNTS);
- if (pmraaqAvatarsQueue->iThreadsCount == 0)
- pmraaqAvatarsQueue->iThreadsCount = 1;
- if (pmraaqAvatarsQueue->iThreadsCount > MAXIMUM_WAIT_OBJECTS)
- pmraaqAvatarsQueue->iThreadsCount = MAXIMUM_WAIT_OBJECTS;
- for (int i = 0; i < pmraaqAvatarsQueue->iThreadsCount; i++)
- pmraaqAvatarsQueue->hThread[i] = ForkThreadEx(&CMraProto::MraAvatarsThreadProc, pmraaqAvatarsQueue, 0);
-
- *phAvatarsQueueHandle = (HANDLE)pmraaqAvatarsQueue;
- }
+ char szBuffer[MAX_PATH];
+ mir_snprintf(szBuffer, SIZEOF(szBuffer), "%s %s", m_szModuleName, Translate("Avatars' plugin connections"));
+
+ NETLIBUSER nlu = { sizeof(nlu) };
+ nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS;
+ nlu.szSettingsModule = MRA_AVT_SECT_NAME;
+ nlu.szDescriptiveName = szBuffer;
+ pmraaqAvatarsQueue->hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+ if (pmraaqAvatarsQueue->hNetlibUser) {
+ InterlockedExchange((volatile LONG*)&pmraaqAvatarsQueue->bIsRunning, TRUE);
+ pmraaqAvatarsQueue->hThreadEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+ pmraaqAvatarsQueue->iThreadsCount = db_get_dw(NULL, MRA_AVT_SECT_NAME, "WorkThreadsCount", MRA_AVT_DEFAULT_WRK_THREAD_COUNTS);
+ if (pmraaqAvatarsQueue->iThreadsCount == 0)
+ pmraaqAvatarsQueue->iThreadsCount = 1;
+ if (pmraaqAvatarsQueue->iThreadsCount > MAXIMUM_WAIT_OBJECTS)
+ pmraaqAvatarsQueue->iThreadsCount = MAXIMUM_WAIT_OBJECTS;
+ for (int i = 0; i < pmraaqAvatarsQueue->iThreadsCount; i++)
+ pmraaqAvatarsQueue->hThread[i] = ForkThreadEx(&CMraProto::MraAvatarsThreadProc, pmraaqAvatarsQueue, 0);
+
+ *phAvatarsQueueHandle = (HANDLE)pmraaqAvatarsQueue;
}
- return dwRetErrorCode;
+ return NO_ERROR;
}
void CMraProto::MraAvatarsQueueClear(HANDLE hAvatarsQueueHandle)
@@ -129,7 +124,6 @@ void CMraProto::MraAvatarsQueueDestroy(HANDLE hAvatarsQueueHandle)
MraAvatarsQueueClear(hAvatarsQueueHandle);
- ListMTDestroy(pmraaqAvatarsQueue);
Netlib_CloseHandle(pmraaqAvatarsQueue->hNetlibUser);
delete pmraaqAvatarsQueue;
}
diff --git a/protocols/MRA/src/MraFilesQueue.cpp b/protocols/MRA/src/MraFilesQueue.cpp
index f795753d96..6d0a7642b5 100644
--- a/protocols/MRA/src/MraFilesQueue.cpp
+++ b/protocols/MRA/src/MraFilesQueue.cpp
@@ -7,7 +7,7 @@
struct MRA_FILES_QUEUE : public LIST_MT
{
- DWORD dwSendTimeOutInterval;
+ DWORD dwSendTimeOutInterval;
};
struct MRA_FILES_QUEUE_FILE
@@ -141,18 +141,13 @@ DWORD MraFilesQueueInitialize(DWORD dwSendTimeOutInterval, HANDLE *phFilesQueueH
if (!phFilesQueueHandle)
return ERROR_INVALID_HANDLE;
- MRA_FILES_QUEUE *pmrafqFilesQueue = (MRA_FILES_QUEUE*)mir_calloc(sizeof(MRA_FILES_QUEUE));
+ MRA_FILES_QUEUE *pmrafqFilesQueue = new MRA_FILES_QUEUE();
if (!pmrafqFilesQueue)
return GetLastError();
- DWORD dwRetErrorCode = ListMTInitialize(pmrafqFilesQueue);
- if (dwRetErrorCode == NO_ERROR) {
- pmrafqFilesQueue->dwSendTimeOutInterval = dwSendTimeOutInterval;
- *phFilesQueueHandle = (HANDLE)pmrafqFilesQueue;
- }
- else mir_free(pmrafqFilesQueue);
-
- return dwRetErrorCode;
+ pmrafqFilesQueue->dwSendTimeOutInterval = dwSendTimeOutInterval;
+ *phFilesQueueHandle = (HANDLE)pmrafqFilesQueue;
+ return NO_ERROR;
}
void MraFilesQueueDestroy(HANDLE hFilesQueueHandle)
@@ -167,8 +162,7 @@ void MraFilesQueueDestroy(HANDLE hFilesQueueHandle)
while (ListMTItemGetFirst(pmrafqFilesQueue, NULL, (LPVOID*)&dat) == NO_ERROR)
MraFilesQueueItemFree(dat);
}
- ListMTDestroy(pmrafqFilesQueue);
- mir_free(pmrafqFilesQueue);
+ delete pmrafqFilesQueue;
}
DWORD MraFilesQueueItemFindByID(HANDLE hFilesQueueHandle, DWORD dwIDRequest, MRA_FILES_QUEUE_ITEM **ppmrafqFilesQueueItem)
diff --git a/protocols/MRA/src/MraMPop.cpp b/protocols/MRA/src/MraMPop.cpp
index 9796744f29..55f485eae7 100644
--- a/protocols/MRA/src/MraMPop.cpp
+++ b/protocols/MRA/src/MraMPop.cpp
@@ -11,8 +11,8 @@ struct MRA_MPOP_SESSION_QUEUE : public FIFO_MT
struct MRA_MPOP_SESSION_QUEUE_ITEM : public FIFO_MT_ITEM
{
- LPSTR lpszUrl; /* Url to open. */
- size_t dwUrlSize;
+ LPSTR lpszUrl; /* Url to open. */
+ size_t dwUrlSize;
};
void MraMPopSessionQueueClear(HANDLE hMPopSessionQueue);
@@ -24,14 +24,10 @@ DWORD MraMPopSessionQueueInitialize(HANDLE *phMPopSessionQueue)
if ((*phMPopSessionQueue))
return ERROR_ALREADY_INITIALIZED;
- MRA_MPOP_SESSION_QUEUE *pmpsqMPopSessionQueue = (MRA_MPOP_SESSION_QUEUE*)mir_calloc(sizeof(MRA_MPOP_SESSION_QUEUE));
+ MRA_MPOP_SESSION_QUEUE *pmpsqMPopSessionQueue = new MRA_MPOP_SESSION_QUEUE();
if (!pmpsqMPopSessionQueue)
return GetLastError();
- pmpsqMPopSessionQueue->bKeyValid = false;
- pmpsqMPopSessionQueue->lpszMPOPKey = NULL;
- pmpsqMPopSessionQueue->dwMPOPKeySize = 0;
- ListMTInitialize(pmpsqMPopSessionQueue);
*phMPopSessionQueue = (HANDLE)pmpsqMPopSessionQueue;
return NO_ERROR;
}
@@ -59,8 +55,7 @@ void MraMPopSessionQueueDestroy(HANDLE hMPopSessionQueue)
MRA_MPOP_SESSION_QUEUE *pmpsqMPopSessionQueue = (MRA_MPOP_SESSION_QUEUE*)hMPopSessionQueue;
MraMPopSessionQueueClear(hMPopSessionQueue);
- ListMTDestroy(pmpsqMPopSessionQueue);
- mir_free(pmpsqMPopSessionQueue);
+ delete pmpsqMPopSessionQueue;
}
DWORD CMraProto::MraMPopSessionQueueAddUrl(HANDLE hMPopSessionQueue, const CMStringA &lpszUrl)
@@ -149,7 +144,7 @@ void CMraProto::MraMPopSessionQueueFlush(HANDLE hMPopSessionQueue)
MRA_MPOP_SESSION_QUEUE *pmpsqMPopSessionQueue = (MRA_MPOP_SESSION_QUEUE*)hMPopSessionQueue;
MRA_MPOP_SESSION_QUEUE_ITEM *pmpsqi;
- while ( FifoMTItemPop(pmpsqMPopSessionQueue, NULL, (LPVOID*)&pmpsqi) == NO_ERROR) {
+ while (FifoMTItemPop(pmpsqMPopSessionQueue, NULL, (LPVOID*)&pmpsqi) == NO_ERROR) {
CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)pmpsqi->lpszUrl);
mir_free(pmpsqi);
}
@@ -170,7 +165,7 @@ DWORD MraMPopSessionQueueSetNewMPopKey(HANDLE hMPopSessionQueue, const CMStringA
pmpsqMPopSessionQueue->bKeyValid = true;
pmpsqMPopSessionQueue->dwMPOPKeySize = szKey.GetLength();
memcpy(pmpsqMPopSessionQueue->lpszMPOPKey, szKey, szKey.GetLength());
- (*(pmpsqMPopSessionQueue->lpszMPOPKey + szKey.GetLength())) = 0;
+ *(pmpsqMPopSessionQueue->lpszMPOPKey + szKey.GetLength()) = 0;
return NO_ERROR;
}
diff --git a/protocols/MRA/src/MraSendQueue.cpp b/protocols/MRA/src/MraSendQueue.cpp
index 80b9f20b1a..bb6467dfaa 100644
--- a/protocols/MRA/src/MraSendQueue.cpp
+++ b/protocols/MRA/src/MraSendQueue.cpp
@@ -28,13 +28,9 @@ DWORD MraSendQueueInitialize(DWORD dwSendTimeOutInterval, HANDLE *phSendQueueHan
return ERROR_INVALID_HANDLE;
MRA_SEND_QUEUE *pmrasqSendQueue = new MRA_SEND_QUEUE();
-
- DWORD dwRetErrorCode = ListMTInitialize(pmrasqSendQueue);
- if (dwRetErrorCode == NO_ERROR) {
- pmrasqSendQueue->dwSendTimeOutInterval = dwSendTimeOutInterval;
- *phSendQueueHandle = (HANDLE)pmrasqSendQueue;
- }
- return dwRetErrorCode;
+ pmrasqSendQueue->dwSendTimeOutInterval = dwSendTimeOutInterval;
+ *phSendQueueHandle = (HANDLE)pmrasqSendQueue;
+ return NO_ERROR;
}
void MraSendQueueDestroy(HANDLE hSendQueueHandle)
@@ -52,7 +48,6 @@ void MraSendQueueDestroy(HANDLE hSendQueueHandle)
}
}
- ListMTDestroy(pmrasqSendQueue);
delete pmrasqSendQueue;
}
diff --git a/protocols/MRA/src/Sdk/ListMT.h b/protocols/MRA/src/Sdk/ListMT.h
index 399765fba2..d87173b227 100644
--- a/protocols/MRA/src/Sdk/ListMT.h
+++ b/protocols/MRA/src/Sdk/ListMT.h
@@ -55,7 +55,7 @@ typedef CONST PLIST_MT_ITEM PCLIST_MT_ITEM, LPCLIST_MT_ITEM;
// структура для работы со списком, заголовок списка
-typedef struct _LIST_MT
+typedef struct _LIST_MT : public MZeroedObject
{
size_t nCount; // *количество элементов в списке
PLIST_MT_ITEM plmtiFirst; // *указывает на первый элемент в списке
@@ -74,26 +74,6 @@ typedef struct _LIST_MT_ITERATOR
typedef CONST PLIST_MT_ITERATOR PCLIST_MT_ITERATOR, LPCLIST_MT_ITERATOR;
-
-
-__inline DWORD ListMTInitialize(PCLIST_MT pclmtListMT)
-{
- InterlockedExchangePointer((volatile PVOID*)&pclmtListMT->nCount,NULL);
- pclmtListMT->plmtiFirst=NULL;
- pclmtListMT->plmtiLast=NULL;
- return NO_ERROR;
-}
-
-
-__inline void ListMTDestroy(PCLIST_MT pclmtListMT)
-{
- InterlockedExchangePointer((volatile PVOID*)&pclmtListMT->nCount,NULL);
- pclmtListMT->plmtiFirst=NULL;
- pclmtListMT->plmtiLast=NULL;
- SecureZeroMemory(&pclmtListMT->cs,sizeof(CRITICAL_SECTION));
-}
-
-
__inline size_t ListMTGetCount(PCLIST_MT pclmtListMT)
{
return((size_t)InterlockedCompareExchangePointer((LPVOID*)&pclmtListMT->nCount,NULL,NULL));