summaryrefslogtreecommitdiff
path: root/src/modules/clist
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-08 11:41:27 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-08 11:41:27 +0000
commita1a932ba54cd0cebb1b7cc7088fc4261638e4f86 (patch)
treec98e37ff11e126234b06ba64e8e1aee6a803d704 /src/modules/clist
parentf7d1561aae86e90bfb02704264fc220fad59896c (diff)
GCDNF_NOCACHE, memleaks & crazy code
git-svn-id: http://svn.miranda-ng.org/main/trunk@844 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/clist')
-rw-r--r--src/modules/clist/clistsettings.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/modules/clist/clistsettings.cpp b/src/modules/clist/clistsettings.cpp
index 8b39b3cfd9..4e25504853 100644
--- a/src/modules/clist/clistsettings.cpp
+++ b/src/modules/clist/clistsettings.cpp
@@ -154,17 +154,18 @@ TCHAR* fnGetContactDisplayName(HANDLE hContact, int mode)
INT_PTR GetContactDisplayName(WPARAM wParam, LPARAM lParam)
{
+ static char retVal[200];
ClcCacheEntryBase* cacheEntry = NULL;
- char *buffer;
HANDLE hContact = (HANDLE)wParam;
if (lParam & GCDNF_UNICODE)
return (INT_PTR)cli.pfnGetContactDisplayName(hContact, lParam & ~GCDNF_UNICODE);
- if (lParam != GCDNF_NOMYHANDLE) {
+ if (lParam & GCDNF_NOCACHE)
+ lParam &= ~GCDNF_NOCACHE;
+ else if (lParam != GCDNF_NOMYHANDLE) {
cacheEntry = cli.pfnGetCacheEntry(hContact);
if (cacheEntry->tszName) {
- static char retVal[200];
strncpy(retVal, _T2A(cacheEntry->tszName), SIZEOF(retVal));
return (INT_PTR)retVal;
}
@@ -178,27 +179,28 @@ INT_PTR GetContactDisplayName(WPARAM wParam, LPARAM lParam)
ci.dwFlag = ((lParam == GCDNF_NOMYHANDLE) ? CNF_DISPLAYNC : CNF_DISPLAY) | CNF_TCHAR;
if ( !CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
if (ci.type == CNFT_ASCIIZ) {
+ strncpy(retVal, _T2A(ci.pszVal), SIZEOF(retVal));
if (cacheEntry == NULL) {
- buffer = mir_u2a(ci.pszVal);
mir_free(ci.pszVal);
- return (INT_PTR) buffer;
+ return (INT_PTR)mir_strdup(retVal);
}
cacheEntry->tszName = ci.pszVal;
- return (INT_PTR)cacheEntry->tszName;
+ return (INT_PTR)retVal;
}
if (ci.type == CNFT_DWORD) {
- buffer = (char*)mir_alloc(15);
- _ltoa(ci.dVal, buffer, 10);
- if (cacheEntry != NULL)
- cacheEntry->tszName = mir_a2u(buffer);
- return (INT_PTR) buffer;
+ _ltoa(ci.dVal, retVal, 10);
+ if (cacheEntry == NULL)
+ return (INT_PTR)mir_strdup(retVal);
+
+ cacheEntry->tszName = mir_a2u(retVal);
+ return (INT_PTR)retVal;
}
}
CallContactService(hContact, PSS_GETINFO, SGIF_MINIMAL, 0);
- buffer = Translate("(Unknown Contact)");
- return (INT_PTR) buffer;
+ char* result = Translate("(Unknown Contact)");
+ return (INT_PTR)((cacheEntry == NULL) ? mir_strdup(result) : result);
}
INT_PTR InvalidateDisplayName(WPARAM wParam, LPARAM)