From f84d16a57eee1f8ecb40a72861496d903b18ffd4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 3 Mar 2014 17:20:49 +0000 Subject: crazy memory allocation code removed git-svn-id: http://svn.miranda-ng.org/main/trunk@8383 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Variables/src/parse_metacontacts.cpp | 22 ++++------------------ plugins/Variables/src/variables.h | 1 + 2 files changed, 5 insertions(+), 18 deletions(-) (limited to 'plugins/Variables') 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) diff --git a/plugins/Variables/src/variables.h b/plugins/Variables/src/variables.h index f670eda2f8..c8184a00ec 100644 --- a/plugins/Variables/src/variables.h +++ b/plugins/Variables/src/variables.h @@ -43,6 +43,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3