Commit 9d6a3845 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

advpack: Use CRT allocation functions.

parent 6129ea6b
...@@ -127,7 +127,7 @@ void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir) ...@@ -127,7 +127,7 @@ void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir)
if (!(value = wcschr(line, '='))) if (!(value = wcschr(line, '=')))
{ {
SetupGetStringFieldW(&context, 0, NULL, 0, &size); SetupGetStringFieldW(&context, 0, NULL, 0, &size);
key = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); key = malloc(size * sizeof(WCHAR));
key_copy = key; key_copy = key;
SetupGetStringFieldW(&context, 0, key, size, &size); SetupGetStringFieldW(&context, 0, key, size, &size);
value = line; value = line;
...@@ -165,7 +165,7 @@ void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir) ...@@ -165,7 +165,7 @@ void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir)
ldid = wcstol(ptr, NULL, 10); ldid = wcstol(ptr, NULL, 10);
SetupSetDirectoryIdW(hInf, ldid, dest); SetupSetDirectoryIdW(hInf, ldid, dest);
} }
HeapFree(GetProcessHeap(), 0, key_copy); free(key_copy);
} while (SetupFindNextLine(&context, &context)); } while (SetupFindNextLine(&context, &context));
} }
...@@ -227,7 +227,7 @@ BOOL WINAPI IsNTAdmin(DWORD reserved, LPDWORD pReserved) ...@@ -227,7 +227,7 @@ BOOL WINAPI IsNTAdmin(DWORD reserved, LPDWORD pReserved)
} }
} }
pTokenGroups = HeapAlloc(GetProcessHeap(), 0, dwSize); pTokenGroups = malloc(dwSize);
if (!pTokenGroups) if (!pTokenGroups)
{ {
CloseHandle(hToken); CloseHandle(hToken);
...@@ -236,7 +236,7 @@ BOOL WINAPI IsNTAdmin(DWORD reserved, LPDWORD pReserved) ...@@ -236,7 +236,7 @@ BOOL WINAPI IsNTAdmin(DWORD reserved, LPDWORD pReserved)
if (!GetTokenInformation(hToken, TokenGroups, pTokenGroups, dwSize, &dwSize)) if (!GetTokenInformation(hToken, TokenGroups, pTokenGroups, dwSize, &dwSize))
{ {
HeapFree(GetProcessHeap(), 0, pTokenGroups); free(pTokenGroups);
CloseHandle(hToken); CloseHandle(hToken);
return FALSE; return FALSE;
} }
...@@ -246,7 +246,7 @@ BOOL WINAPI IsNTAdmin(DWORD reserved, LPDWORD pReserved) ...@@ -246,7 +246,7 @@ BOOL WINAPI IsNTAdmin(DWORD reserved, LPDWORD pReserved)
if (!AllocateAndInitializeSid(&SidAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, if (!AllocateAndInitializeSid(&SidAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &pSid)) DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &pSid))
{ {
HeapFree(GetProcessHeap(), 0, pTokenGroups); free(pTokenGroups);
return FALSE; return FALSE;
} }
...@@ -259,7 +259,7 @@ BOOL WINAPI IsNTAdmin(DWORD reserved, LPDWORD pReserved) ...@@ -259,7 +259,7 @@ BOOL WINAPI IsNTAdmin(DWORD reserved, LPDWORD pReserved)
} }
} }
HeapFree(GetProcessHeap(), 0, pTokenGroups); free(pTokenGroups);
FreeSid(pSid); FreeSid(pSid);
return bSidFound; return bSidFound;
...@@ -469,16 +469,13 @@ HRESULT WINAPI RegisterOCX(HWND hWnd, HINSTANCE hInst, LPCSTR cmdline, INT show) ...@@ -469,16 +469,13 @@ HRESULT WINAPI RegisterOCX(HWND hWnd, HINSTANCE hInst, LPCSTR cmdline, INT show)
UNICODE_STRING cmdlineW; UNICODE_STRING cmdlineW;
HRESULT hr = E_FAIL; HRESULT hr = E_FAIL;
HMODULE hm = NULL; HMODULE hm = NULL;
DWORD size;
TRACE("(%s)\n", debugstr_a(cmdline)); TRACE("(%s)\n", debugstr_a(cmdline));
RtlCreateUnicodeStringFromAsciiz(&cmdlineW, cmdline); RtlCreateUnicodeStringFromAsciiz(&cmdlineW, cmdline);
size = (lstrlenW(cmdlineW.Buffer) + 1) * sizeof(WCHAR); cmdline_copy = wcsdup(cmdlineW.Buffer);
cmdline_copy = HeapAlloc(GetProcessHeap(), 0, size);
cmdline_ptr = cmdline_copy; cmdline_ptr = cmdline_copy;
lstrcpyW(cmdline_copy, cmdlineW.Buffer);
ocx_filename = get_parameter(&cmdline_ptr, ',', TRUE); ocx_filename = get_parameter(&cmdline_ptr, ',', TRUE);
if (!ocx_filename || !*ocx_filename) if (!ocx_filename || !*ocx_filename)
...@@ -495,7 +492,7 @@ HRESULT WINAPI RegisterOCX(HWND hWnd, HINSTANCE hInst, LPCSTR cmdline, INT show) ...@@ -495,7 +492,7 @@ HRESULT WINAPI RegisterOCX(HWND hWnd, HINSTANCE hInst, LPCSTR cmdline, INT show)
done: done:
FreeLibrary(hm); FreeLibrary(hm);
HeapFree(GetProcessHeap(), 0, cmdline_copy); free(cmdline_copy);
RtlFreeUnicodeString(&cmdlineW); RtlFreeUnicodeString(&cmdlineW);
return hr; return hr;
...@@ -636,7 +633,7 @@ HRESULT WINAPI TranslateInfStringA(LPCSTR pszInfFilename, LPCSTR pszInstallSecti ...@@ -636,7 +633,7 @@ HRESULT WINAPI TranslateInfStringA(LPCSTR pszInfFilename, LPCSTR pszInstallSecti
if (res == S_OK) if (res == S_OK)
{ {
bufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); bufferW = malloc(len * sizeof(WCHAR));
res = TranslateInfStringW(filenameW.Buffer, installW.Buffer, res = TranslateInfStringW(filenameW.Buffer, installW.Buffer,
translateW.Buffer, keyW.Buffer, bufferW, translateW.Buffer, keyW.Buffer, bufferW,
...@@ -655,7 +652,7 @@ HRESULT WINAPI TranslateInfStringA(LPCSTR pszInfFilename, LPCSTR pszInstallSecti ...@@ -655,7 +652,7 @@ HRESULT WINAPI TranslateInfStringA(LPCSTR pszInfFilename, LPCSTR pszInstallSecti
res = E_NOT_SUFFICIENT_BUFFER; res = E_NOT_SUFFICIENT_BUFFER;
} }
HeapFree(GetProcessHeap(), 0, bufferW); free(bufferW);
} }
RtlFreeUnicodeString(&filenameW); RtlFreeUnicodeString(&filenameW);
...@@ -753,7 +750,7 @@ HRESULT WINAPI TranslateInfStringExA(HINF hInf, LPCSTR pszInfFilename, ...@@ -753,7 +750,7 @@ HRESULT WINAPI TranslateInfStringExA(HINF hInf, LPCSTR pszInfFilename,
if (res == S_OK) if (res == S_OK)
{ {
bufferW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); bufferW = malloc(len * sizeof(WCHAR));
res = TranslateInfStringExW(hInf, filenameW.Buffer, sectionW.Buffer, res = TranslateInfStringExW(hInf, filenameW.Buffer, sectionW.Buffer,
keyW.Buffer, bufferW, len, &len, NULL); keyW.Buffer, bufferW, len, &len, NULL);
...@@ -772,7 +769,7 @@ HRESULT WINAPI TranslateInfStringExA(HINF hInf, LPCSTR pszInfFilename, ...@@ -772,7 +769,7 @@ HRESULT WINAPI TranslateInfStringExA(HINF hInf, LPCSTR pszInfFilename,
res = E_NOT_SUFFICIENT_BUFFER; res = E_NOT_SUFFICIENT_BUFFER;
} }
HeapFree(GetProcessHeap(), 0, bufferW); free(bufferW);
} }
RtlFreeUnicodeString(&filenameW); RtlFreeUnicodeString(&filenameW);
......
...@@ -21,21 +21,19 @@ ...@@ -21,21 +21,19 @@
#ifndef __ADVPACK_PRIVATE_H #ifndef __ADVPACK_PRIVATE_H
#define __ADVPACK_PRIVATE_H #define __ADVPACK_PRIVATE_H
#include "wine/heap.h"
HRESULT do_ocx_reg(HMODULE hocx, BOOL do_reg, const WCHAR *flags, const WCHAR *param) DECLSPEC_HIDDEN; HRESULT do_ocx_reg(HMODULE hocx, BOOL do_reg, const WCHAR *flags, const WCHAR *param) DECLSPEC_HIDDEN;
LPWSTR get_parameter(LPWSTR *params, WCHAR separator, BOOL quoted) DECLSPEC_HIDDEN; LPWSTR get_parameter(LPWSTR *params, WCHAR separator, BOOL quoted) DECLSPEC_HIDDEN;
void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir) DECLSPEC_HIDDEN; void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir) DECLSPEC_HIDDEN;
HRESULT launch_exe(LPCWSTR cmd, LPCWSTR dir, HANDLE *phEXE) DECLSPEC_HIDDEN; HRESULT launch_exe(LPCWSTR cmd, LPCWSTR dir, HANDLE *phEXE) DECLSPEC_HIDDEN;
static inline char *heap_strdupWtoA(const WCHAR *str) static inline char *strdupWtoA(const WCHAR *str)
{ {
char *ret = NULL; char *ret = NULL;
if(str) { if(str) {
size_t size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL); size_t size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
ret = heap_alloc(size); ret = malloc(size);
if(ret) if(ret)
WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
} }
......
...@@ -46,7 +46,7 @@ static LPWSTR ansi_to_unicode_list(LPCSTR ansi_list) ...@@ -46,7 +46,7 @@ static LPWSTR ansi_to_unicode_list(LPCSTR ansi_list)
while (*ptr) ptr += lstrlenA(ptr) + 1; while (*ptr) ptr += lstrlenA(ptr) + 1;
len = ptr + 1 - ansi_list; len = ptr + 1 - ansi_list;
wlen = MultiByteToWideChar(CP_ACP, 0, ansi_list, len, NULL, 0); wlen = MultiByteToWideChar(CP_ACP, 0, ansi_list, len, NULL, 0);
list = HeapAlloc(GetProcessHeap(), 0, wlen * sizeof(WCHAR)); list = malloc(wlen * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, ansi_list, len, list, wlen); MultiByteToWideChar(CP_ACP, 0, ansi_list, len, list, wlen);
return list; return list;
} }
...@@ -82,7 +82,7 @@ HRESULT WINAPI AddDelBackupEntryA(LPCSTR lpcszFileList, LPCSTR lpcszBackupDir, ...@@ -82,7 +82,7 @@ HRESULT WINAPI AddDelBackupEntryA(LPCSTR lpcszFileList, LPCSTR lpcszBackupDir,
res = AddDelBackupEntryW(filelist, backup, basename.Buffer, dwFlags); res = AddDelBackupEntryW(filelist, backup, basename.Buffer, dwFlags);
HeapFree(GetProcessHeap(), 0, filelist); free(filelist);
RtlFreeUnicodeString(&backupdir); RtlFreeUnicodeString(&backupdir);
RtlFreeUnicodeString(&basename); RtlFreeUnicodeString(&basename);
...@@ -246,7 +246,7 @@ HRESULT WINAPI AdvInstallFileW(HWND hwnd, LPCWSTR lpszSourceDir, LPCWSTR lpszSou ...@@ -246,7 +246,7 @@ HRESULT WINAPI AdvInstallFileW(HWND hwnd, LPCWSTR lpszSourceDir, LPCWSTR lpszSou
LPWSTR szDestFilename; LPWSTR szDestFilename;
LPCWSTR szPath; LPCWSTR szPath;
WCHAR szRootPath[ROOT_LENGTH]; WCHAR szRootPath[ROOT_LENGTH];
DWORD dwLen, dwLastError; DWORD dwLastError;
HSPFILEQ fileQueue; HSPFILEQ fileQueue;
PVOID pContext; PVOID pContext;
...@@ -268,18 +268,7 @@ HRESULT WINAPI AdvInstallFileW(HWND hwnd, LPCWSTR lpszSourceDir, LPCWSTR lpszSou ...@@ -268,18 +268,7 @@ HRESULT WINAPI AdvInstallFileW(HWND hwnd, LPCWSTR lpszSourceDir, LPCWSTR lpszSou
szPath = lpszSourceDir + ROOT_LENGTH; szPath = lpszSourceDir + ROOT_LENGTH;
/* use lpszSourceFile as destination filename if lpszDestFile is NULL */ /* use lpszSourceFile as destination filename if lpszDestFile is NULL */
if (lpszDestFile) szDestFilename = wcsdup(lpszDestFile ? lpszDestFile : lpszSourceFile);
{
dwLen = lstrlenW(lpszDestFile);
szDestFilename = HeapAlloc(GetProcessHeap(), 0, (dwLen+1) * sizeof(WCHAR));
lstrcpyW(szDestFilename, lpszDestFile);
}
else
{
dwLen = lstrlenW(lpszSourceFile);
szDestFilename = HeapAlloc(GetProcessHeap(), 0, (dwLen+1) * sizeof(WCHAR));
lstrcpyW(szDestFilename, lpszSourceFile);
}
/* add the file copy operation to the setup queue */ /* add the file copy operation to the setup queue */
if (!SetupQueueCopyW(fileQueue, szRootPath, szPath, lpszSourceFile, NULL, if (!SetupQueueCopyW(fileQueue, szRootPath, szPath, lpszSourceFile, NULL,
...@@ -314,7 +303,7 @@ done: ...@@ -314,7 +303,7 @@ done:
SetupTermDefaultQueueCallback(pContext); SetupTermDefaultQueueCallback(pContext);
SetupCloseFileQueue(fileQueue); SetupCloseFileQueue(fileQueue);
HeapFree(GetProcessHeap(), 0, szDestFilename); free(szDestFilename);
return HRESULT_FROM_WIN32(dwLastError); return HRESULT_FROM_WIN32(dwLastError);
} }
...@@ -483,9 +472,8 @@ HRESULT WINAPI DelNodeRunDLL32W(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT ...@@ -483,9 +472,8 @@ HRESULT WINAPI DelNodeRunDLL32W(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT
TRACE("(%p, %p, %s, %i)\n", hWnd, hInst, debugstr_w(cmdline), show); TRACE("(%p, %p, %s, %i)\n", hWnd, hInst, debugstr_w(cmdline), show);
cmdline_copy = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(cmdline) + 1) * sizeof(WCHAR)); cmdline_copy = wcsdup(cmdline);
cmdline_ptr = cmdline_copy; cmdline_ptr = cmdline_copy;
lstrcpyW(cmdline_copy, cmdline);
/* get the parameters at indexes 0 and 1 respectively */ /* get the parameters at indexes 0 and 1 respectively */
szFilename = get_parameter(&cmdline_ptr, ',', TRUE); szFilename = get_parameter(&cmdline_ptr, ',', TRUE);
...@@ -496,7 +484,7 @@ HRESULT WINAPI DelNodeRunDLL32W(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT ...@@ -496,7 +484,7 @@ HRESULT WINAPI DelNodeRunDLL32W(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT
res = DelNodeW(szFilename, dwFlags); res = DelNodeW(szFilename, dwFlags);
HeapFree(GetProcessHeap(), 0, cmdline_copy); free(cmdline_copy);
return res; return res;
} }
...@@ -549,14 +537,14 @@ static LPSTR convert_file_list(LPCSTR FileList, DWORD *dwNumFiles) ...@@ -549,14 +537,14 @@ static LPSTR convert_file_list(LPCSTR FileList, DWORD *dwNumFiles)
return NULL; return NULL;
dwLen = last - first + 3; /* room for double-null termination */ dwLen = last - first + 3; /* room for double-null termination */
szConvertedList = HeapAlloc(GetProcessHeap(), 0, dwLen); szConvertedList = malloc(dwLen);
lstrcpynA(szConvertedList, first, dwLen - 1); lstrcpynA(szConvertedList, first, dwLen - 1);
szConvertedList[dwLen - 1] = '\0'; szConvertedList[dwLen - 1] = '\0';
/* empty list */ /* empty list */
if (!szConvertedList[0]) if (!szConvertedList[0])
{ {
HeapFree(GetProcessHeap(), 0, szConvertedList); free(szConvertedList);
return NULL; return NULL;
} }
...@@ -580,8 +568,8 @@ static LPSTR convert_file_list(LPCSTR FileList, DWORD *dwNumFiles) ...@@ -580,8 +568,8 @@ static LPSTR convert_file_list(LPCSTR FileList, DWORD *dwNumFiles)
static void free_file_node(struct FILELIST *pNode) static void free_file_node(struct FILELIST *pNode)
{ {
HeapFree(GetProcessHeap(), 0, pNode->FileName); free(pNode->FileName);
HeapFree(GetProcessHeap(), 0, pNode); free(pNode);
} }
/* determines whether szFile is in the NULL-separated szFileList */ /* determines whether szFile is in the NULL-separated szFileList */
...@@ -731,7 +719,7 @@ HRESULT WINAPI ExtractFilesA(LPCSTR CabName, LPCSTR ExpandDir, DWORD Flags, ...@@ -731,7 +719,7 @@ HRESULT WINAPI ExtractFilesA(LPCSTR CabName, LPCSTR ExpandDir, DWORD Flags,
done: done:
free_file_list(&session); free_file_list(&session);
FreeLibrary(hCabinet); FreeLibrary(hCabinet);
HeapFree(GetProcessHeap(), 0, szConvertedList); free(szConvertedList);
return res; return res;
} }
...@@ -774,19 +762,19 @@ HRESULT WINAPI ExtractFilesW(LPCWSTR CabName, LPCWSTR ExpandDir, DWORD Flags, ...@@ -774,19 +762,19 @@ HRESULT WINAPI ExtractFilesW(LPCWSTR CabName, LPCWSTR ExpandDir, DWORD Flags,
Flags, debugstr_w(FileList), LReserved, Reserved); Flags, debugstr_w(FileList), LReserved, Reserved);
if(CabName) { if(CabName) {
cab_name = heap_strdupWtoA(CabName); cab_name = strdupWtoA(CabName);
if(!cab_name) if(!cab_name)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
if(ExpandDir) { if(ExpandDir) {
expand_dir = heap_strdupWtoA(ExpandDir); expand_dir = strdupWtoA(ExpandDir);
if(!expand_dir) if(!expand_dir)
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
} }
if(SUCCEEDED(hres) && FileList) { if(SUCCEEDED(hres) && FileList) {
file_list = heap_strdupWtoA(FileList); file_list = strdupWtoA(FileList);
if(!file_list) if(!file_list)
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
} }
...@@ -796,9 +784,9 @@ HRESULT WINAPI ExtractFilesW(LPCWSTR CabName, LPCWSTR ExpandDir, DWORD Flags, ...@@ -796,9 +784,9 @@ HRESULT WINAPI ExtractFilesW(LPCWSTR CabName, LPCWSTR ExpandDir, DWORD Flags,
if(SUCCEEDED(hres)) if(SUCCEEDED(hres))
hres = ExtractFilesA(cab_name, expand_dir, Flags, file_list, LReserved, Reserved); hres = ExtractFilesA(cab_name, expand_dir, Flags, file_list, LReserved, Reserved);
heap_free(cab_name); free(cab_name);
heap_free(expand_dir); free(expand_dir);
heap_free(file_list); free(file_list);
return hres; return hres;
} }
...@@ -1078,7 +1066,7 @@ HRESULT WINAPI GetVersionFromFileExW(LPCWSTR lpszFilename, LPDWORD pdwMSVer, ...@@ -1078,7 +1066,7 @@ HRESULT WINAPI GetVersionFromFileExW(LPCWSTR lpszFilename, LPDWORD pdwMSVer,
goto done; goto done;
} }
pVersionInfo = HeapAlloc(GetProcessHeap(), 0, dwInfoSize); pVersionInfo = malloc(dwInfoSize);
if (!pVersionInfo) if (!pVersionInfo)
goto done; goto done;
...@@ -1110,7 +1098,7 @@ HRESULT WINAPI GetVersionFromFileExW(LPCWSTR lpszFilename, LPDWORD pdwMSVer, ...@@ -1110,7 +1098,7 @@ HRESULT WINAPI GetVersionFromFileExW(LPCWSTR lpszFilename, LPDWORD pdwMSVer,
} }
done: done:
HeapFree(GetProcessHeap(), 0, pVersionInfo); free(pVersionInfo);
if (bFileCopied) if (bFileCopied)
DeleteFileW(szFile); DeleteFileW(szFile);
......
...@@ -227,13 +227,13 @@ static WCHAR *get_field_string(INFCONTEXT *context, DWORD index, WCHAR *buffer, ...@@ -227,13 +227,13 @@ static WCHAR *get_field_string(INFCONTEXT *context, DWORD index, WCHAR *buffer,
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{ {
/* now grow the buffer */ /* now grow the buffer */
if (buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer); if (buffer != static_buffer) free(buffer);
if (!(buffer = HeapAlloc(GetProcessHeap(), 0, required*sizeof(WCHAR)))) return NULL; if (!(buffer = malloc(required*sizeof(WCHAR)))) return NULL;
*size = required; *size = required;
if (SetupGetStringFieldW(context, index, buffer, *size, &required)) return buffer; if (SetupGetStringFieldW(context, index, buffer, *size, &required)) return buffer;
} }
if (buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer); if (buffer != static_buffer) free(buffer);
return NULL; return NULL;
} }
...@@ -267,7 +267,7 @@ static HRESULT iterate_section_fields(HINF hinf, PCWSTR section, PCWSTR key, ...@@ -267,7 +267,7 @@ static HRESULT iterate_section_fields(HINF hinf, PCWSTR section, PCWSTR key,
hr = S_OK; hr = S_OK;
done: done:
if (buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer); if (buffer != static_buffer) free(buffer);
return hr; return hr;
} }
...@@ -401,7 +401,7 @@ static HRESULT get_working_dir(ADVInfo *info, LPCWSTR inf_filename, LPCWSTR work ...@@ -401,7 +401,7 @@ static HRESULT get_working_dir(ADVInfo *info, LPCWSTR inf_filename, LPCWSTR work
ptr = path; ptr = path;
} }
info->working_dir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); info->working_dir = malloc(len * sizeof(WCHAR));
if (!info->working_dir) if (!info->working_dir)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -421,38 +421,21 @@ static HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec, ...@@ -421,38 +421,21 @@ static HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec,
if (!(ptr = wcsrchr(inf_filename, '\\'))) if (!(ptr = wcsrchr(inf_filename, '\\')))
ptr = inf_filename; ptr = inf_filename;
len = lstrlenW(ptr); info->inf_filename = wcsdup(ptr);
info->inf_filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
if (!info->inf_filename) if (!info->inf_filename)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
lstrcpyW(info->inf_filename, ptr);
/* FIXME: determine the proper platform to install (NTx86, etc) */ /* FIXME: determine the proper platform to install (NTx86, etc) */
if (!install_sec || !*install_sec) info->install_sec = wcsdup(install_sec && *install_sec ? install_sec : L"DefaultInstall");
{
len = ARRAY_SIZE(L"DefaultInstall");
ptr = L"DefaultInstall";
}
else
{
len = lstrlenW(install_sec) + 1;
ptr = install_sec;
}
info->install_sec = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
if (!info->install_sec) if (!info->install_sec)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
lstrcpyW(info->install_sec, ptr);
hr = get_working_dir(info, inf_filename, working_dir); hr = get_working_dir(info, inf_filename, working_dir);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
len = lstrlenW(info->working_dir) + lstrlenW(info->inf_filename) + 2; len = lstrlenW(info->working_dir) + lstrlenW(info->inf_filename) + 2;
info->inf_path = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); info->inf_path = malloc(len * sizeof(WCHAR));
if (!info->inf_path) if (!info->inf_path)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -485,10 +468,10 @@ static void install_release(const ADVInfo *info) ...@@ -485,10 +468,10 @@ static void install_release(const ADVInfo *info)
{ {
SetupCloseInfFile(info->hinf); SetupCloseInfFile(info->hinf);
HeapFree(GetProcessHeap(), 0, info->inf_path); free(info->inf_path);
HeapFree(GetProcessHeap(), 0, info->inf_filename); free(info->inf_filename);
HeapFree(GetProcessHeap(), 0, info->install_sec); free(info->install_sec);
HeapFree(GetProcessHeap(), 0, info->working_dir); free(info->working_dir);
} }
/* this structure very closely resembles parameters of RunSetupCommand() */ /* this structure very closely resembles parameters of RunSetupCommand() */
...@@ -733,9 +716,8 @@ INT WINAPI LaunchINFSectionW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT sho ...@@ -733,9 +716,8 @@ INT WINAPI LaunchINFSectionW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT sho
if (!cmdline) if (!cmdline)
return ADV_FAILURE; return ADV_FAILURE;
cmdline_copy = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(cmdline) + 1) * sizeof(WCHAR)); cmdline_copy = wcsdup(cmdline);
cmdline_ptr = cmdline_copy; cmdline_ptr = cmdline_copy;
lstrcpyW(cmdline_copy, cmdline);
inf_filename = get_parameter(&cmdline_ptr, ',', TRUE); inf_filename = get_parameter(&cmdline_ptr, ',', TRUE);
install_sec = get_parameter(&cmdline_ptr, ',', TRUE); install_sec = get_parameter(&cmdline_ptr, ',', TRUE);
...@@ -762,7 +744,7 @@ INT WINAPI LaunchINFSectionW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT sho ...@@ -762,7 +744,7 @@ INT WINAPI LaunchINFSectionW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT sho
done: done:
install_release(&info); install_release(&info);
HeapFree(GetProcessHeap(), 0, cmdline_copy); free(cmdline_copy);
return SUCCEEDED(hr) ? ADV_SUCCESS : ADV_FAILURE; return SUCCEEDED(hr) ? ADV_SUCCESS : ADV_FAILURE;
} }
...@@ -830,9 +812,8 @@ HRESULT WINAPI LaunchINFSectionExW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, I ...@@ -830,9 +812,8 @@ HRESULT WINAPI LaunchINFSectionExW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, I
if (!cmdline) if (!cmdline)
return ADV_FAILURE; return ADV_FAILURE;
cmdline_copy = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(cmdline) + 1) * sizeof(WCHAR)); cmdline_copy = wcsdup(cmdline);
cmdline_ptr = cmdline_copy; cmdline_ptr = cmdline_copy;
lstrcpyW(cmdline_copy, cmdline);
cabinfo.pszInf = get_parameter(&cmdline_ptr, ',', TRUE); cabinfo.pszInf = get_parameter(&cmdline_ptr, ',', TRUE);
cabinfo.pszSection = get_parameter(&cmdline_ptr, ',', TRUE); cabinfo.pszSection = get_parameter(&cmdline_ptr, ',', TRUE);
...@@ -845,7 +826,7 @@ HRESULT WINAPI LaunchINFSectionExW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, I ...@@ -845,7 +826,7 @@ HRESULT WINAPI LaunchINFSectionExW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, I
if (!is_full_path(cabinfo.pszCab) && !is_full_path(cabinfo.pszInf)) if (!is_full_path(cabinfo.pszCab) && !is_full_path(cabinfo.pszInf))
{ {
HeapFree(GetProcessHeap(), 0, cmdline_copy); free(cmdline_copy);
return E_INVALIDARG; return E_INVALIDARG;
} }
...@@ -862,7 +843,7 @@ HRESULT WINAPI LaunchINFSectionExW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, I ...@@ -862,7 +843,7 @@ HRESULT WINAPI LaunchINFSectionExW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, I
} }
hr = ExecuteCabW(hWnd, &cabinfo, NULL); hr = ExecuteCabW(hWnd, &cabinfo, NULL);
HeapFree(GetProcessHeap(), 0, cmdline_copy); free(cmdline_copy);
return SUCCEEDED(hr) ? ADV_SUCCESS : ADV_FAILURE; return SUCCEEDED(hr) ? ADV_SUCCESS : ADV_FAILURE;
} }
......
...@@ -95,8 +95,8 @@ static void strentry_atow(const STRENTRYA *aentry, STRENTRYW *wentry) ...@@ -95,8 +95,8 @@ static void strentry_atow(const STRENTRYA *aentry, STRENTRYW *wentry)
name_len = MultiByteToWideChar(CP_ACP, 0, aentry->pszName, -1, NULL, 0); name_len = MultiByteToWideChar(CP_ACP, 0, aentry->pszName, -1, NULL, 0);
val_len = MultiByteToWideChar(CP_ACP, 0, aentry->pszValue, -1, NULL, 0); val_len = MultiByteToWideChar(CP_ACP, 0, aentry->pszValue, -1, NULL, 0);
wentry->pszName = HeapAlloc(GetProcessHeap(), 0, name_len * sizeof(WCHAR)); wentry->pszName = malloc(name_len * sizeof(WCHAR));
wentry->pszValue = HeapAlloc(GetProcessHeap(), 0, val_len * sizeof(WCHAR)); wentry->pszValue = malloc(val_len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, aentry->pszName, -1, wentry->pszName, name_len); MultiByteToWideChar(CP_ACP, 0, aentry->pszName, -1, wentry->pszName, name_len);
MultiByteToWideChar(CP_ACP, 0, aentry->pszValue, -1, wentry->pszValue, val_len); MultiByteToWideChar(CP_ACP, 0, aentry->pszValue, -1, wentry->pszValue, val_len);
...@@ -107,8 +107,8 @@ static STRTABLEW *strtable_atow(const STRTABLEA *atable) ...@@ -107,8 +107,8 @@ static STRTABLEW *strtable_atow(const STRTABLEA *atable)
STRTABLEW *wtable; STRTABLEW *wtable;
DWORD j; DWORD j;
wtable = HeapAlloc(GetProcessHeap(), 0, sizeof(STRTABLEW)); wtable = malloc(sizeof(STRTABLEW));
wtable->pse = HeapAlloc(GetProcessHeap(), 0, atable->cEntries * sizeof(STRENTRYW)); wtable->pse = malloc(atable->cEntries * sizeof(STRENTRYW));
wtable->cEntries = atable->cEntries; wtable->cEntries = atable->cEntries;
for (j = 0; j < wtable->cEntries; j++) for (j = 0; j < wtable->cEntries; j++)
...@@ -123,12 +123,12 @@ static void free_strtable(STRTABLEW *wtable) ...@@ -123,12 +123,12 @@ static void free_strtable(STRTABLEW *wtable)
for (j = 0; j < wtable->cEntries; j++) for (j = 0; j < wtable->cEntries; j++)
{ {
HeapFree(GetProcessHeap(), 0, wtable->pse[j].pszName); free(wtable->pse[j].pszName);
HeapFree(GetProcessHeap(), 0, wtable->pse[j].pszValue); free(wtable->pse[j].pszValue);
} }
HeapFree(GetProcessHeap(), 0, wtable->pse); free(wtable->pse);
HeapFree(GetProcessHeap(), 0, wtable); free(wtable);
} }
/*********************************************************************** /***********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment