https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ce2c1f6321f3e59da8697…
commit ce2c1f6321f3e59da86970f545ec497ebf0e54cf
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Thu Nov 5 19:55:33 2020 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Fri Nov 6 01:06:12 2020 +0100
[
RAPPS.COM] Use HeapAlloc/Free instead of the deprecated LocalAlloc/Free.
And fix my build.
---
base/applications/rapps_com/main.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/base/applications/rapps_com/main.c b/base/applications/rapps_com/main.c
index fdb583f053d..d5f7c01ff0f 100644
--- a/base/applications/rapps_com/main.c
+++ b/base/applications/rapps_com/main.c
@@ -9,11 +9,12 @@
#include <winbase.h>
#include <strsafe.h>
-
int run_rapps(LPWSTR cmdline)
{
+ DWORD dwExit;
STARTUPINFOW si = { sizeof(si) };
PROCESS_INFORMATION pi = { 0 };
+
SetLastError(0);
if (!CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si,
&pi))
{
@@ -22,18 +23,21 @@ int run_rapps(LPWSTR cmdline)
}
CloseHandle(pi.hThread);
WaitForSingleObject(pi.hProcess, INFINITE);
- DWORD dwExit;
GetExitCodeProcess(pi.hProcess, &dwExit);
CloseHandle(pi.hProcess);
- return dwExit;
+ return (int)dwExit;
}
int wmain(int argc, wchar_t* argv[])
{
+ int iRet;
+ int n;
+ size_t arglen;
WCHAR RappsExe[MAX_PATH] = { 0 };
+ wchar_t* cmdline;
GetModuleFileNameW(NULL, RappsExe, ARRAYSIZE(RappsExe));
- size_t arglen = wcslen(RappsExe);
+ arglen = wcslen(RappsExe);
if (arglen > 4 && !wcsicmp(RappsExe + arglen - 4, L".com"))
{
wcscpy(RappsExe + arglen - 4, L".exe");
@@ -41,18 +45,18 @@ int wmain(int argc, wchar_t* argv[])
else
{
fprintf(stderr, "Unable to build rapps.exe path...\n");
- return - 1;
+ return -1;
}
- arglen += (1 + 2); // nullterminator + 2 quotes
+ arglen += (1 + 2); // NULL terminator + 2 quotes
- for (int n = 1; n < argc; ++n)
+ for (n = 1; n < argc; ++n)
{
arglen += wcslen(argv[n]);
arglen += 3; // Surrounding quotes + space
}
- wchar_t* cmdline = LocalAlloc(LMEM_ZEROINIT, arglen * sizeof(WCHAR));
+ cmdline = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, arglen * sizeof(WCHAR));
if (cmdline)
{
wchar_t* ptr = cmdline;
@@ -60,14 +64,14 @@ int wmain(int argc, wchar_t* argv[])
StringCchPrintfExW(ptr, cchRemaining, &ptr, &cchRemaining, 0,
L"\"%s\"", RappsExe);
- for (int n = 1; n < argc; ++n)
+ for (n = 1; n < argc; ++n)
{
StringCchPrintfExW(ptr, cchRemaining, &ptr, &cchRemaining, 0, L"
\"%s\"", argv[n]);
}
}
- int iRet = run_rapps(cmdline);
+ iRet = run_rapps(cmdline);
if (cmdline)
- LocalFree(cmdline);
+ HeapFree(GetProcessHeap(), 0, cmdline);
return iRet;
}