summaryrefslogtreecommitdiff
path: root/plugins/Variables
diff options
context:
space:
mode:
authorVlad Mironov <mironych@googlemail.com>2012-06-30 15:24:11 +0000
committerVlad Mironov <mironych@googlemail.com>2012-06-30 15:24:11 +0000
commit008fe34954b0bda8fd3487a9658c14581ecd813a (patch)
treef546ed4196e4a09311bf19878ff6e7d1af772d4c /plugins/Variables
parent14f435dc730cf2b242cae1cc2a2f4d4c2a65162e (diff)
Наводим порядок.
git-svn-id: http://svn.miranda-ng.org/main/trunk@695 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Variables')
-rw-r--r--plugins/Variables/contact.cpp103
-rw-r--r--plugins/Variables/help.cpp10
-rw-r--r--plugins/Variables/options.cpp1
-rw-r--r--plugins/Variables/parse_logic.cpp64
-rw-r--r--plugins/Variables/parse_metacontacts.cpp27
-rw-r--r--plugins/Variables/parse_miranda.cpp8
-rw-r--r--plugins/Variables/parse_system.cpp66
-rw-r--r--plugins/Variables/tokenregister.cpp11
-rw-r--r--plugins/Variables/variables.cpp51
9 files changed, 181 insertions, 160 deletions
diff --git a/plugins/Variables/contact.cpp b/plugins/Variables/contact.cpp
index b6d48ee1e3..89ab60d72f 100644
--- a/plugins/Variables/contact.cpp
+++ b/plugins/Variables/contact.cpp
@@ -131,8 +131,8 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact)
return NULL;
if ( type & CNF_UNICODE )
- return (TCHAR *)a2u(szProto);
- return (TCHAR *)_strdup(szProto);
+ return (TCHAR *)mir_a2u(szProto);
+ return (TCHAR *)mir_strdup(szProto);
case CCNF_ACCOUNT:
if ( g_mirandaVersion < PLUGIN_MAKE_VERSION( 0,8,0,0 ))
@@ -142,7 +142,7 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact)
if (szProto) {
PROTOACCOUNT* pa = ProtoGetAccount( szProto );
if ( pa )
- return _tcsdup( pa->tszAccountName );
+ return mir_tstrdup( pa->tszAccountName );
}
return NULL;
@@ -155,9 +155,9 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact)
return NULL;
if ( type & CNF_UNICODE )
- return (TCHAR *)a2u(protoname);
+ return (TCHAR *)mir_a2u(protoname);
- return (TCHAR *)_strdup(protoname);
+ return (TCHAR *)mir_strdup(protoname);
case CCNF_STATUS:
szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
@@ -173,14 +173,14 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact)
if (szStatus == NULL)
return NULL;
- return _tcsdup(szStatus);
+ return mir_tstrdup(szStatus);
}
else {
char *aszStatus = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)status, 0);
if (aszStatus == NULL)
return NULL;
- return (TCHAR *)_strdup(aszStatus);
+ return (TCHAR *)mir_strdup(aszStatus);
}
case CCNF_INTERNALIP:
@@ -200,25 +200,25 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact)
return NULL;
if ( type & CNF_UNICODE )
- return (TCHAR *)a2u(dotted);
- return (TCHAR *)_strdup(dotted);
+ return (TCHAR *)mir_a2u(dotted);
+ return (TCHAR *)mir_strdup(dotted);
}
case CCNF_GROUP:
if (!DBGetContactSetting(hContact, "CList", "Group", &dbv)) {
if ( type & CNF_UNICODE )
- res = (TCHAR *)a2u(dbv.pszVal);
+ res = (TCHAR *)mir_a2u(dbv.pszVal);
else
- res = (TCHAR *)_strdup(dbv.pszVal);
+ res = (TCHAR *)mir_strdup(dbv.pszVal);
DBFreeVariant(&dbv);
return res;
}
if (!DBGetContactSettingW(hContact, "CList", "Group", &dbv)) {
if ( type & CNF_UNICODE )
- res = (TCHAR *)_wcsdup(dbv.pwszVal);
+ res = (TCHAR *)mir_wstrdup(dbv.pwszVal);
else
- res = (TCHAR *)u2a(dbv.pwszVal);
+ res = (TCHAR *)mir_u2a(dbv.pwszVal);
DBFreeVariant(&dbv);
return res;
@@ -232,7 +232,7 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact)
if ( DBGetContactSettingByte(hContact, szProto, "ChatRoom", 0) == 1) {
DBVARIANT dbv;
if ( !DBGetContactSettingTString(hContact, szProto, "ChatRoomID", &dbv )) {
- res = _tcsdup( dbv.ptszVal );
+ res = mir_tstrdup( dbv.ptszVal );
DBFreeVariant( &dbv );
return res;
} } }
@@ -258,12 +258,12 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact)
if (type & CNF_UNICODE) {
TCHAR *ptszVal;
- ptszVal = (TCHAR *)a2u((char *)ci.pszVal);
+ ptszVal = (TCHAR *)mir_a2u((char *)ci.pszVal);
mir_free(ci.pszVal);
return ptszVal;
}
else {
- res = (TCHAR *)_strdup((char *)ci.pszVal);
+ res = (TCHAR *)mir_strdup((char *)ci.pszVal);
mir_free(ci.pszVal);
return res;
} } }
@@ -277,7 +277,7 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact)
szVal[0] = (char)ci.bVal;
if ( type & CNF_UNICODE )
return (TCHAR *)a2u(szVal);
- return (TCHAR *)_strdup(szVal);
+ return (TCHAR *)mir_strdup(szVal);
case CNFT_WORD:
return itot(ci.wVal);
@@ -288,9 +288,9 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact)
case CNFT_ASCIIZ:
if (ci.pszVal != NULL) {
if (type&CNF_UNICODE)
- res = _tcsdup(ci.pszVal);
+ res = mir_tstrdup(ci.pszVal);
else
- res = (TCHAR *)_strdup((char *)ci.pszVal);
+ res = (TCHAR *)mir_strdup((char *)ci.pszVal);
mir_free(ci.pszVal);
}
@@ -302,10 +302,9 @@ static TCHAR* getContactInfo(BYTE type, HANDLE hContact)
TCHAR *getContactInfoT(BYTE type, HANDLE hContact, int tchar)
{
- if (tchar) {
-
- return getContactInfo((BYTE)(type|CNF_UNICODE), hContact);
-
+ if (tchar)
+ {
+ return getContactInfo((BYTE)(type | CNF_UNICODE), hContact);
}
return getContactInfo(type, hContact);
@@ -373,30 +372,38 @@ int getContactFromString( CONTACTSINFO* ci )
continue;
}
// <proto:id> (exact)
- if (ci->flags&CI_PROTOID) {
+ if (ci->flags&CI_PROTOID)
+ {
cInfo = getContactInfoT(CNF_UNIQUEID, hContact, ci->flags&CI_TCHAR);
- if (cInfo == NULL) {
+ if (cInfo == NULL)
+ {
// <HANDLE:hContact>
- cInfo = itot((int)hContact);
- szFind = ( TCHAR* )malloc((_tcslen(cInfo) + _tcslen(_T(PROTOID_HANDLE)) + 4)*sizeof(TCHAR));
- if (szFind != NULL) {
+ cInfo = (TCHAR*)mir_alloc(32);
+ //cInfo = itot((INT_PTR)hContact);
+ _stprintf(cInfo, _T("%p"), hContact);
+ szFind = ( TCHAR* )mir_alloc((_tcslen(cInfo) + _tcslen(_T(PROTOID_HANDLE)) + 4)*sizeof(TCHAR));
+ if (szFind != NULL)
+ {
wsprintf(szFind, _T("<%s:%s>"), _T(PROTOID_HANDLE), cInfo);
- if (!_tcsncmp(tszContact, szFind, _tcslen(tszContact))) {
+ if (!_tcsncmp(tszContact, szFind, _tcslen(tszContact)))
+ {
bMatch = TRUE;
}
- free(cInfo);
- free(szFind);
+ mir_free(cInfo);
+ mir_free(szFind);
}
}
- else {
+ else
+ {
szFind = ( TCHAR* )malloc((_tcslen(cInfo) + strlen(szProto) + 4)*sizeof(TCHAR));
- if (szFind != NULL) {
-
+ if (szFind != NULL)
+ {
tszProto = a2u(szProto);
- if ( (tszProto != NULL) && (szFind != NULL)) {
+ if ( (tszProto != NULL) && (szFind != NULL))
+ {
wsprintf(szFind, _T("<%s:%s>"), tszProto, cInfo);
- free(cInfo);
+ mir_free(cInfo);
free(tszProto);
if (!_tcsncmp(tszContact, szFind, _tcslen(tszContact)))
bMatch = TRUE;
@@ -413,7 +420,7 @@ int getContactFromString( CONTACTSINFO* ci )
if (!_tcscmp(tszContact, szFind))
bMatch = TRUE;
- free(szFind);
+ mir_free(szFind);
}
}
// nick (not exact)
@@ -423,7 +430,7 @@ int getContactFromString( CONTACTSINFO* ci )
if (!_tcscmp(tszContact, szFind))
bMatch = TRUE;
- free(szFind);
+ mir_free(szFind);
}
}
// list name (not exact)
@@ -433,7 +440,7 @@ int getContactFromString( CONTACTSINFO* ci )
if (!_tcscmp(tszContact, szFind))
bMatch = TRUE;
- free(szFind);
+ mir_free(szFind);
}
}
// firstname (exact)
@@ -443,7 +450,7 @@ int getContactFromString( CONTACTSINFO* ci )
if (!_tcscmp(tszContact, szFind)) {
bMatch = TRUE;
}
- free(szFind);
+ mir_free(szFind);
}
}
// lastname (exact)
@@ -453,7 +460,7 @@ int getContactFromString( CONTACTSINFO* ci )
if (!_tcscmp(tszContact, szFind)) {
bMatch = TRUE;
}
- free(szFind);
+ mir_free(szFind);
}
}
// email (exact)
@@ -463,7 +470,7 @@ int getContactFromString( CONTACTSINFO* ci )
if (!_tcscmp(tszContact, szFind)) {
bMatch = TRUE;
}
- free(szFind);
+ mir_free(szFind);
}
}
// CNF_ (exact)
@@ -473,7 +480,7 @@ int getContactFromString( CONTACTSINFO* ci )
if (!_tcscmp(tszContact, szFind)) {
bMatch = TRUE;
}
- free(szFind);
+ mir_free(szFind);
}
}
if (bMatch) {
@@ -533,7 +540,7 @@ static int contactSettingChanged(WPARAM wParam, LPARAM lParam)
((!strcmp(dbw->szSetting, "e-mail")) && (cce[i].flags&CI_EMAIL)) ||
((!strcmp(dbw->szSetting, "MyHandle")) && (cce[i].flags&CI_LISTNAME)) ||
(cce[i].flags & CI_CNFINFO) != 0 || // lazy; always invalidate CNF info cache entries
- (( ((int)uid != CALLSERVICE_NOTFOUND) && (uid != NULL)) && (!strcmp(dbw->szSetting, uid)) && (cce[i].flags & CI_UNIQUEID)))
+ (( ((INT_PTR)uid != CALLSERVICE_NOTFOUND) && (uid != NULL)) && (!strcmp(dbw->szSetting, uid)) && (cce[i].flags & CI_UNIQUEID)))
{
/* remove from cache */
free(cce[i].tszContact);
@@ -589,17 +596,19 @@ TCHAR *encodeContactToString(HANDLE hContact)
if ( szProto == NULL || tszUniqueId == NULL )
return NULL;
- tszResult = ( TCHAR* )calloc((_tcslen(tszUniqueId) + strlen(szProto) + 4), sizeof(TCHAR));
+ tszResult = ( TCHAR* )mir_alloc((_tcslen(tszUniqueId) + strlen(szProto) + 4) * sizeof(TCHAR));
if (tszResult == NULL)
return NULL;
-
- tszProto = a2u(szProto);
+ tszProto = mir_a2u(szProto);
if (tszProto == NULL)
return NULL;
wsprintf(tszResult, _T("<%s:%s>"), tszProto, tszUniqueId);
+
+ mir_free(tszProto);
+
return tszResult;
}
diff --git a/plugins/Variables/help.cpp b/plugins/Variables/help.cpp
index 5231294de3..569fcaf7b2 100644
--- a/plugins/Variables/help.cpp
+++ b/plugins/Variables/help.cpp
@@ -677,7 +677,7 @@ static INT_PTR CALLBACK inputDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM
ZeroMemory(dat, sizeof(INPUTDLGDATA));
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
// splitter things
- dat->splitterPos = (int)db_getd(SETTING_SPLITTERPOS, -1);
+ dat->splitterPos = (INT_PTR)db_getd(SETTING_SPLITTERPOS, -1);
{
RECT rc;
POINT pt;
@@ -1319,7 +1319,7 @@ INT_PTR getSkinItemService(WPARAM wParam, LPARAM lParam)
{
int item = lParam;
if (item == 0)
- return (int)NULL;
+ return (INT_PTR)NULL;
switch (item) {
case VSI_HELPICON:
@@ -1331,13 +1331,13 @@ INT_PTR getSkinItemService(WPARAM wParam, LPARAM lParam)
hHelpIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_V), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
}
- return (int)hHelpIcon;
+ return (INT_PTR)hHelpIcon;
case VSI_HELPTIPTEXT:
- return (int)Translate("Open String Formatting Help");
+ return (INT_PTR)Translate("Open String Formatting Help");
}
- return (int)NULL;
+ return (INT_PTR)NULL;
}
int iconsChanged(WPARAM wParam, LPARAM lParam)
diff --git a/plugins/Variables/options.cpp b/plugins/Variables/options.cpp
index 175baff0f0..6140bc79dd 100644
--- a/plugins/Variables/options.cpp
+++ b/plugins/Variables/options.cpp
@@ -20,6 +20,7 @@
extern HINSTANCE hInst;
extern struct ParseOptions gParseOpts;
+extern int hLangpack;
static INT_PTR CALLBACK SetOptsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
diff --git a/plugins/Variables/parse_logic.cpp b/plugins/Variables/parse_logic.cpp
index 23f8badca8..8a7086ce37 100644
--- a/plugins/Variables/parse_logic.cpp
+++ b/plugins/Variables/parse_logic.cpp
@@ -33,7 +33,7 @@ static TCHAR *parseAnd(ARGUMENTSINFO *ai) {
for (i=1;i<ai->argc;i++) {
fi.tszFormat = ai->targv[i];
szCondition = formatString(&fi);
- free(szCondition);
+ mir_free(szCondition);
//if (fi.pCount <= 0) {
if (fi.eCount > 0) {
ai->flags |= AIF_FALSE;
@@ -67,7 +67,7 @@ static TCHAR *parseIf(ARGUMENTSINFO *ai) {
fi.eCount = fi.pCount = 0;
fi.tszFormat = ai->targv[1];
szCondition = formatString(&fi);
- free(szCondition);
+ mir_free(szCondition);
//if (fi.pCount > 0) {
if (fi.eCount == 0) {
return _tcsdup(ai->targv[2]);
@@ -97,7 +97,7 @@ static TCHAR *parseIf2(ARGUMENTSINFO *ai) {
else {
if (szCondition != NULL) {
// ai->flags |= AIF_DONTPARSE;
- free(szCondition);
+ mir_free(szCondition);
}
return _tcsdup(ai->targv[2]);
}
@@ -121,7 +121,7 @@ static TCHAR *parseIf3(ARGUMENTSINFO *ai) {
return szCondition;
}
if (szCondition != NULL) {
- free(szCondition);
+ mir_free(szCondition);
}
}
@@ -143,20 +143,20 @@ static TCHAR *parseIfequal(ARGUMENTSINFO *ai)
tszSecond = formatString(&fi);
if ( (tszFirst == NULL) || (tszSecond == NULL)) {
if (tszFirst != NULL)
- free(tszFirst);
+ mir_free(tszFirst);
if (tszSecond != NULL)
- free(tszSecond);
+ mir_free(tszSecond);
return NULL;
}
if ( (ttoi(tszFirst)) == (ttoi(tszSecond))) {
- free(tszFirst);
- free(tszSecond);
+ mir_free(tszFirst);
+ mir_free(tszSecond);
return _tcsdup(ai->targv[3]);
}
- free(tszFirst);
- free(tszSecond);
+ mir_free(tszFirst);
+ mir_free(tszSecond);
return _tcsdup(ai->targv[4]);
}
@@ -178,20 +178,20 @@ static TCHAR *parseIfgreater(ARGUMENTSINFO *ai) {
tszSecond = formatString(&fi);
if ( (tszFirst == NULL) || (tszSecond == NULL)) {
if (tszFirst != NULL) {
- free(tszFirst);
+ mir_free(tszFirst);
}
if (tszSecond != NULL) {
- free(tszSecond);
+ mir_free(tszSecond);
}
return NULL;
}
if ( (ttoi(tszFirst)) > (ttoi(tszSecond))) {
- free(tszFirst);
- free(tszSecond);
+ mir_free(tszFirst);
+ mir_free(tszSecond);
return _tcsdup(ai->targv[3]);
}
- free(tszFirst);
- free(tszSecond);
+ mir_free(tszFirst);
+ mir_free(tszSecond);
return _tcsdup(ai->targv[4]);
}
@@ -212,20 +212,20 @@ static TCHAR *parseIflonger(ARGUMENTSINFO *ai) {
tszSecond = formatString(&fi);
if ( (tszFirst == NULL) || (tszSecond == NULL)) {
if (tszFirst != NULL) {
- free(tszFirst);
+ mir_free(tszFirst);
}
if (tszSecond != NULL) {
- free(tszSecond);
+ mir_free(tszSecond);
}
return NULL;
}
if ( _tcslen(tszFirst) > _tcslen(tszSecond)) {
- free(tszFirst);
- free(tszSecond);
+ mir_free(tszFirst);
+ mir_free(tszSecond);
return _tcsdup(ai->targv[3]);
}
- free(tszFirst);
- free(tszSecond);
+ mir_free(tszFirst);
+ mir_free(tszSecond);
return _tcsdup(ai->targv[4]);
}
@@ -249,27 +249,27 @@ static TCHAR *parseFor(ARGUMENTSINFO *ai) {
CopyMemory(&fi, ai->fi, sizeof(fi));
fi.eCount = fi.pCount = 0;
fi.tszFormat = ai->targv[1];
- free(formatString(&fi));
+ mir_free(formatString(&fi));
fi.tszFormat = ai->targv[2];
- free(formatString(&fi));
+ mir_free(formatString(&fi));
while (fi.eCount == 0) {
fi.tszFormat = ai->targv[4];
parsed = formatString(&fi);
if (parsed != NULL) {
if (res == NULL) {
- res = ( TCHAR* )calloc( _tcslen(parsed)+1, sizeof(TCHAR));
+ res = ( TCHAR* )mir_alloc( _tcslen(parsed)+1 * sizeof(TCHAR));
if (res == NULL)
return NULL;
}
- else res = ( TCHAR* )realloc(res, (_tcslen(res)+_tcslen(parsed)+1)*sizeof(TCHAR));
+ else res = ( TCHAR* )mir_realloc(res, (_tcslen(res)+_tcslen(parsed)+1)*sizeof(TCHAR));
_tcscat(res, parsed);
}
fi.tszFormat = ai->targv[3];
- free(formatString(&fi));
+ mir_free(formatString(&fi));
fi.eCount = 0;
fi.tszFormat = ai->targv[2];
- free(formatString(&fi));
+ mir_free(formatString(&fi));
}
return res;
@@ -320,7 +320,7 @@ static TCHAR *parseNot(ARGUMENTSINFO *ai) {
memcpy(&fi, ai->fi, sizeof(fi));
fi.tszFormat = ai->targv[1];
szCondition = formatString(&fi);
- free(szCondition);
+ mir_free(szCondition);
//if (fi.pCount > 0) {
if (fi.eCount == 0) {
ai->flags |= AIF_FALSE;
@@ -345,7 +345,7 @@ static TCHAR *parseOr(ARGUMENTSINFO *ai) {
fi.tszFormat = ai->targv[i];
fi.eCount = 0;
szCondition = formatString(&fi);
- free(szCondition);
+ mir_free(szCondition);
//if (fi.pCount > 0) {
if (fi.eCount == 0) {
ai->flags &= ~AIF_FALSE;
@@ -378,12 +378,12 @@ static TCHAR *parseXor(ARGUMENTSINFO *ai) {
ai->flags = AIF_FALSE;
fi.tszFormat = ai->targv[0];
szCondition = formatString(&fi);
- free(szCondition);
+ mir_free(szCondition);
//val1 = fi.pCount > 0;
val1 = fi.eCount == 0;
fi.tszFormat = ai->targv[1];
szCondition = formatString(&fi);
- free(szCondition);
+ mir_free(szCondition);
//val2 = fi.pCount > 0;
val2 = fi.eCount == 0;
ai->flags |= ((val1&AIF_FALSE)==!(val2&AIF_FALSE))?0:AIF_FALSE;
diff --git a/plugins/Variables/parse_metacontacts.cpp b/plugins/Variables/parse_metacontacts.cpp
index 71a9da283b..c639668e05 100644
--- a/plugins/Variables/parse_metacontacts.cpp
+++ b/plugins/Variables/parse_metacontacts.cpp
@@ -55,16 +55,19 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai)
if ( szProto != NULL )
szUniqueID = getContactInfoT(CNF_UNIQUEID, hContact, 1);
- if ( szUniqueID == NULL ) {
+ if ( szUniqueID == NULL )
+ {
szProto = PROTOID_HANDLE;
- szUniqueID = itot((int)hContact);
+ //szUniqueID = itot((INT_PTR)hContact);
+ szUniqueID = (TCHAR*)mir_alloc(32);
+ _stprintf(szUniqueID, _T("%p"), hContact);
if ( szProto == NULL || szUniqueID == NULL )
return NULL;
}
res = ( TCHAR* )malloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
if (res == NULL) {
- free(szUniqueID);
+ mir_free(szUniqueID);
return NULL;
}
@@ -75,7 +78,7 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai)
if ( tszProto != NULL && szUniqueID != NULL ) {
wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID);
- free(szUniqueID);
+ mir_free(szUniqueID);
free(tszProto);
}
@@ -116,14 +119,16 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai)
if (szUniqueID == NULL) {
szProto = PROTOID_HANDLE;
- szUniqueID = itot((int)hContact);
+ //szUniqueID = itot((INT_PTR)hContact);
+ szUniqueID = (TCHAR*)mir_alloc(32);
+ _stprintf(szUniqueID, _T("%p"), hContact);
if ( szProto == NULL || szUniqueID == NULL )
return NULL;
}
res = ( TCHAR* )malloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
if (res == NULL) {
- free(szUniqueID);
+ mir_free(szUniqueID);
return NULL;
}
@@ -134,7 +139,7 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai)
if ( tszProto != NULL && szUniqueID != NULL ) {
wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID);
- free(szUniqueID);
+ mir_free(szUniqueID);
free(tszProto);
}
@@ -175,14 +180,16 @@ static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai)
if (szUniqueID == NULL) {
szProto = PROTOID_HANDLE;
- szUniqueID = itot((int)hContact);
+ //szUniqueID = itot((INT_PTR)hContact);
+ szUniqueID = (TCHAR*)mir_alloc(32);
+ _stprintf(szUniqueID, _T("%p"), hContact);
if ( szProto == NULL || szUniqueID == NULL )
return NULL;
}
res = ( TCHAR* )malloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
if (res == NULL) {
- free(szUniqueID);
+ mir_free(szUniqueID);
return NULL;
}
@@ -193,7 +200,7 @@ static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai)
if ( tszProto != NULL && szUniqueID != NULL ) {
wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID);
- free(szUniqueID);
+ mir_free(szUniqueID);
free(tszProto);
}
diff --git a/plugins/Variables/parse_miranda.cpp b/plugins/Variables/parse_miranda.cpp
index 7a4e26567e..5480a1805b 100644
--- a/plugins/Variables/parse_miranda.cpp
+++ b/plugins/Variables/parse_miranda.cpp
@@ -561,14 +561,16 @@ static TCHAR *parseSpecialContact(ARGUMENTSINFO *ai)
if (szUniqueID == NULL) {
szProto = PROTOID_HANDLE;
- szUniqueID = itot((int)ai->fi->hContact);
+ //szUniqueID = itot((INT_PTR)ai->fi->hContact);
+ szUniqueID = (TCHAR*)mir_alloc(32);
+ _stprintf(szUniqueID, _T("%p"), ai->fi->hContact);
if ( szProto == NULL || szUniqueID == NULL )
return NULL;
}
res = ( TCHAR* )malloc((strlen(szProto) + _tcslen(szUniqueID) + 4)*sizeof(TCHAR));
if (res == NULL) {
- free(szUniqueID);
+ mir_free(szUniqueID);
return NULL;
}
@@ -578,7 +580,7 @@ static TCHAR *parseSpecialContact(ARGUMENTSINFO *ai)
if ( tszProto != NULL && szUniqueID != NULL ) {
wsprintf(res, _T("<%s:%s>"), tszProto, szUniqueID);
- free(szUniqueID);
+ mir_free(szUniqueID);
free(tszProto);
}
diff --git a/plugins/Variables/parse_system.cpp b/plugins/Variables/parse_system.cpp
index 9ede81bf4a..960618ac01 100644
--- a/plugins/Variables/parse_system.cpp
+++ b/plugins/Variables/parse_system.cpp
@@ -43,12 +43,12 @@ static TCHAR *parseComputerName(ARGUMENTSINFO *ai) {
ai->flags |= AIF_DONTPARSE;
len = MAX_COMPUTERNAME_LENGTH;
- res = ( TCHAR* )calloc((len + 1), sizeof(TCHAR));
+ res = ( TCHAR* )mir_alloc((len + 1) * sizeof(TCHAR));
if (res == NULL)
return NULL;
if (!GetComputerName(res, &len)) {
- free(res);
+ mir_free(res);
return NULL;
}
return res;
@@ -127,7 +127,7 @@ static TCHAR *parseCpuLoad(ARGUMENTSINFO *ai) {
PdhCloseQuery(hQuery);
free(szCounter);
- return _tcsdup(szVal);
+ return mir_tstrdup(szVal);
}
#endif
@@ -142,12 +142,12 @@ static TCHAR *parseCurrentDate(ARGUMENTSINFO *ai) {
szFormat = ai->targv[1];
len = GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, szFormat, NULL, 0);
- res = ( TCHAR* )malloc((len+1)*sizeof(TCHAR));
+ res = ( TCHAR* )mir_alloc((len+1)*sizeof(TCHAR));
if (res == NULL) {
return NULL;
}
if (GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, szFormat, res, len) == 0) {
- free(res);
+ mir_free(res);
return NULL;
}
@@ -165,12 +165,12 @@ static TCHAR *parseCurrentTime(ARGUMENTSINFO *ai) {
szFormat = ai->targv[1];
len = GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, szFormat, NULL, 0);
- res = ( TCHAR* )malloc((len+1)*sizeof(TCHAR));
+ res = ( TCHAR* )mir_alloc((len+1)*sizeof(TCHAR));
if (res == NULL)
return NULL;
if (GetTimeFormat(LOCALE_USER_DEFAULT, 0, NULL, szFormat, res, len) == 0) {
- free(res);
+ mir_free(res);
return NULL;
}
@@ -210,7 +210,7 @@ static TCHAR *parseDirectory(ARGUMENTSINFO *ai) {
if (*scur == _T('\\'))
scur++;
- res = ( TCHAR* )calloc((ecur-scur)+2, sizeof(TCHAR));
+ res = ( TCHAR* )mir_alloc((ecur-scur)+2 * sizeof(TCHAR));
if (res == NULL)
return NULL;
@@ -248,7 +248,7 @@ static TCHAR *parseDirectory2(ARGUMENTSINFO *ai) {
depth -= 1;
ecur--;
}
- res = ( TCHAR* )calloc((ecur-ai->targv[1])+2, sizeof(TCHAR));
+ res = ( TCHAR* )mir_alloc((ecur-ai->targv[1])+2 * sizeof(TCHAR));
if (res == NULL)
return NULL;
@@ -325,7 +325,7 @@ static TCHAR *parseDiffTime(ARGUMENTSINFO *ai) {
diff = difftime(mktime(&t1), mktime(&t0));
mir_sntprintf(szTime, SIZEOF(szTime), _T("%.0f"), diff);
- return _tcsdup(szTime);
+ return mir_tstrdup(szTime);
}
static TCHAR *parseDirExists(ARGUMENTSINFO *ai) {
@@ -343,7 +343,7 @@ static TCHAR *parseDirExists(ARGUMENTSINFO *ai) {
CloseHandle(hFile);
}
- return _tcsdup(_T(""));
+ return mir_tstrdup(_T(""));
}
static TCHAR *parseEnvironmentVariable(ARGUMENTSINFO *ai) {
@@ -358,13 +358,13 @@ static TCHAR *parseEnvironmentVariable(ARGUMENTSINFO *ai) {
if (len <= 0) {
return NULL;
}
- res = ( TCHAR* )malloc((len+1)*sizeof(TCHAR));
+ res = ( TCHAR* )mir_alloc((len+1)*sizeof(TCHAR));
if (res == NULL) {
return NULL;
}
ZeroMemory(res, (len+1)*sizeof(TCHAR));
if (ExpandEnvironmentStrings(ai->targv[1], res, len) == 0) {
- free(res);
+ mir_free(res);
return NULL;
}
return res;
@@ -383,7 +383,7 @@ static TCHAR *parseFileExists(ARGUMENTSINFO *ai) {
else
CloseHandle(hFile);
- return _tcsdup(_T(""));
+ return mir_tstrdup(_T(""));
}
static TCHAR *parseFindWindow(ARGUMENTSINFO *ai) {
@@ -401,7 +401,7 @@ static TCHAR *parseFindWindow(ARGUMENTSINFO *ai) {
len = SendMessage(hWin, WM_GETTEXTLENGTH, 0, 0);
if (len >= 0) {
- res = ( TCHAR* )malloc((len+1)*sizeof(TCHAR));
+ res = ( TCHAR* )mir_alloc((len+1)*sizeof(TCHAR));
ZeroMemory(res, (len+1)*sizeof(TCHAR));
GetWindowText(hWin, res, len+1);
return res;
@@ -464,10 +464,10 @@ static TCHAR *parseListDir(ARGUMENTSINFO *ai) {
if ( ((ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && (bDirs)) || ((!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) && (bFiles))) {
if (tszRes != NULL) {
_tcscat(tszRes, tszSeperator);
- tszRes = ( TCHAR* )realloc(tszRes, (_tcslen(tszRes) + _tcslen(ffd.cFileName) + _tcslen(tszSeperator) + 1)*sizeof(TCHAR));
+ tszRes = ( TCHAR* )mir_realloc(tszRes, (_tcslen(tszRes) + _tcslen(ffd.cFileName) + _tcslen(tszSeperator) + 1)*sizeof(TCHAR));
}
else {
- tszRes = ( TCHAR* )malloc((_tcslen(ffd.cFileName) + _tcslen(tszSeperator) + 1)*sizeof(TCHAR));
+ tszRes = ( TCHAR* )mir_alloc((_tcslen(ffd.cFileName) + _tcslen(tszSeperator) + 1)*sizeof(TCHAR));
_tcscpy(tszRes, _T(""));
}
_tcscat(tszRes, ffd.cFileName);
@@ -499,14 +499,14 @@ static TCHAR *parseProcessRunning(ARGUMENTSINFO *ai) {
return NULL;
}
- szProc = ref = u2a(ai->targv[1]);
+ szProc = ref = mir_u2a(ai->targv[1]);
EnumProcs((PROCENUMPROC) MyProcessEnumerator, (LPARAM)&szProc);
if (szProc != NULL) {
ai->flags |= AIF_FALSE;
}
- free(ref);
- return _tcsdup(_T(""));
+ mir_free(ref);
+ return mir_tstrdup(_T(""));
}
#endif
@@ -552,7 +552,7 @@ static TCHAR *parseRegistryValue(ARGUMENTSINFO *ai) {
}
free(key);
len = MAX_REGVALUE_LENGTH+1;
- res = ( TCHAR* )malloc(len*sizeof(TCHAR));
+ res = ( TCHAR* )mir_alloc(len*sizeof(TCHAR));
if (res == NULL) {
return NULL;
}
@@ -560,7 +560,7 @@ static TCHAR *parseRegistryValue(ARGUMENTSINFO *ai) {
err = RegQueryValueEx(hKey, ai->targv[2], NULL, &type, (BYTE*)res, &len);
if ( (err != ERROR_SUCCESS) || (type != REG_SZ)) {
RegCloseKey(hKey);
- free(res);
+ mir_free(res);
return NULL;
}
RegCloseKey(hKey);
@@ -612,12 +612,12 @@ static TCHAR *parseTimestamp2Date(ARGUMENTSINFO *ai) {
return NULL;
}
len = GetDateFormat(LOCALE_USER_DEFAULT, 0, &sysTime, szFormat, NULL, 0);
- res = ( TCHAR* )calloc((len+1), sizeof(TCHAR));
+ res = ( TCHAR* )mir_alloc((len+1) * sizeof(TCHAR));
if (res == NULL) {
return NULL;
}
if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &sysTime, szFormat, res, len) == 0) {
- free(res);
+ mir_free(res);
return NULL;
}
@@ -648,12 +648,12 @@ static TCHAR *parseTimestamp2Time(ARGUMENTSINFO *ai) {
return NULL;
}
len = GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysTime, szFormat, NULL, 0);
- res = ( TCHAR* )malloc((len+1)*sizeof(TCHAR));
+ res = ( TCHAR* )mir_alloc((len+1)*sizeof(TCHAR));
if (res == NULL) {
return NULL;
}
if (GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysTime, szFormat, res, len) == 0) {
- free(res);
+ mir_free(res);
return NULL;
}
@@ -699,13 +699,13 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) {
if (*ai->targv[2] == _T('0')) {
// complete file
bufSz = fileSz + csz;
- pBuf = ( PBYTE )calloc(1, bufSz);
+ pBuf = ( PBYTE )mir_alloc(1 * bufSz);
if (pBuf == NULL)
return NULL;
if (ReadFile(hFile, pBuf, bufSz-csz, &readSz, NULL) == 0) {
CloseHandle(hFile);
- free(pBuf);
+ mir_free(pBuf);
return NULL;
}
CloseHandle(hFile);
@@ -714,7 +714,7 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) {
res = (TCHAR *)pBuf;
}
else {
- res = a2u((char *)pBuf);
+ res = mir_a2u((char *)pBuf);
free(pBuf);
}
@@ -911,7 +911,7 @@ static TCHAR *parseUpTime(ARGUMENTSINFO *ai) {
PdhRemoveCounter(hCounter);
pdhStatus = PdhCloseQuery(hQuery);
- return _tcsdup(szVal);
+ return mir_tstrdup(szVal);
}
#endif
@@ -925,13 +925,13 @@ static TCHAR *parseUserName(ARGUMENTSINFO *ai) {
}
ai->flags |= AIF_DONTPARSE;
len = UNLEN;
- res = ( TCHAR* )malloc(len + 1);
+ res = ( TCHAR* )mir_alloc(len + 1);
if (res == NULL) {
return NULL;
}
ZeroMemory(res, len + 1);
if (!GetUserName(res, &len)) {
- free(res);
+ mir_free(res);
return NULL;
}
return res;
@@ -960,7 +960,7 @@ static TCHAR *parseClipboard(ARGUMENTSINFO *ai) {
if (hData != NULL) {
tszText = (TCHAR*)GlobalLock(hData);
len = _tcslen(tszText);
- res = (TCHAR*)malloc((len + 1) * sizeof(TCHAR));
+ res = (TCHAR*)mir_alloc((len + 1) * sizeof(TCHAR));
_tcscpy(res, tszText);
res[len] = _T('\0');
GlobalUnlock(hData);
diff --git a/plugins/Variables/tokenregister.cpp b/plugins/Variables/tokenregister.cpp
index 50c81ddad8..d88b81949a 100644
--- a/plugins/Variables/tokenregister.cpp
+++ b/plugins/Variables/tokenregister.cpp
@@ -57,7 +57,8 @@ int registerIntToken(TCHAR *szToken, TCHAR *(*parseFunction)(ARGUMENTSINFO *ai),
TOKENREGISTEREX tr = { 0 };
tr.cbSize = sizeof(tr);
tr.flags = TRF_FREEMEM|TRF_TCHAR|TRF_PARSEFUNC|extraFlags;
- tr.memType = TR_MEM_VARIABLES;
+ //tr.memType = TR_MEM_VARIABLES;
+ tr.memType = TR_MEM_MIRANDA;
tr.szHelpText = szHelpText;
tr.tszTokenString = szToken;
tr.parseFunctionT = parseFunction;
@@ -211,7 +212,7 @@ TCHAR *parseFromRegister(ARGUMENTSINFO *ai)
cAi.argv[j] = u2a( ai->targv[j] );
if ( thisVr->flags & TRF_PARSEFUNC )
- callRes = (int)thisVr->parseFunction( &cAi );
+ callRes = (INT_PTR)thisVr->parseFunction( &cAi );
else if ( thisVr->szService != NULL)
callRes = CallService( thisVr->szService, (WPARAM)0, (LPARAM)&cAi );
@@ -225,7 +226,7 @@ TCHAR *parseFromRegister(ARGUMENTSINFO *ai)
else {
// unicode variables calls unicode plugin
if ( thisVr->flags & TRF_PARSEFUNC )
- callRes = (int)thisVr->parseFunctionT( ai );
+ callRes = (INT_PTR)thisVr->parseFunctionT( ai );
else if ( thisVr->szService != NULL )
callRes = CallService( thisVr->szService, (WPARAM)0, (LPARAM)ai );
@@ -244,8 +245,8 @@ TCHAR *parseFromRegister(ARGUMENTSINFO *ai)
if ( trCopy.flags & TRF_FREEMEM ) {
if ( trCopy.memType == TR_MEM_MIRANDA )
mir_free(( void* )callRes );
- else if ( trCopy.memType == TR_MEM_VARIABLES )
- free((void *)callRes);
+// else if ( trCopy.memType == TR_MEM_VARIABLES )
+// free((void *)callRes);
}
}
LeaveCriticalSection(&csRegister);
diff --git a/plugins/Variables/variables.cpp b/plugins/Variables/variables.cpp
index acc5f90a26..448398cafc 100644
--- a/plugins/Variables/variables.cpp
+++ b/plugins/Variables/variables.cpp
@@ -94,12 +94,12 @@ TCHAR *getArguments(TCHAR *string, TCHAR ***aargv, int *aargc) {
break;
}
if (bNewArg) {
- argv = ( TCHAR** )realloc(argv, (argc+1)*sizeof(TCHAR *));
+ argv = ( TCHAR** )mir_realloc(argv, (argc+1)*sizeof(TCHAR *));
if (argv == NULL) {
return NULL;
}
if (cur > scur) {
- argv[argc] = ( TCHAR* )malloc((cur-scur+2)*sizeof(TCHAR));
+ argv[argc] = ( TCHAR* )mir_alloc((cur-scur+2)*sizeof(TCHAR));
if (argv[argc] == NULL) {
return NULL;
}
@@ -107,7 +107,7 @@ TCHAR *getArguments(TCHAR *string, TCHAR ***aargv, int *aargc) {
_tcsncpy(argv[argc], scur+1, cur-(scur+1));
}
else {
- argv[argc] = _tcsdup(_T(""));
+ argv[argc] = mir_tstrdup(_T(""));
}
argc += 1;
bNewArg = FALSE;
@@ -123,10 +123,10 @@ TCHAR *getArguments(TCHAR *string, TCHAR ***aargv, int *aargc) {
else {
for (i=0;i<argc;i++) {
if (argv[i] != NULL) {
- free(argv[i]);
+ mir_free(argv[i]);
}
}
- free(argv);
+ mir_free(argv);
*aargv = NULL;
*aargc = 0;
cur = NULL;
@@ -167,7 +167,7 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi)
TOKENREGISTEREX *tr;
ARGUMENTSINFO ai = { 0 };
- string = _tcsdup(szTemplate);
+ string = mir_tstrdup(szTemplate);
if (string == NULL)
return NULL;
@@ -185,10 +185,10 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi)
for (i=0;i<argc;i++)
if (argv[i] != NULL)
- free(argv[i]);
+ mir_free(argv[i]);
if (argv != NULL)
- free(argv);
+ mir_free(argv);
argc = parsedTokenLen = initStrLen = tokenLen = 0;
tcur = scur = token = parsedToken = NULL;
@@ -225,7 +225,7 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi)
if (*cur == _T('\0')) {
*scur = _T('\0');
- string = ( TCHAR* )realloc(string, (_tcslen(string)+1)*sizeof(TCHAR));
+ string = ( TCHAR* )mir_realloc(string, (_tcslen(string)+1)*sizeof(TCHAR));
continue;
}
MoveMemory(scur, cur, (_tcslen(cur)+1)*sizeof(TCHAR));
@@ -303,16 +303,16 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi)
argv[i] = formatString(&afi);
fi->eCount += afi.eCount;
fi->pCount += afi.pCount;
- free(afi.szFormat);
+ mir_free(afi.szFormat);
}
}
if (argv[i] == NULL)
- argv[i] = _tcsdup(_T(""));
+ argv[i] = mir_tstrdup(_T(""));
}
}
// cur should now point at the character after FIELD_CHAR or after the last ')'
if (tr != NULL) {
- pargv = ( TCHAR** )malloc((argc+1)*sizeof(TCHAR *));
+ pargv = ( TCHAR** )mir_alloc((argc+1)*sizeof(TCHAR *));
if (pargv == NULL) {
fi->eCount += 1;
return NULL;
@@ -330,7 +330,7 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi)
ai.flags |= AIF_DONTPARSE;
parsedToken = parseFromRegister(&ai);
- free(pargv);
+ mir_free(pargv);
}
else parsedToken = fi->tszaTemporaryVars[tmpVarPos + 1];
@@ -366,7 +366,7 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi)
curPos = cur-string;
if (tokenLen < parsedTokenLen) {
// string needs more memory
- string = ( TCHAR* )realloc(string, (initStrLen-tokenLen+parsedTokenLen+1)*sizeof(TCHAR));
+ string = ( TCHAR* )mir_realloc(string, (initStrLen-tokenLen+parsedTokenLen+1)*sizeof(TCHAR));
if (string == NULL) {
fi->eCount += 1;
return NULL;
@@ -380,7 +380,7 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi)
int len;
len = _tcslen(string);
- string = ( TCHAR* )realloc(string, (len+1)*sizeof(TCHAR));
+ string = ( TCHAR* )mir_realloc(string, (len+1)*sizeof(TCHAR));
}
if (( ai.flags & AIF_DONTPARSE ) || tmpVarPos >= 0)
pos += parsedTokenLen;
@@ -395,12 +395,12 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi)
for ( i=0; i < argc; i++ )
if ( argv[i] != NULL )
- free( argv[i] );
+ mir_free( argv[i] );
if ( argv != NULL )
- free(argv);
+ mir_free(argv);
- return ( TCHAR* )realloc(string, (_tcslen(string)+1)*sizeof(TCHAR));
+ return ( TCHAR* )mir_realloc(string, (_tcslen(string)+1)*sizeof(TCHAR));
}
/*
@@ -408,7 +408,8 @@ static TCHAR* replaceDynVars(TCHAR* szTemplate, FORMATINFO* fi)
*/
static INT_PTR formatStringService(WPARAM wParam, LPARAM lParam) {
- int res, i;
+ INT_PTR res;
+ int i;
BOOL copied;
FORMATINFO *fi, tempFi;
FORMATINFOV1 *fiv1;
@@ -458,11 +459,11 @@ static INT_PTR formatStringService(WPARAM wParam, LPARAM lParam) {
tRes = formatString(fi);
if (!(fi->flags&FIF_TCHAR)) {
- res = (int)u2a(tRes);
- free(tRes);
+ res = (INT_PTR)mir_u2a(tRes);
+ mir_free(tRes);
}
else {
- res = (int)tRes;
+ res = (INT_PTR)tRes;
}
if (copied) {
@@ -508,12 +509,12 @@ TCHAR *formatString(FORMATINFO *fi) {
if ((fi == NULL) || (fi->tszFormat == NULL)) {
return NULL;
}
- string = _tcsdup(fi->tszFormat);
+ string = mir_tstrdup(fi->tszFormat);
if (string == NULL) {
return NULL;
}
formattedString = replaceDynVars(string, fi);
- free(string);
+ mir_free(string);
if (formattedString == NULL) {
return NULL;
}
@@ -529,7 +530,7 @@ static INT_PTR freeMemory(WPARAM wParam, LPARAM lParam) {
if ((void*)wParam == NULL) {
return -1;
}
- free((void*)wParam);
+ mir_free((void*)wParam);
return 0;
}