summaryrefslogtreecommitdiff
path: root/protocols/IcqOscarJ
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-21 11:11:20 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-21 11:11:20 +0000
commitaa8f4373e0c9614b7d64a5760c0fa071b1c1edc9 (patch)
tree218b31bc3166dfc36adf55800b7e7cdea17a8c68 /protocols/IcqOscarJ
parentc80bc292b555c6666930790c399f6fac6226c468 (diff)
- MZeroedObject used instead of the operator new() inlining
- SAFE_DELETE of local objects removed from ICQ git-svn-id: http://svn.miranda-ng.org/main/trunk@1092 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/IcqOscarJ')
-rw-r--r--protocols/IcqOscarJ/changeinfo/changeinfo.h2
-rw-r--r--protocols/IcqOscarJ/changeinfo/dlgproc.cpp66
-rw-r--r--protocols/IcqOscarJ/icq_avatar.cpp19
-rw-r--r--protocols/IcqOscarJ/icq_avatar.h4
-rw-r--r--protocols/IcqOscarJ/icq_proto.h9
-rw-r--r--protocols/IcqOscarJ/icq_rates.cpp8
-rw-r--r--protocols/IcqOscarJ/icq_rates.h6
-rw-r--r--protocols/IcqOscarJ/icq_server.cpp6
-rw-r--r--protocols/IcqOscarJ/icqoscar.h1
-rw-r--r--protocols/IcqOscarJ/utilities.cpp2
-rw-r--r--protocols/IcqOscarJ/utilities.h22
11 files changed, 65 insertions, 80 deletions
diff --git a/protocols/IcqOscarJ/changeinfo/changeinfo.h b/protocols/IcqOscarJ/changeinfo/changeinfo.h
index 9cb2e37220..ecc4fc3106 100644
--- a/protocols/IcqOscarJ/changeinfo/changeinfo.h
+++ b/protocols/IcqOscarJ/changeinfo/changeinfo.h
@@ -71,7 +71,7 @@ extern const SettingItem setting[];
extern const int settingCount;
//dlgproc.c
-struct ChangeInfoData : public void_struct
+struct ChangeInfoData : public MZeroedObject
{
HWND hwndDlg;
CIcqProto *ppro;
diff --git a/protocols/IcqOscarJ/changeinfo/dlgproc.cpp b/protocols/IcqOscarJ/changeinfo/dlgproc.cpp
index babb269c28..404777aa97 100644
--- a/protocols/IcqOscarJ/changeinfo/dlgproc.cpp
+++ b/protocols/IcqOscarJ/changeinfo/dlgproc.cpp
@@ -39,17 +39,17 @@ static int DrawTextUtf(HDC hDC, char *text, LPRECT lpRect, UINT uFormat, LPSIZE
if (lpSize)
GetTextExtentPoint32W(hDC, tmp, strlennull(tmp), lpSize);
SAFE_FREE((void**)&tmp);
-
+
return res;
}
char* ChangeInfoData::GetItemSettingText(int i, char *buf, size_t bufsize)
{
- char *text = buf;
- int alloced = 0;
+ char *text = buf;
+ int alloced = 0;
- buf[0] = '\0';
+ buf[0] = '\0';
if (settingData[i].value == 0 && !(setting[i].displayType & LIF_ZEROISVALID))
{
@@ -64,7 +64,7 @@ char* ChangeInfoData::GetItemSettingText(int i, char *buf, size_t bufsize)
case LI_STRING:
case LI_LONGSTRING:
text = BinaryToEscapes((char*)settingData[i].value);
- alloced = 1;
+ alloced = 1;
break;
case LI_NUMBER:
@@ -78,19 +78,19 @@ char* ChangeInfoData::GetItemSettingText(int i, char *buf, size_t bufsize)
{
text = ICQTranslateUtfStatic(LPGEN("Unknown value"), buf, bufsize);
- FieldNamesItem *list = (FieldNamesItem*)setting[i].pList;
- for (int j=0; TRUE; j++)
+ FieldNamesItem *list = (FieldNamesItem*)setting[i].pList;
+ for (int j=0; TRUE; j++)
if (list[j].code == settingData[i].value)
{
text = ICQTranslateUtfStatic(list[j].text, buf, bufsize);
break;
}
- else if (!list[j].text)
- {
- if (list[j].code == settingData[i].value)
- text = ICQTranslateUtfStatic("Unspecified", buf, bufsize);
- break;
- }
+ else if (!list[j].text)
+ {
+ if (list[j].code == settingData[i].value)
+ text = ICQTranslateUtfStatic("Unspecified", buf, bufsize);
+ break;
+ }
}
break;
}
@@ -102,23 +102,23 @@ char* ChangeInfoData::GetItemSettingText(int i, char *buf, size_t bufsize)
else
{
if (alloced)
- {
+ {
SAFE_FREE(&text);
- alloced = 0;
- }
- text = "********";
+ alloced = 0;
+ }
+ text = "********";
}
}
- if (text != buf)
- {
- char *tmp = text;
+ if (text != buf)
+ {
+ char *tmp = text;
- text = null_strcpy(buf, text, bufsize - 1);
- if (alloced)
- SAFE_FREE(&tmp);
- }
+ text = null_strcpy(buf, text, bufsize - 1);
+ if (alloced)
+ SAFE_FREE(&tmp);
+ }
- return text;
+ return text;
}
@@ -503,7 +503,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
dat->ClearChangeFlags();
UnhookEvent(dat->hAckHook);
- dat->hAckHook = NULL;
+ dat->hAckHook = NULL;
EnableDlgItem(hwndDlg, IDC_LIST, TRUE);
EnableDlgItem(hwndDlg, IDC_UPLOADING, FALSE);
SetDlgItemTextUtf(hwndDlg, IDC_UPLOADING, ICQTranslateUtfStatic(LPGEN("Upload complete"), str, MAX_PATH));
@@ -517,7 +517,7 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
EnableDlgItem(hwndDlg, IDC_UPLOADING, FALSE);
SetDlgItemTextUtf(hwndDlg, IDC_UPLOADING, ICQTranslateUtfStatic(LPGEN("Upload FAILED"), str, MAX_PATH));
SendMessage(GetParent(hwndDlg), PSM_FORCECHANGED, 0, 0);
- EnableDlgItem(hwndDlg, IDC_SAVE, TRUE);
+ EnableDlgItem(hwndDlg, IDC_SAVE, TRUE);
}
break;
}
@@ -527,13 +527,13 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
UnhookEvent(dat->hAckHook);
dat->hAckHook = NULL;
}
- {
- HFONT hFont = (HFONT)SendMessage(dat->hwndList, WM_GETFONT, 0, 0);
- DeleteObject(hFont);
- }
+ {
+ HFONT hFont = (HFONT)SendMessage(dat->hwndList, WM_GETFONT, 0, 0);
+ DeleteObject(hFont);
+ }
dat->FreeStoredDbSettings();
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
- SAFE_DELETE((void_struct**)&dat);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
+ delete dat;
break;
}
return FALSE;
diff --git a/protocols/IcqOscarJ/icq_avatar.cpp b/protocols/IcqOscarJ/icq_avatar.cpp
index 1678f609e5..29a92ec4a4 100644
--- a/protocols/IcqOscarJ/icq_avatar.cpp
+++ b/protocols/IcqOscarJ/icq_avatar.cpp
@@ -78,8 +78,7 @@ avatars_request* CIcqProto::ReleaseAvatarRequestInQueue(avatars_request *request
ar = ar->pNext;
}
- SAFE_DELETE(&request);
-
+ delete request;
return pNext;
}
@@ -859,7 +858,7 @@ int CIcqProto::GetAvatarData(HANDLE hContact, DWORD dwUin, const char *szUid, co
if (!ar->hash)
{ // alloc failed
m_avatarsMutex->Leave();
- SAFE_DELETE(&ar);
+ delete ar;
return 0;
}
memcpy(ar->hash, hash, hashlen); // copy the data
@@ -932,7 +931,7 @@ int CIcqProto::SetAvatarData(HANDLE hContact, WORD wRef, const BYTE *data, unsig
if (!ar->pData)
{ // alloc failed
m_avatarsMutex->Leave();
- SAFE_DELETE(&ar);
+ delete ar;
return 0;
}
memcpy(ar->pData, data, datalen); // copy the data
@@ -981,7 +980,7 @@ void __cdecl CIcqProto::AvatarThread(avatars_server_connection *pInfo)
{ // Release connection handler
icq_lock l(m_avatarsMutex);
- SAFE_DELETE(&pInfo);
+ delete pInfo;
}
NetLog_Server("%s thread ended.", "Avatar");
@@ -1010,8 +1009,8 @@ isLoggedIn(FALSE), stopThread(FALSE), isActive(FALSE)
avatars_server_connection::~avatars_server_connection()
{
- SAFE_DELETE(&m_ratesMutex);
- SAFE_DELETE(&localSeqMutex);
+ delete m_ratesMutex;
+ delete localSeqMutex;
}
@@ -1206,7 +1205,7 @@ void avatars_server_connection::checkRequestQueue()
if (GetTickCount() > pRequest->timeOut)
{ // expired contact block, remove
*ppRequest = pRequest->pNext;
- SAFE_DELETE(&pRequest);
+ delete pRequest;
}
else // it is not time, move to next request
ppRequest = &pRequest->pNext;
@@ -1234,7 +1233,7 @@ void avatars_server_connection::checkRequestQueue()
sendUploadAvatarRequest(pRequest->hContact, pRequest->wRef, pRequest->pData, pRequest->cbData);
break;
}
- SAFE_DELETE(&pRequest);
+ delete pRequest;
ppro->m_avatarsMutex->Enter();
}
@@ -1327,7 +1326,7 @@ void avatars_server_connection::connectionThread()
{ // release rates
icq_lock l(m_ratesMutex);
- SAFE_DELETE((void_struct**)&m_rates);
+ SAFE_DELETE((MZeroedObject**)&m_rates);
}
SAFE_FREE((void**)&pCookie);
diff --git a/protocols/IcqOscarJ/icq_avatar.h b/protocols/IcqOscarJ/icq_avatar.h
index 7ac8ed7469..6bfcb65c45 100644
--- a/protocols/IcqOscarJ/icq_avatar.h
+++ b/protocols/IcqOscarJ/icq_avatar.h
@@ -93,7 +93,7 @@ public:
__inline static void SAFE_DELETE(avatars_server_connection **p) { SAFE_DELETE((lockable_struct**)p); };
-struct avatars_request : public void_struct
+struct avatars_request : public MZeroedObject
{
int type;
HANDLE hContact;
@@ -112,7 +112,7 @@ public:
virtual ~avatars_request();
};
-__inline static void SAFE_DELETE(avatars_request **p) { SAFE_DELETE((void_struct**)p); };
+__inline static void SAFE_DELETE(avatars_request **p) { SAFE_DELETE((MZeroedObject**)p); };
#define ART_GET 1
#define ART_UPLOAD 2
diff --git a/protocols/IcqOscarJ/icq_proto.h b/protocols/IcqOscarJ/icq_proto.h
index 6c2b4a059e..7293763d65 100644
--- a/protocols/IcqOscarJ/icq_proto.h
+++ b/protocols/IcqOscarJ/icq_proto.h
@@ -51,18 +51,11 @@ struct userinfo
time_t queued;
};
-struct CIcqProto : public PROTO_INTERFACE
+struct CIcqProto : public PROTO_INTERFACE, public MZeroedObject
{
CIcqProto( const char*, const TCHAR* );
~CIcqProto();
- __inline void* operator new( size_t size )
- { return SAFE_MALLOC( size );
- }
- __inline void operator delete( void* p )
- { SAFE_FREE( &p );
- }
-
//====================================================================================
// PROTO_INTERFACE
//====================================================================================
diff --git a/protocols/IcqOscarJ/icq_rates.cpp b/protocols/IcqOscarJ/icq_rates.cpp
index 09a1b27396..e7513ec148 100644
--- a/protocols/IcqOscarJ/icq_rates.cpp
+++ b/protocols/IcqOscarJ/icq_rates.cpp
@@ -334,7 +334,7 @@ rates_queue::rates_queue(CIcqProto *ppro, const char *szDescr, int nLimitLevel,
rates_queue::~rates_queue()
{
cleanup();
- SAFE_DELETE(&listsMutex);
+ delete listsMutex;
}
@@ -377,7 +377,7 @@ void rates_queue::cleanup()
ppro->NetLog_Server("Rates: Purging %d %s(s).", pendingListSize, szDescr);
for (int i=0; i < pendingListSize; i++)
- SAFE_DELETE((void_struct**)&pendingList[i]);
+ delete pendingList[i];
SAFE_FREE((void**)&pendingList);
pendingListSize = 0;
}
@@ -439,7 +439,7 @@ void rates_queue::processQueue()
if (nDelay < 10) nDelay = 10;
initDelay(nDelay, &rates_queue::processQueue);
}
- SAFE_DELETE((void_struct**)&item);
+ delete item;
}
@@ -461,7 +461,7 @@ void rates_queue::putItem(rates_queue_item *pItem, int nMinDelay)
{
if (duplicates == -1)
{ // discard existing, append new item
- SAFE_DELETE((void_struct**)&pendingList[i]);
+ delete pendingList[i];
memcpy(&pendingList[i], &pendingList[i + 1], (pendingListSize - i - 1) * sizeof(rates_queue_item*));
bFound = TRUE;
}
diff --git a/protocols/IcqOscarJ/icq_rates.h b/protocols/IcqOscarJ/icq_rates.h
index de5d9b76d0..ab16e74007 100644
--- a/protocols/IcqOscarJ/icq_rates.h
+++ b/protocols/IcqOscarJ/icq_rates.h
@@ -47,7 +47,7 @@ struct rates_group
int nPairs;
};
-struct rates : public void_struct
+struct rates : public MZeroedObject
{
private:
CIcqProto *ppro;
@@ -90,7 +90,7 @@ public:
//
// generic queue item
//
-struct rates_queue_item : public void_struct
+struct rates_queue_item : public MZeroedObject
{
friend struct rates_queue;
protected:
@@ -119,7 +119,7 @@ typedef void (rates_queue::*IcqRateFunc)(void);
//
// generic item queue (FIFO)
//
-struct rates_queue : public void_struct
+struct rates_queue : public MZeroedObject
{
private:
CIcqProto *ppro;
diff --git a/protocols/IcqOscarJ/icq_server.cpp b/protocols/IcqOscarJ/icq_server.cpp
index 87b975d6d3..63a5d63d84 100644
--- a/protocols/IcqOscarJ/icq_server.cpp
+++ b/protocols/IcqOscarJ/icq_server.cpp
@@ -221,9 +221,9 @@ void __cdecl CIcqProto::ServerThread(serverthread_start_info *infoParam)
{
icq_lock l(m_ratesMutex);
- SAFE_DELETE((void_struct**)&m_ratesQueue_Request);
- SAFE_DELETE((void_struct**)&m_ratesQueue_Response);
- SAFE_DELETE((void_struct**)&m_rates);
+ SAFE_DELETE((MZeroedObject**)&m_ratesQueue_Request);
+ SAFE_DELETE((MZeroedObject**)&m_ratesQueue_Response);
+ SAFE_DELETE((MZeroedObject**)&m_rates);
}
FlushServerIDs(); // clear server IDs list
diff --git a/protocols/IcqOscarJ/icqoscar.h b/protocols/IcqOscarJ/icqoscar.h
index b565eda497..97e9bf9da0 100644
--- a/protocols/IcqOscarJ/icqoscar.h
+++ b/protocols/IcqOscarJ/icqoscar.h
@@ -76,6 +76,7 @@
#include <m_protosvc.h>
#include <m_options.h>
#include <m_system.h>
+#include <m_system_cpp.h>
#include <m_userinfo.h>
#include <m_utils.h>
#include <m_idle.h>
diff --git a/protocols/IcqOscarJ/utilities.cpp b/protocols/IcqOscarJ/utilities.cpp
index 7ec9edcc8e..4f68ecb535 100644
--- a/protocols/IcqOscarJ/utilities.cpp
+++ b/protocols/IcqOscarJ/utilities.cpp
@@ -1654,7 +1654,7 @@ BOOL CIcqProto::validateStatusMessageRequest(HANDLE hContact, WORD byMessageType
}
-void __fastcall SAFE_DELETE(void_struct **p)
+void __fastcall SAFE_DELETE(MZeroedObject **p)
{
if (*p)
{
diff --git a/protocols/IcqOscarJ/utilities.h b/protocols/IcqOscarJ/utilities.h
index 4d881e578e..962ecce15f 100644
--- a/protocols/IcqOscarJ/utilities.h
+++ b/protocols/IcqOscarJ/utilities.h
@@ -1,22 +1,22 @@
// ---------------------------------------------------------------------------80
// ICQ plugin for Miranda Instant Messenger
// ________________________________________
-//
+//
// Copyright © 2000-2001 Richard Hughes, Roland Rabien, Tristan Van de Vreede
// Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2010 Joe Kucera
-//
+//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
@@ -107,20 +107,12 @@ void* __fastcall SAFE_REALLOC(void* p, size_t size);
__inline static void SAFE_FREE(char** str) { SAFE_FREE((void**)str); }
__inline static void SAFE_FREE(WCHAR** str) { SAFE_FREE((void**)str); }
-struct void_struct
-{
- __inline void* operator new(size_t size) { return SAFE_MALLOC(size); }
- __inline void operator delete(void *p) { SAFE_FREE(&p); }
-
- virtual ~void_struct() {};
-};
-
-struct lockable_struct: public void_struct
+struct lockable_struct: public MZeroedObject
{
private:
int nLockCount;
public:
- lockable_struct(): void_struct() { _Lock(); };
+ lockable_struct() { _Lock(); };
virtual ~lockable_struct() {};
void _Lock() { nLockCount++; };
@@ -129,7 +121,7 @@ public:
int getLockCount() { return nLockCount; };
};
-void __fastcall SAFE_DELETE(void_struct **p);
+void __fastcall SAFE_DELETE(MZeroedObject **p);
void __fastcall SAFE_DELETE(lockable_struct **p);
DWORD ICQWaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds, int bWaitAlways = FALSE);