Author: tfaber
Date: Sat Feb 2 11:14:58 2013
New Revision: 58264
URL:
http://svn.reactos.org/svn/reactos?rev=58264&view=rev
Log:
[EXPLORER_NEW]
- Prefer HeapAlloc over malloc
Modified:
trunk/reactos/base/shell/explorer-new/startup.c
trunk/reactos/base/shell/explorer-new/trayntfy.c
Modified: trunk/reactos/base/shell/explorer-new/startup.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/st…
==============================================================================
--- trunk/reactos/base/shell/explorer-new/startup.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/startup.c [iso-8859-1] Sat Feb 2 11:14:58 2013
@@ -107,9 +107,9 @@
static BOOL ProcessRunKeys(HKEY hkRoot, LPCWSTR szKeyName, BOOL bDelete,
BOOL bSynchronous)
{
- HKEY hkWin = NULL, hkRun=NULL;
+ HKEY hkWin = NULL, hkRun = NULL;
LONG res = ERROR_SUCCESS;
- DWORD i, nMaxCmdLine = 0, nMaxValue = 0;
+ DWORD i, cbMaxCmdLine = 0, cchMaxValue = 0;
WCHAR *szCmdLine = NULL;
WCHAR *szValue = NULL;
@@ -118,7 +118,12 @@
else
wprintf(L"processing %s entries under HKCU\n", szKeyName);
- if ((res = RegOpenKeyExW(hkRoot,
L"Software\\Microsoft\\Windows\\CurrentVersion", 0, KEY_READ, &hkWin)) !=
ERROR_SUCCESS)
+ res = RegOpenKeyExW(hkRoot,
+ L"Software\\Microsoft\\Windows\\CurrentVersion",
+ 0,
+ KEY_READ,
+ &hkWin);
+ if (res != ERROR_SUCCESS)
{
printf("RegOpenKey failed on Software\\Microsoft\\Windows\\CurrentVersion
(%ld)\n",
res);
@@ -126,8 +131,12 @@
goto end;
}
- if ((res = RegOpenKeyExW(hkWin, szKeyName, 0, bDelete?KEY_ALL_ACCESS:KEY_READ,
&hkRun))!=
- ERROR_SUCCESS)
+ res = RegOpenKeyExW(hkWin,
+ szKeyName,
+ 0,
+ bDelete ? KEY_ALL_ACCESS : KEY_READ,
+ &hkRun);
+ if (res != ERROR_SUCCESS)
{
if (res == ERROR_FILE_NOT_FOUND)
{
@@ -141,8 +150,19 @@
goto end;
}
- if ((res = RegQueryInfoKeyW(hkRun, NULL, NULL, NULL, NULL, NULL, NULL, &i,
&nMaxValue,
- &nMaxCmdLine, NULL, NULL)) != ERROR_SUCCESS)
+ res = RegQueryInfoKeyW(hkRun,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ &i,
+ &cchMaxValue,
+ &cbMaxCmdLine,
+ NULL,
+ NULL);
+ if (res != ERROR_SUCCESS)
{
printf("Couldn't query key info (%ld)\n", res);
@@ -157,7 +177,10 @@
goto end;
}
- if ((szCmdLine = malloc(nMaxCmdLine)) == NULL)
+ szCmdLine = HeapAlloc(hProcessHeap,
+ 0,
+ cbMaxCmdLine);
+ if (szCmdLine == NULL)
{
printf("Couldn't allocate memory for the commands to be
executed\n");
@@ -165,24 +188,34 @@
goto end;
}
- if ((szValue = malloc((++nMaxValue)*sizeof(*szValue))) == NULL)
+ ++cchMaxValue;
+ szValue = HeapAlloc(hProcessHeap,
+ 0,
+ cchMaxValue * sizeof(*szValue));
+ if (szValue == NULL)
{
printf("Couldn't allocate memory for the value names\n");
- free(szCmdLine);
res = ERROR_NOT_ENOUGH_MEMORY;
goto end;
}
while (i > 0)
{
- DWORD nValLength = nMaxValue, nDataLength = nMaxCmdLine;
+ DWORD cchValLength = cchMaxValue, cbDataLength = cbMaxCmdLine;
DWORD type;
--i;
- if ((res = RegEnumValueW(hkRun, i, szValue, &nValLength, 0, &type,
- (LPBYTE)szCmdLine, &nDataLength)) != ERROR_SUCCESS)
+ res = RegEnumValueW(hkRun,
+ i,
+ szValue,
+ &cchValLength,
+ 0,
+ &type,
+ (PBYTE)szCmdLine,
+ &cbDataLength);
+ if (res != ERROR_SUCCESS)
{
printf("Couldn't read in value %ld - %ld\n", i, res);
@@ -204,7 +237,8 @@
continue;
}
- if ((res = runCmd(szCmdLine, NULL, bSynchronous, FALSE)) ==
INVALID_RUNCMD_RETURN)
+ res = runCmd(szCmdLine, NULL, bSynchronous, FALSE);
+ if (res == INVALID_RUNCMD_RETURN)
{
printf("Error running cmd #%ld (%ld)\n", i, GetLastError());
}
@@ -212,11 +246,12 @@
printf("Done processing cmd #%ld\n", i);
}
- free(szValue);
- free(szCmdLine);
res = ERROR_SUCCESS;
-
end:
+ if (szValue != NULL)
+ HeapFree(hProcessHeap, 0, szValue);
+ if (szCmdLine != NULL)
+ HeapFree(hProcessHeap, 0, szCmdLine);
if (hkRun != NULL)
RegCloseKey(hkRun);
if (hkWin != NULL)
Modified: trunk/reactos/base/shell/explorer-new/trayntfy.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/explorer-new/tr…
==============================================================================
--- trunk/reactos/base/shell/explorer-new/trayntfy.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/explorer-new/trayntfy.c [iso-8859-1] Sat Feb 2 11:14:58
2013
@@ -51,11 +51,12 @@
PNOTIFY_ITEM *findNotifyPointer = &This->NotifyItems;
PNOTIFY_ITEM notifyItem;
- notifyItem = malloc(sizeof(*notifyItem));
+ notifyItem = HeapAlloc(hProcessHeap,
+ HEAP_ZERO_MEMORY,
+ sizeof(*notifyItem));
if (notifyItem == NULL)
return NULL;
- ZeroMemory(notifyItem, sizeof(*notifyItem));
notifyItem->next = NULL;
while (*findNotifyPointer != NULL)
@@ -248,7 +249,9 @@
if (!(deleteItem->iconData.dwState & NIS_HIDDEN))
This->VisibleButtonCount--;
- free(deleteItem);
+ HeapFree(hProcessHeap,
+ 0,
+ deleteItem);
This->ButtonCount--;
while (updateItem != NULL)