summaryrefslogtreecommitdiff
path: root/plugins/Variables/src/parse_metacontacts.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-03-03 17:20:49 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-03-03 17:20:49 +0000
commitf84d16a57eee1f8ecb40a72861496d903b18ffd4 (patch)
treead7bab13c0d11b34a1d1a6d1f5ee3100ecd7b7c1 /plugins/Variables/src/parse_metacontacts.cpp
parent4c7043a8e251ca5bdf32b2cba7ece8c392c5a1fe (diff)
crazy memory allocation code removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@8383 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Variables/src/parse_metacontacts.cpp')
-rw-r--r--plugins/Variables/src/parse_metacontacts.cpp22
1 files changed, 4 insertions, 18 deletions
diff --git a/plugins/Variables/src/parse_metacontacts.cpp b/plugins/Variables/src/parse_metacontacts.cpp
index 564e04749f..e027eb0f2d 100644
--- a/plugins/Variables/src/parse_metacontacts.cpp
+++ b/plugins/Variables/src/parse_metacontacts.cpp
@@ -26,8 +26,7 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai)
MCONTACT hContact = NULL;
- CONTACTSINFO ci = { 0 };
- ci.cbSize = sizeof(ci);
+ CONTACTSINFO ci = { sizeof(ci) };
ci.tszContact = ai->targv[1];
ci.flags = 0xFFFFFFFF ^ (CI_TCHAR == 0 ? CI_UNICODE : 0);
int count = getContactFromString(&ci);
@@ -44,7 +43,7 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai)
if (hContact == NULL)
return NULL;
- TCHAR* szUniqueID = NULL;
+ ptrT szUniqueID;
char* szProto = GetContactProto(hContact);
if (szProto != NULL)
szUniqueID = getContactInfoT(CNF_UNIQUEID, hContact);
@@ -54,25 +53,12 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai)
TCHAR tszID[40];
mir_sntprintf(tszID, SIZEOF(tszID), _T("%p"), hContact);
szUniqueID = mir_tstrdup(tszID);
- if (szUniqueID == NULL)
- return NULL;
}
- size_t size = strlen(szProto) + _tcslen(szUniqueID) + 4;
- TCHAR *res = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
- if (res == NULL) {
- mir_free(szUniqueID);
+ if (szUniqueID == NULL)
return NULL;
- }
- TCHAR *tszProto = mir_a2t(szProto);
- if (tszProto != NULL && szUniqueID != NULL) {
- mir_sntprintf(res, size, _T("<%s:%s>"), tszProto, szUniqueID);
- mir_free(szUniqueID);
- mir_free(tszProto);
- }
-
- return res;
+ return mir_tstrdup(CMString(FORMAT, _T("<%S:%s>"), szProto, szUniqueID));
}
static TCHAR *parseGetDefault(ARGUMENTSINFO *ai)