diff options
author | George Hazan <george.hazan@gmail.com> | 2014-03-03 17:20:49 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-03-03 17:20:49 +0000 |
commit | f84d16a57eee1f8ecb40a72861496d903b18ffd4 (patch) | |
tree | ad7bab13c0d11b34a1d1a6d1f5ee3100ecd7b7c1 /plugins/Variables | |
parent | 4c7043a8e251ca5bdf32b2cba7ece8c392c5a1fe (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')
-rw-r--r-- | plugins/Variables/src/parse_metacontacts.cpp | 22 | ||||
-rw-r--r-- | plugins/Variables/src/variables.h | 1 |
2 files changed, 5 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)
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 <m_icolib.h>
#include <m_clui.h>
#include <m_clc.h>
+#include <m_string.h>
#include <m_variables.h>
#include <m_metacontacts.h>
|