mirror of
https://github.com/LegacyUpdate/LegacyUpdate.git
synced 2025-01-22 14:12:07 -05:00
Replace all malloc/free with LocalAlloc/LocalFree
This commit is contained in:
parent
c20a9fab49
commit
fe2399bae4
5 changed files with 7 additions and 6 deletions
|
@ -8,7 +8,7 @@ void __cdecl IsProcessRunning(HWND hwndParent, int string_size, TCHAR *variables
|
|||
EXDLL_INIT();
|
||||
g_hwndParent = hwndParent;
|
||||
|
||||
LPTSTR process = (LPTSTR)malloc(string_size * sizeof(TCHAR));
|
||||
LPTSTR process = (LPTSTR)LocalAlloc(LPTR, string_size * sizeof(TCHAR));
|
||||
popstring(process);
|
||||
CharLowerBuffW(process, wcslen(process));
|
||||
|
||||
|
@ -17,5 +17,5 @@ void __cdecl IsProcessRunning(HWND hwndParent, int string_size, TCHAR *variables
|
|||
wsprintf(buffer, L"%d", pid);
|
||||
pushstring(buffer);
|
||||
|
||||
free(process);
|
||||
LocalFree(process);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include "Registry.h"
|
||||
|
||||
static LPWSTR _installPath;
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ HRESULT GetRegistryString(HKEY key, LPCWSTR subkeyPath, LPCWSTR valueName, DWORD
|
|||
|
||||
if (data != NULL && size != NULL) {
|
||||
DWORD length = 512 * sizeof(WCHAR);
|
||||
LPWSTR buffer = (LPWSTR)malloc(length);
|
||||
LPWSTR buffer = (LPWSTR)LocalAlloc(LPTR, length);
|
||||
LSTATUS status;
|
||||
do {
|
||||
status = RegQueryValueEx(subkey, valueName, NULL, NULL, (BYTE *)buffer, &length);
|
||||
if (status == ERROR_MORE_DATA) {
|
||||
length += 256 * sizeof(WCHAR);
|
||||
buffer = (LPWSTR)realloc(buffer, length);
|
||||
buffer = (LPWSTR)LocalReAlloc(buffer, length, LMEM_MOVEABLE);
|
||||
} else if (status != ERROR_SUCCESS) {
|
||||
hr = HRESULT_FROM_WIN32(status);
|
||||
goto end;
|
||||
|
|
|
@ -17,7 +17,7 @@ HRESULT GetOwnVersion(LPWSTR *version, LPDWORD size) {
|
|||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
LPVOID verInfo = malloc(verInfoSize);
|
||||
LPVOID verInfo = LocalAlloc(LPTR, verInfoSize);
|
||||
if (!GetFileVersionInfo(filename, verHandle, verInfoSize, verInfo)) {
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
|
|
@ -35,6 +35,6 @@ static inline BOOL IsOSVersionOrEarlier(DWORD major, DWORD minor) {
|
|||
HRESULT GetOwnVersion(LPWSTR *version, LPDWORD size);
|
||||
|
||||
static inline void GetOwnFileName(LPWSTR *filename, LPDWORD size) {
|
||||
*filename = (LPWSTR)malloc(MAX_PATH);
|
||||
*filename = (LPWSTR)LocalAlloc(LPTR, MAX_PATH);
|
||||
*size = GetModuleFileName((HMODULE)&__ImageBase, *filename, MAX_PATH);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue