summaryrefslogtreecommitdiff
path: root/plugins/Variables/parse_system.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-06-30 16:17:46 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-06-30 16:17:46 +0000
commit7dad3543a2b848f6547b291f812c9643dc0b85f2 (patch)
tree1054ad62ecba19750bb4531f34e9d033ac1b7244 /plugins/Variables/parse_system.cpp
parent008fe34954b0bda8fd3487a9658c14581ecd813a (diff)
Variables moved to mir_* memory allocation routines
git-svn-id: http://svn.miranda-ng.org/main/trunk@696 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Variables/parse_system.cpp')
-rw-r--r--plugins/Variables/parse_system.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/plugins/Variables/parse_system.cpp b/plugins/Variables/parse_system.cpp
index 960618ac01..a733f8ba25 100644
--- a/plugins/Variables/parse_system.cpp
+++ b/plugins/Variables/parse_system.cpp
@@ -2,7 +2,7 @@
Variables Plugin for Miranda-IM (www.miranda-im.org)
Copyright 2003-2006 P. Boon
- This program is free software; you can redistribute it and/or modify
+ This program is mir_free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
@@ -70,9 +70,9 @@ static TCHAR *parseCpuLoad(ARGUMENTSINFO *ai) {
return NULL;
if (_tcslen(ai->targv[1]) == 0)
- szCounter = _tcsdup(_T("\\Processor(_Total)\\% Processor Time"));
+ szCounter = mir_tstrdup(_T("\\Processor(_Total)\\% Processor Time"));
else {
- szCounter = ( TCHAR* )malloc((_tcslen(ai->targv[1]) + 32)*sizeof(TCHAR));
+ szCounter = ( TCHAR* )mir_alloc((_tcslen(ai->targv[1]) + 32)*sizeof(TCHAR));
if (szCounter == NULL)
return NULL;
@@ -80,23 +80,23 @@ static TCHAR *parseCpuLoad(ARGUMENTSINFO *ai) {
}
pdhStatus = PdhValidatePath(szCounter);
if (pdhStatus != ERROR_SUCCESS) {
- free(szCounter);
+ mir_free(szCounter);
return NULL;
}
pdhStatus = PdhOpenQuery(NULL, 0, &hQuery);
if (pdhStatus != ERROR_SUCCESS) {
- free(szCounter);
+ mir_free(szCounter);
return NULL;
}
pdhStatus = PdhAddCounter(hQuery, szCounter, 0, &hCounter);
if (pdhStatus != ERROR_SUCCESS) {
- free(szCounter);
+ mir_free(szCounter);
pdhStatus = PdhCloseQuery(hQuery);
return NULL;
}
pdhStatus = PdhCollectQueryData(hQuery);
if (pdhStatus != ERROR_SUCCESS) {
- free(szCounter);
+ mir_free(szCounter);
PdhRemoveCounter(hCounter);
pdhStatus = PdhCloseQuery(hQuery);
return NULL;
@@ -104,20 +104,20 @@ static TCHAR *parseCpuLoad(ARGUMENTSINFO *ai) {
Sleep(100);
pdhStatus = PdhCollectQueryData(hQuery);
if (pdhStatus != ERROR_SUCCESS) {
- free(szCounter);
+ mir_free(szCounter);
PdhRemoveCounter(hCounter);
pdhStatus = PdhCloseQuery(hQuery);
return NULL;
}
pdhStatus = PdhGetFormattedCounterValue(hCounter, PDH_FMT_DOUBLE, (LPDWORD)NULL, &cValue);
if (pdhStatus != ERROR_SUCCESS) {
- free(szCounter);
+ mir_free(szCounter);
PdhRemoveCounter(hCounter);
pdhStatus = PdhCloseQuery(hQuery);
return NULL;
}
if (cValue.CStatus != ERROR_SUCCESS) {
- free(szCounter);
+ mir_free(szCounter);
PdhRemoveCounter(hCounter);
pdhStatus = PdhCloseQuery(hQuery);
return NULL;
@@ -125,7 +125,7 @@ static TCHAR *parseCpuLoad(ARGUMENTSINFO *ai) {
mir_sntprintf(szVal, SIZEOF(szVal), _T("%.0f"), cValue.doubleValue);
//PdhRemoveCounter(*hCounter);
PdhCloseQuery(hQuery);
- free(szCounter);
+ mir_free(szCounter);
return mir_tstrdup(szVal);
}
@@ -457,7 +457,7 @@ static TCHAR *parseListDir(ARGUMENTSINFO *ai) {
return NULL;
}
if ( ((ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && (bDirs)) || ((!(ffd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) && (bFiles))) {
- 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, ffd.cFileName);
}
while (FindNextFile(hFind, &ffd) != 0) {
@@ -520,7 +520,7 @@ static TCHAR *parseRegistryValue(ARGUMENTSINFO *ai) {
if (ai->argc != 3) {
return NULL;
}
- key = subKey = _tcsdup(ai->targv[1]);
+ key = subKey = mir_tstrdup(ai->targv[1]);
if (subKey == NULL) {
return NULL;
}
@@ -542,15 +542,15 @@ static TCHAR *parseRegistryValue(ARGUMENTSINFO *ai) {
hKey = HKEY_USERS;
}
else {
- free(key);
+ mir_free(key);
return NULL;
}
subKey = cur+1;
if (RegOpenKeyEx(hKey, subKey, 0, KEY_READ, &hKey) != ERROR_SUCCESS) {
- free(key);
+ mir_free(key);
return NULL;
}
- free(key);
+ mir_free(key);
len = MAX_REGVALUE_LENGTH+1;
res = ( TCHAR* )mir_alloc(len*sizeof(TCHAR));
if (res == NULL) {
@@ -714,15 +714,15 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) {
res = (TCHAR *)pBuf;
}
else {
- res = mir_a2u((char *)pBuf);
- free(pBuf);
+ res = mir_a2t((char *)pBuf);
+ mir_free(pBuf);
}
return res;
}
bufSz = TXTFILEBUFSZ*csz;
- pBuf = ( PBYTE )calloc(bufSz, 1);
+ pBuf = ( PBYTE )mir_calloc(bufSz);
if (pBuf == NULL) {
return NULL;
}
@@ -731,7 +731,7 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) {
ZeroMemory(pBuf, bufSz);
if (ReadFile(hFile, pBuf, bufSz-csz, &readSz, NULL) == 0) {
CloseHandle(hFile);
- free(pBuf);
+ mir_free(pBuf);
return NULL;
}
totalReadSz += readSz;
@@ -804,12 +804,12 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) {
} while ( (totalReadSz < fileSz) && (readSz > 0));
if (linePos < 0) {
CloseHandle(hFile);
- free(pBuf);
+ mir_free(pBuf);
return NULL;
}
if (SetFilePointer(hFile, linePos, NULL, FILE_BEGIN) != linePos) {
CloseHandle(hFile);
- free(pBuf);
+ mir_free(pBuf);
return NULL;
}
ZeroMemory(pBuf, bufSz);
@@ -817,7 +817,7 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) {
do {
icur = 0;
if (ReadFile(hFile, pBuf, bufSz-csz, &readSz, NULL) == 0) {
- free(pBuf);
+ mir_free(pBuf);
CloseHandle(hFile);
return NULL;
}
@@ -836,8 +836,8 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) {
res = (TCHAR *)pBuf;
}
else {
- res = a2u((char *)pBuf);
- free(pBuf);
+ res = mir_a2t((char *)pBuf);
+ mir_free(pBuf);
}
return res;
@@ -850,8 +850,8 @@ static TCHAR *parseTextFile(ARGUMENTSINFO *ai) {
res = (TCHAR *)pBuf;
}
else {
- res = a2u((char *)pBuf);
- free(pBuf);
+ res = mir_a2t((char *)pBuf);
+ mir_free(pBuf);
}
return res;