diff options
Diffstat (limited to 'plugins/Variables/src')
| -rw-r--r-- | plugins/Variables/src/parse_metacontacts.cpp | 59 | 
1 files changed, 12 insertions, 47 deletions
diff --git a/plugins/Variables/src/parse_metacontacts.cpp b/plugins/Variables/src/parse_metacontacts.cpp index 281cac0556..131b24518f 100644 --- a/plugins/Variables/src/parse_metacontacts.cpp +++ b/plugins/Variables/src/parse_metacontacts.cpp @@ -55,10 +55,7 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai)  		szUniqueID = mir_tstrdup(tszID);
  	}
 -	if (szUniqueID == NULL)
 -		return NULL;
 -
 -	return mir_tstrdup(CMString(FORMAT, _T("<%S:%s>"), szProto, szUniqueID));
 +	return CMString(FORMAT, _T("<%S:%s>"), szProto, szUniqueID).Detouch();
  }
  static TCHAR *parseGetDefault(ARGUMENTSINFO *ai)
 @@ -86,34 +83,19 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai)  	if (hContact == NULL)
  		return NULL;
 -	TCHAR* szUniqueID = NULL;
 +	ptrT szUniqueID;
  	char* szProto = GetContactProto(hContact);
  	if (szProto != NULL)
  		szUniqueID = getContactInfoT(CNF_UNIQUEID, hContact);
  	if (szUniqueID == NULL) {
  		szProto = PROTOID_HANDLE;
 -		szUniqueID = (TCHAR *)mir_alloc(32);
 -		mir_sntprintf(szUniqueID, 32, _T("%p"), hContact);
 -		if (szProto == NULL || 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);
 -		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);
 +		TCHAR tszID[40];
 +		mir_sntprintf(tszID, SIZEOF(tszID), _T("%p"), hContact);
 +		szUniqueID = mir_tstrdup(tszID);
  	}
 -	return res;
 +	return CMString(FORMAT, _T("<%S:%s>"), szProto, szUniqueID).Detouch();
  }
  static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai)
 @@ -141,36 +123,19 @@ static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai)  	if (hContact == NULL)
  		return NULL;
 -	TCHAR* szUniqueID = NULL;
 -	char* szProto = GetContactProto(hContact);
 +	ptrT szUniqueID;
 +	char *szProto = GetContactProto(hContact);
  	if (szProto != NULL)
  		szUniqueID = getContactInfoT(CNF_UNIQUEID, hContact);
  	if (szUniqueID == NULL) {
  		szProto = PROTOID_HANDLE;
 -		if (szProto == NULL)
 -			return NULL;
 -		szUniqueID = (TCHAR *)mir_alloc(32);
 -		if (szUniqueID == NULL)
 -			return NULL;
 -		mir_sntprintf(szUniqueID, 32, _T("%p"), hContact);
 -	}
 -
 -	size_t size = strlen(szProto) + _tcslen(szUniqueID) + 4;
 -	TCHAR *res = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
 -	if (res == NULL) {
 -		mir_free(szUniqueID);
 -		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);
 +		TCHAR tszID[40];
 +		mir_sntprintf(tszID, SIZEOF(tszID), _T("%p"), hContact);
 +		szUniqueID = mir_tstrdup(tszID);
  	}
 -	return res;
 +	return CMString(FORMAT, _T("<%S:%s>"), szProto, szUniqueID).Detouch();
  }
  void registerMetaContactsTokens()
  | 
