From bc0b5ed1e7f371820a08a9fdd275be68afe2fbe9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 20 Sep 2013 13:26:16 +0000 Subject: code cleaning & simplification git-svn-id: http://svn.miranda-ng.org/main/trunk@6138 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/JabberG/src/jabber_svc.cpp | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'protocols/JabberG/src/jabber_svc.cpp') 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; iarResources.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; iarResources.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 -- cgit v1.2.3