summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_svc.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-09-20 13:26:16 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-09-20 13:26:16 +0000
commitbc0b5ed1e7f371820a08a9fdd275be68afe2fbe9 (patch)
tree505ba51290ff2137d3be8e8401cf76192b26a5f0 /protocols/JabberG/src/jabber_svc.cpp
parent61e43dca25a80a451cf2b7dbbc4931a8f2a96d80 (diff)
code cleaning & simplification
git-svn-id: http://svn.miranda-ng.org/main/trunk@6138 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_svc.cpp')
-rw-r--r--protocols/JabberG/src/jabber_svc.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp
index ae1bf712f7..5a507af5f0 100644
--- a/protocols/JabberG/src/jabber_svc.cpp
+++ b/protocols/JabberG/src/jabber_svc.cpp
@@ -795,7 +795,7 @@ LPTSTR CJabberSysInterface::GetBestResourceName(LPCTSTR jid)
LPTSTR CJabberSysInterface::GetResourceList(LPCTSTR jid)
{
- if ( !jid)
+ if (jid == NULL)
return NULL;
mir_cslock lck(m_psProto->m_csLists);
@@ -808,23 +808,14 @@ LPTSTR CJabberSysInterface::GetResourceList(LPCTSTR jid)
if (!item->arResources.getCount())
return NULL;
- int i;
- int iLen = 1; // 1 for extra zero terminator at the end of the string
- // calculate total necessary string length
- for (i=0; i<item->arResources.getCount(); i++)
- iLen += lstrlen(item->arResources[i]->resourceName) + 1;
-
- // allocate memory and fill it
- LPTSTR str = (LPTSTR)mir_alloc(iLen * sizeof(TCHAR));
- LPTSTR p = str;
- for (i=0; i<item->arResources.getCount(); i++) {
- JABBER_RESOURCE_STATUS *r = item->arResources[i];
- lstrcpy(p, r->resourceName);
- p += lstrlen(r->resourceName) + 1;
+ CMString res;
+ for (int i=0; i < item->arResources.getCount(); i++) {
+ res.Append(item->arResources[i]->resourceName);
+ res.AppendChar(0);
}
- *p = 0; // extra zero terminator
+ res.AppendChar(0);
- return str;
+ return mir_tstrndup(res, res.GetLength());
}
char *CJabberSysInterface::GetModuleName() const