diff options
author | George Hazan <george.hazan@gmail.com> | 2013-05-06 15:42:54 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-05-06 15:42:54 +0000 |
commit | 27d17244cb0af6f8b04e2b6725d504c336dabb07 (patch) | |
tree | 397c9ff1289c02c4a886e06919f8c67fd6d92e5d /protocols/Skype/src | |
parent | 14eec47b6101e1f96437f7bb1057ee04a3cc4f63 (diff) |
memory leaks
git-svn-id: http://svn.miranda-ng.org/main/trunk@4592 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype/src')
-rw-r--r-- | protocols/Skype/src/skype_avatars.cpp | 2 | ||||
-rw-r--r-- | protocols/Skype/src/skype_chat.cpp | 24 | ||||
-rw-r--r-- | protocols/Skype/src/skype_contacts.cpp | 8 | ||||
-rw-r--r-- | protocols/Skype/src/skype_dialogs.cpp | 14 | ||||
-rw-r--r-- | protocols/Skype/src/skype_events.cpp | 13 | ||||
-rw-r--r-- | protocols/Skype/src/skype_menus.cpp | 4 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 7 |
7 files changed, 28 insertions, 44 deletions
diff --git a/protocols/Skype/src/skype_avatars.cpp b/protocols/Skype/src/skype_avatars.cpp index adf956edeb..9e53ff1485 100644 --- a/protocols/Skype/src/skype_avatars.cpp +++ b/protocols/Skype/src/skype_avatars.cpp @@ -71,7 +71,7 @@ wchar_t * CSkypeProto::GetContactAvatarFilePath(HANDLE hContact) if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)path);
- ::mir_ptr<wchar_t> sid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
+ mir_ptr<wchar_t> sid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
if (hContact != NULL)
::mir_sntprintf(path, MAX_PATH, _T("%s\\%s.jpg"), path, sid);
else if (sid != NULL)
diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp index 60ec6a65de..00926950b5 100644 --- a/protocols/Skype/src/skype_chat.cpp +++ b/protocols/Skype/src/skype_chat.cpp @@ -32,7 +32,7 @@ HANDLE CSkypeProto::GetChatRoomByCid(const wchar_t *cid) {
if (this->IsProtoContact(hContact) && this->IsChatRoom(hContact))
{
- ::mir_ptr<wchar_t> chatID(::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID"));
+ mir_ptr<wchar_t> chatID(::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID"));
if (::wcscmp(cid, chatID) == 0)
return hContact;
}
@@ -80,8 +80,8 @@ void CSkypeProto::ChatValidateContact(HANDLE hItem, HWND hwndList, const StringL //HANDLE hContact = (HANDLE)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
if (this->IsProtoContact(hItem) && !this->IsChatRoom(hItem))
{
- std::wstring sid = ::db_get_wsa(hItem, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
- if (sid.empty() || contacts.contains(sid.c_str()))
+ mir_ptr<wchar_t> sid( ::db_get_wsa(hItem, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
+ if (sid == NULL || contacts.contains(sid))
::SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hItem, 0);
}
else
@@ -136,8 +136,8 @@ void CSkypeProto::GetInvitedContacts(HANDLE hItem, HWND hwndList, StringList &ch }
else
{
- std::wstring sid(::db_get_wsa(hItem, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
- chatTargets.insert(sid.c_str());
+ mir_ptr<wchar_t> login( ::db_get_wsa(hItem, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
+ chatTargets.insert(login);
}
}
}
@@ -415,7 +415,7 @@ INT_PTR __cdecl CSkypeProto::OnJoinChat(WPARAM wParam, LPARAM) HANDLE hContact = (HANDLE)wParam;
if (hContact)
{
- wchar_t *cid = ::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID");
+ mir_ptr<wchar_t> cid( ::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID"));
SEString data;
CConversation::Ref conversation;
@@ -427,8 +427,6 @@ INT_PTR __cdecl CSkypeProto::OnJoinChat(WPARAM wParam, LPARAM) conversation->Join();
this->JoinToChat(conversation);
-
- ::mir_free(cid);
}
return 0;
@@ -438,13 +436,7 @@ INT_PTR __cdecl CSkypeProto::OnLeaveChat(WPARAM wParam, LPARAM) {
HANDLE hContact = (HANDLE)wParam;
if (hContact)
- {
- wchar_t *cid = ::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID");
-
- this->LeaveChat(cid);
-
- ::mir_free(cid);
- }
+ this->LeaveChat( mir_ptr<wchar_t>( ::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID")));
return 0;
}
@@ -481,7 +473,7 @@ int __cdecl CSkypeProto::OnGCEventHook(WPARAM, LPARAM lParam) if (g_skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation, false))
{
CMessage::Ref message;
- ::mir_ptr<char> text(::mir_utf8encodeW(gch->ptszText));
+ mir_ptr<char> text(::mir_utf8encodeW(gch->ptszText));
conversation->PostText((char *)text, message);
}
}
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index fbbb4c00bc..f50d60e416 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -166,8 +166,8 @@ HANDLE CSkypeProto::GetContactBySid(const wchar_t *sid) {
if (this->IsProtoContact(hContact) && !this->IsChatRoom(hContact))
{
- std::wstring contactSid = ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
- if (contactSid.compare(sid) == 0)
+ mir_ptr<wchar_t> contactSid( ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
+ if ( lstrcmp(contactSid, sid) == 0)
return hContact;
}
@@ -278,13 +278,13 @@ void __cdecl CSkypeProto::LoadContactList(void* data) this->UpdateContactAuthState(hContact, contact);
this->UpdateContactStatus(hContact, contact);
- wchar_t *nick = ::db_get_wsa(hContact, "CList", "MyHandle");
+ mir_ptr<wchar_t> nick( ::db_get_wsa(hContact, "CList", "MyHandle"));
if ( !nick || !::wcslen(nick))
{
SEString data;
contact->GetPropFullname(data);
- mir_ptr<wchar_t> nick = ::mir_utf8decodeW(data);
+ nick = ::mir_utf8decodeW(data);
::db_set_ws(hContact, "CList", "MyHandle", nick);
}
diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp index 2cb8fd675e..73968b9dc2 100644 --- a/protocols/Skype/src/skype_dialogs.cpp +++ b/protocols/Skype/src/skype_dialogs.cpp @@ -13,9 +13,8 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR proto = (CSkypeProto *)lParam;
::SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
{
- wchar_t *sid = ::db_get_wsa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_LOGIN);
+ mir_ptr<wchar_t> sid( ::db_get_wsa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_LOGIN));
SetDlgItemText(hwnd, IDC_SL, sid);
- ::mir_free(sid);
}
{
char *pwd = ::db_get_sa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_PASSWORD);
@@ -55,9 +54,8 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR SendDlgItemMessage(hwnd, IDC_GROUP, EM_LIMITTEXT, SKYPE_GROUP_NAME_LIMIT, 0);
- wchar_t *defgroup = db_get_wsa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_DEF_GROUP);
+ mir_ptr<wchar_t> defgroup( db_get_wsa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_DEF_GROUP));
SetDlgItemText(hwnd, IDC_GROUP, defgroup);
- ::mir_free(defgroup);
}
return TRUE;
@@ -363,8 +361,8 @@ INT_PTR CALLBACK CSkypeProto::SkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam if (!szProto)
break;
- ::SetDlgItemText(hwndDlg, IDC_SID, ::db_get_wsa(hContact, ppro->m_szModuleName, SKYPE_SETTINGS_LOGIN));
- ::SetDlgItemText(hwndDlg, IDC_STATUSTEXT, ::db_get_wsa(hContact, ppro->m_szModuleName, "XStatusMsg") ? ::db_get_wsa(hContact, ppro->m_szModuleName, "XStatusMsg") : TranslateT("<not specified>"));
+ ::SetDlgItemText(hwndDlg, IDC_SID, mir_ptr<wchar_t>(::db_get_wsa(hContact, ppro->m_szModuleName, SKYPE_SETTINGS_LOGIN)));
+ ::SetDlgItemText(hwndDlg, IDC_STATUSTEXT, mir_ptr<wchar_t>(::db_get_wsa(hContact, ppro->m_szModuleName, "XStatusMsg")) ? mir_ptr<wchar_t>(::db_get_wsa(hContact, ppro->m_szModuleName, "XStatusMsg")) : TranslateT("<not specified>"));
if (::db_get_dw(hContact, ppro->m_szModuleName, "OnlineSinceTS", 0)) {
TCHAR date[64];
@@ -453,7 +451,7 @@ static INT_PTR CALLBACK PersonalSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar }
- wchar_t *lang = ::db_get_wsa(NULL, ppro->m_szModuleName, "Language1");
+ mir_ptr<wchar_t> lang( ::db_get_wsa(NULL, ppro->m_szModuleName, "Language1"));
for (std::map<std::wstring, std::wstring>::iterator it = CSkypeProto::languages.begin(); it != CSkypeProto::languages.end(); ++it)
{
int nItem = SendMessage(GetDlgItem(hwndDlg, IDC_LANGUAGE), CB_ADDSTRING, 0, (LPARAM)TranslateTS(it->second.c_str()));
@@ -659,7 +657,7 @@ static INT_PTR CALLBACK HomeSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, else
SetDlgItemText(hwndDlg, IDC_STATE, _T(""));
- wchar_t *countr = ::db_get_wsa(NULL, ppro->m_szModuleName, "Country");
+ mir_ptr<wchar_t> countr( ::db_get_wsa(NULL, ppro->m_szModuleName, "Country"));
for (int i = 0; i < g_cbCountries; i++) {
if (g_countries[i].id != 0xFFFF && g_countries[i].id != 0) {
TCHAR *country = mir_a2t(g_countries[i].szName);
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index dd45a37b42..e2622a604b 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -53,7 +53,7 @@ int CSkypeProto::OnContactDeleted(WPARAM wParam, LPARAM lParam) {
if (this->IsChatRoom(hContact))
{
- wchar_t *chatID = ::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID");
+ mir_ptr<wchar_t> chatID(::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID"));
this->LeaveChat(chatID);
CConversation::Ref conversation;
@@ -107,7 +107,7 @@ int __cdecl CSkypeProto::OnTabSRMMButtonPressed(WPARAM wParam, LPARAM lParam) if (this->IsOnline() && !this->IsChatRoom(hContact))
{
StringList targets;
- targets.insert(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
+ targets.insert( mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN)));
this->StartChat(targets);
}
@@ -247,18 +247,13 @@ void CSkypeProto::OnMessageSended(CConversation::Ref &conversation, CMessage::Re else
{
conversation->GetPropIdentity(data);
- wchar_t *cid = ::mir_utf8decodeW(data);
+ mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
- wchar_t *nick = ::db_get_wsa(NULL, this->m_szModuleName, "Nick");
+ mir_ptr<wchar_t> nick( ::db_get_wsa(NULL, this->m_szModuleName, "Nick"));
if (::wcsicmp(nick, L"") == 0)
- {
nick = ::db_get_wsa(NULL, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
- }
this->SendChatMessage(cid, nick, ::mir_utf8decodeW(text));
-
- ::mir_free(nick);
- ::mir_free(cid);
}
}
diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp index db0cb991a3..536e587d86 100644 --- a/protocols/Skype/src/skype_menus.cpp +++ b/protocols/Skype/src/skype_menus.cpp @@ -75,7 +75,7 @@ int CSkypeProto::GrantAuth(WPARAM wParam, LPARAM lParam) {
CContact::Ref contact;
HANDLE hContact = (HANDLE)wParam;
- SEString sid(::mir_u2a(::mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN))));
+ SEString sid(::mir_u2a(mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN))));
if (g_skype->GetContact(sid, contact))
{
if (contact->SetBuddyStatus(true))
@@ -92,7 +92,7 @@ int CSkypeProto::RevokeAuth(WPARAM wParam, LPARAM lParam) {
CContact::Ref contact;
HANDLE hContact = (HANDLE)wParam;
- SEString sid(::mir_u2a(::mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN))));
+ SEString sid(::mir_u2a(mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN))));
if (g_skype->GetContact(sid, contact))
{
if (contact->SetBuddyStatus(false))
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index e0e7f1b74e..d320f51b84 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -125,7 +125,7 @@ int __cdecl CSkypeProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage) if (this->IsOnline() && hContact)
{
CContact::Ref contact;
- SEString sid(::mir_u2a(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN)));
+ SEString sid( mir_ptr<char>(::mir_u2a( mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN)))));
if (g_skype->GetContact(sid, contact))
{
contact->SetBuddyStatus(Contact::AUTHORIZED_BY_ME);
@@ -353,7 +353,7 @@ HANDLE __cdecl CSkypeProto::SendFile(HANDLE hContact, const TCHAR *szDescription int __cdecl CSkypeProto::SendMsg(HANDLE hContact, int flags, const char *msg)
{
SEStringList targets;
- wchar_t *sid = ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
+ mir_ptr<wchar_t> sid( ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
SEString identity = ::mir_u2a(sid);
targets.append(identity);
@@ -421,7 +421,7 @@ int __cdecl CSkypeProto::UserIsTyping(HANDLE hContact, int type) {
if (hContact && this->IsOnline() && this->m_iStatus != ID_STATUS_INVISIBLE)
{
- wchar_t *sid = ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
+ mir_ptr<wchar_t> sid( ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
if (::wcsicmp(sid, this->login) != 0)
{
SEStringList targets;
@@ -444,7 +444,6 @@ int __cdecl CSkypeProto::UserIsTyping(HANDLE hContact, int type) }
}
}
- ::mir_free(sid);
}
return 1;
|