Commit c293cd78 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

setupapi: Use CRT functions for memory allocation where possible.

The big win here is getting rid of the reimplementation of wcsdup.
parent 678a8156
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "winsvc.h" #include "winsvc.h"
#include "setupapi.h" #include "setupapi.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h" #include "wine/list.h"
#include "cfgmgr32.h" #include "cfgmgr32.h"
#include "winioctl.h" #include "winioctl.h"
...@@ -249,14 +248,14 @@ static DEVINST alloc_devnode(struct device *device) ...@@ -249,14 +248,14 @@ static DEVINST alloc_devnode(struct device *device)
{ {
if (devnode_table) if (devnode_table)
{ {
devnode_table = realloc(devnode_table, devnode_table_size * 2 * sizeof(*devnode_table));
memset(devnode_table + devnode_table_size, 0, devnode_table_size * sizeof(*devnode_table));
devnode_table_size *= 2; devnode_table_size *= 2;
devnode_table = heap_realloc_zero(devnode_table,
devnode_table_size * sizeof(*devnode_table));
} }
else else
{ {
devnode_table_size = 256; devnode_table_size = 256;
devnode_table = heap_alloc_zero(devnode_table_size * sizeof(*devnode_table)); devnode_table = calloc(devnode_table_size, sizeof(*devnode_table));
} }
} }
...@@ -296,7 +295,7 @@ static WCHAR *get_iface_key_path(struct device_iface *iface) ...@@ -296,7 +295,7 @@ static WCHAR *get_iface_key_path(struct device_iface *iface)
WCHAR *path, *ptr; WCHAR *path, *ptr;
size_t len = lstrlenW(DeviceClasses) + 1 + 38 + 1 + lstrlenW(iface->symlink); size_t len = lstrlenW(DeviceClasses) + 1 + 38 + 1 + lstrlenW(iface->symlink);
if (!(path = heap_alloc((len + 1) * sizeof(WCHAR)))) if (!(path = malloc((len + 1) * sizeof(WCHAR))))
{ {
SetLastError(ERROR_OUTOFMEMORY); SetLastError(ERROR_OUTOFMEMORY);
return NULL; return NULL;
...@@ -327,7 +326,7 @@ static WCHAR *get_refstr_key_path(struct device_iface *iface) ...@@ -327,7 +326,7 @@ static WCHAR *get_refstr_key_path(struct device_iface *iface)
if (iface->refstr) if (iface->refstr)
len += lstrlenW(iface->refstr); len += lstrlenW(iface->refstr);
if (!(path = heap_alloc((len + 1) * sizeof(WCHAR)))) if (!(path = malloc((len + 1) * sizeof(WCHAR))))
{ {
SetLastError(ERROR_OUTOFMEMORY); SetLastError(ERROR_OUTOFMEMORY);
return NULL; return NULL;
...@@ -393,7 +392,7 @@ static LPWSTR SETUPDI_CreateSymbolicLinkPath(LPCWSTR instanceId, ...@@ -393,7 +392,7 @@ static LPWSTR SETUPDI_CreateSymbolicLinkPath(LPCWSTR instanceId,
/* space for a hash between string and reference string: */ /* space for a hash between string and reference string: */
len += lstrlenW(ReferenceString) + 1; len += lstrlenW(ReferenceString) + 1;
} }
ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); ret = malloc(len * sizeof(WCHAR));
if (ret) if (ret)
{ {
int printed = swprintf(ret, len, fmt, instanceId, guidStr); int printed = swprintf(ret, len, fmt, instanceId, guidStr);
...@@ -450,7 +449,7 @@ static struct device_iface *SETUPDI_CreateDeviceInterface(struct device *device, ...@@ -450,7 +449,7 @@ static struct device_iface *SETUPDI_CreateDeviceInterface(struct device *device,
return iface; return iface;
} }
iface = heap_alloc(sizeof(*iface)); iface = malloc(sizeof(*iface));
symlink = SETUPDI_CreateSymbolicLinkPath(device->instanceId, class, refstr); symlink = SETUPDI_CreateSymbolicLinkPath(device->instanceId, class, refstr);
if (!iface || !symlink) if (!iface || !symlink)
...@@ -459,7 +458,7 @@ static struct device_iface *SETUPDI_CreateDeviceInterface(struct device *device, ...@@ -459,7 +458,7 @@ static struct device_iface *SETUPDI_CreateDeviceInterface(struct device *device,
goto err; goto err;
} }
if (refstr && !(refstr2 = strdupW(refstr))) if (refstr && !(refstr2 = wcsdup(refstr)))
{ {
SetLastError(ERROR_OUTOFMEMORY); SetLastError(ERROR_OUTOFMEMORY);
goto err; goto err;
...@@ -483,7 +482,7 @@ static struct device_iface *SETUPDI_CreateDeviceInterface(struct device *device, ...@@ -483,7 +482,7 @@ static struct device_iface *SETUPDI_CreateDeviceInterface(struct device *device,
} }
RegSetValueExW(key, DeviceInstance, 0, REG_SZ, (BYTE *)device->instanceId, RegSetValueExW(key, DeviceInstance, 0, REG_SZ, (BYTE *)device->instanceId,
lstrlenW(device->instanceId) * sizeof(WCHAR)); lstrlenW(device->instanceId) * sizeof(WCHAR));
heap_free(path); free(path);
iface->class_key = key; iface->class_key = key;
...@@ -504,7 +503,7 @@ static struct device_iface *SETUPDI_CreateDeviceInterface(struct device *device, ...@@ -504,7 +503,7 @@ static struct device_iface *SETUPDI_CreateDeviceInterface(struct device *device,
if (is_linked(key)) if (is_linked(key))
iface->flags |= SPINT_ACTIVE; iface->flags |= SPINT_ACTIVE;
heap_free(path); free(path);
iface->refstr_key = key; iface->refstr_key = key;
...@@ -512,18 +511,18 @@ static struct device_iface *SETUPDI_CreateDeviceInterface(struct device *device, ...@@ -512,18 +511,18 @@ static struct device_iface *SETUPDI_CreateDeviceInterface(struct device *device,
return iface; return iface;
err: err:
heap_free(iface); free(iface);
heap_free(refstr2); free(refstr2);
heap_free(symlink); free(symlink);
heap_free(path); free(path);
return NULL; return NULL;
} }
static BOOL SETUPDI_SetInterfaceSymbolicLink(struct device_iface *iface, static BOOL SETUPDI_SetInterfaceSymbolicLink(struct device_iface *iface,
const WCHAR *symlink) const WCHAR *symlink)
{ {
heap_free(iface->symlink); free(iface->symlink);
if ((iface->symlink = strdupW(symlink))) if ((iface->symlink = wcsdup(symlink)))
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
...@@ -691,9 +690,9 @@ static void delete_device_iface(struct device_iface *iface) ...@@ -691,9 +690,9 @@ static void delete_device_iface(struct device_iface *iface)
list_remove(&iface->entry); list_remove(&iface->entry);
RegCloseKey(iface->refstr_key); RegCloseKey(iface->refstr_key);
RegCloseKey(iface->class_key); RegCloseKey(iface->class_key);
heap_free(iface->refstr); free(iface->refstr);
heap_free(iface->symlink); free(iface->symlink);
heap_free(iface); free(iface);
} }
/* remove all interfaces associated with the device, including those not /* remove all interfaces associated with the device, including those not
...@@ -822,8 +821,8 @@ static void delete_device(struct device *device) ...@@ -822,8 +821,8 @@ static void delete_device(struct device *device)
} }
RegCloseKey(device->key); RegCloseKey(device->key);
heap_free(device->instanceId); free(device->instanceId);
heap_free(device->drivers); free(device->drivers);
LIST_FOR_EACH_ENTRY_SAFE(iface, next, &device->interfaces, LIST_FOR_EACH_ENTRY_SAFE(iface, next, &device->interfaces,
struct device_iface, entry) struct device_iface, entry)
...@@ -832,7 +831,7 @@ static void delete_device(struct device *device) ...@@ -832,7 +831,7 @@ static void delete_device(struct device *device)
} }
free_devnode(device->devnode); free_devnode(device->devnode);
list_remove(&device->entry); list_remove(&device->entry);
heap_free(device); free(device);
} }
/* Create a new device, or return a device already in the set. */ /* Create a new device, or return a device already in the set. */
...@@ -857,16 +856,16 @@ static struct device *create_device(struct DeviceInfoSet *set, ...@@ -857,16 +856,16 @@ static struct device *create_device(struct DeviceInfoSet *set,
} }
} }
if (!(device = heap_alloc_zero(sizeof(*device)))) if (!(device = calloc(1, sizeof(*device))))
{ {
SetLastError(ERROR_OUTOFMEMORY); SetLastError(ERROR_OUTOFMEMORY);
return NULL; return NULL;
} }
if (!(device->instanceId = strdupW(instanceid))) if (!(device->instanceId = wcsdup(instanceid)))
{ {
SetLastError(ERROR_OUTOFMEMORY); SetLastError(ERROR_OUTOFMEMORY);
heap_free(device); free(device);
return NULL; return NULL;
} }
...@@ -1497,7 +1496,7 @@ SetupDiCreateDeviceInfoListExW(const GUID *ClassGuid, ...@@ -1497,7 +1496,7 @@ SetupDiCreateDeviceInfoListExW(const GUID *ClassGuid,
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} }
list = HeapAlloc(GetProcessHeap(), 0, size); list = malloc(size);
if (!list) if (!list)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
...@@ -2186,7 +2185,7 @@ HDEVINFO WINAPI SetupDiGetClassDevsA(const GUID *class, LPCSTR enumstr, HWND par ...@@ -2186,7 +2185,7 @@ HDEVINFO WINAPI SetupDiGetClassDevsA(const GUID *class, LPCSTR enumstr, HWND par
if (enumstr) if (enumstr)
{ {
int len = MultiByteToWideChar(CP_ACP, 0, enumstr, -1, NULL, 0); int len = MultiByteToWideChar(CP_ACP, 0, enumstr, -1, NULL, 0);
enumstrW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); enumstrW = malloc(len * sizeof(WCHAR));
if (!enumstrW) if (!enumstrW)
{ {
ret = INVALID_HANDLE_VALUE; ret = INVALID_HANDLE_VALUE;
...@@ -2196,7 +2195,7 @@ HDEVINFO WINAPI SetupDiGetClassDevsA(const GUID *class, LPCSTR enumstr, HWND par ...@@ -2196,7 +2195,7 @@ HDEVINFO WINAPI SetupDiGetClassDevsA(const GUID *class, LPCSTR enumstr, HWND par
} }
ret = SetupDiGetClassDevsExW(class, enumstrW, parent, flags, NULL, NULL, ret = SetupDiGetClassDevsExW(class, enumstrW, parent, flags, NULL, NULL,
NULL); NULL);
HeapFree(GetProcessHeap(), 0, enumstrW); free(enumstrW);
end: end:
return ret; return ret;
...@@ -2220,7 +2219,7 @@ HDEVINFO WINAPI SetupDiGetClassDevsExA( ...@@ -2220,7 +2219,7 @@ HDEVINFO WINAPI SetupDiGetClassDevsExA(
if (enumstr) if (enumstr)
{ {
int len = MultiByteToWideChar(CP_ACP, 0, enumstr, -1, NULL, 0); int len = MultiByteToWideChar(CP_ACP, 0, enumstr, -1, NULL, 0);
enumstrW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); enumstrW = malloc(len * sizeof(WCHAR));
if (!enumstrW) if (!enumstrW)
{ {
ret = INVALID_HANDLE_VALUE; ret = INVALID_HANDLE_VALUE;
...@@ -2231,10 +2230,10 @@ HDEVINFO WINAPI SetupDiGetClassDevsExA( ...@@ -2231,10 +2230,10 @@ HDEVINFO WINAPI SetupDiGetClassDevsExA(
if (machine) if (machine)
{ {
int len = MultiByteToWideChar(CP_ACP, 0, machine, -1, NULL, 0); int len = MultiByteToWideChar(CP_ACP, 0, machine, -1, NULL, 0);
machineW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); machineW = malloc(len * sizeof(WCHAR));
if (!machineW) if (!machineW)
{ {
HeapFree(GetProcessHeap(), 0, enumstrW); free(enumstrW);
ret = INVALID_HANDLE_VALUE; ret = INVALID_HANDLE_VALUE;
goto end; goto end;
} }
...@@ -2242,8 +2241,8 @@ HDEVINFO WINAPI SetupDiGetClassDevsExA( ...@@ -2242,8 +2241,8 @@ HDEVINFO WINAPI SetupDiGetClassDevsExA(
} }
ret = SetupDiGetClassDevsExW(class, enumstrW, parent, flags, deviceset, ret = SetupDiGetClassDevsExW(class, enumstrW, parent, flags, deviceset,
machineW, reserved); machineW, reserved);
HeapFree(GetProcessHeap(), 0, enumstrW); free(enumstrW);
HeapFree(GetProcessHeap(), 0, machineW); free(machineW);
end: end:
return ret; return ret;
...@@ -2543,13 +2542,13 @@ static void SETUPDI_EnumerateDevices(HDEVINFO DeviceInfoSet, const GUID *class, ...@@ -2543,13 +2542,13 @@ static void SETUPDI_EnumerateDevices(HDEVINFO DeviceInfoSet, const GUID *class,
{ {
SETUPDI_EnumerateMatchingDevices(DeviceInfoSet, enumstr, enumStrKey, class, flags); SETUPDI_EnumerateMatchingDevices(DeviceInfoSet, enumstr, enumStrKey, class, flags);
} }
else if ((bus = strdupW(enumstr))) else if ((bus = wcsdup(enumstr)))
{ {
device = wcschr(bus, '\\'); device = wcschr(bus, '\\');
*device++ = 0; *device++ = 0;
SETUPDI_EnumerateMatchingDeviceInstances(DeviceInfoSet, bus, device, enumStrKey, class, flags); SETUPDI_EnumerateMatchingDeviceInstances(DeviceInfoSet, bus, device, enumStrKey, class, flags);
HeapFree(GetProcessHeap(), 0, bus); free(bus);
} }
RegCloseKey(enumStrKey); RegCloseKey(enumStrKey);
...@@ -2965,7 +2964,7 @@ BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo) ...@@ -2965,7 +2964,7 @@ BOOL WINAPI SetupDiDestroyDeviceInfoList(HDEVINFO devinfo)
{ {
delete_device(device); delete_device(device);
} }
heap_free(set); free(set);
SetLastError(ERROR_SUCCESS); SetLastError(ERROR_SUCCESS);
return TRUE; return TRUE;
...@@ -3740,7 +3739,7 @@ static BOOL call_coinstallers(WCHAR *list, DI_FUNCTION function, HDEVINFO devinf ...@@ -3740,7 +3739,7 @@ static BOOL call_coinstallers(WCHAR *list, DI_FUNCTION function, HDEVINFO devinf
{ {
procname = strdupWtoA(procnameW + 1); procname = strdupWtoA(procnameW + 1);
coinst_proc = (void *)GetProcAddress(module, procname); coinst_proc = (void *)GetProcAddress(module, procname);
heap_free(procname); free(procname);
} }
else else
coinst_proc = (void *)GetProcAddress(module, "CoDeviceInstall"); coinst_proc = (void *)GetProcAddress(module, "CoDeviceInstall");
...@@ -3799,10 +3798,10 @@ BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION function, HDEVINFO devinfo, SP ...@@ -3799,10 +3798,10 @@ BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION function, HDEVINFO devinfo, SP
SETUPDI_GuidToString(&device->class, guidstr); SETUPDI_GuidToString(&device->class, guidstr);
if (!RegGetValueW(coinst_key, NULL, guidstr, RRF_RT_REG_MULTI_SZ, NULL, NULL, &size)) if (!RegGetValueW(coinst_key, NULL, guidstr, RRF_RT_REG_MULTI_SZ, NULL, NULL, &size))
{ {
path = heap_alloc(size); path = malloc(size);
if (!RegGetValueW(coinst_key, NULL, guidstr, RRF_RT_REG_MULTI_SZ, NULL, path, &size)) if (!RegGetValueW(coinst_key, NULL, guidstr, RRF_RT_REG_MULTI_SZ, NULL, path, &size))
coret = call_coinstallers(path, function, devinfo, device_data); coret = call_coinstallers(path, function, devinfo, device_data);
heap_free(path); free(path);
} }
RegCloseKey(coinst_key); RegCloseKey(coinst_key);
} }
...@@ -3814,10 +3813,10 @@ BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION function, HDEVINFO devinfo, SP ...@@ -3814,10 +3813,10 @@ BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION function, HDEVINFO devinfo, SP
{ {
if (!RegGetValueW(coinst_key, NULL, coinstallers32W, RRF_RT_REG_MULTI_SZ, NULL, NULL, &size)) if (!RegGetValueW(coinst_key, NULL, coinstallers32W, RRF_RT_REG_MULTI_SZ, NULL, NULL, &size))
{ {
path = heap_alloc(size); path = malloc(size);
if (!RegGetValueW(coinst_key, NULL, coinstallers32W, RRF_RT_REG_MULTI_SZ, NULL, path, &size)) if (!RegGetValueW(coinst_key, NULL, coinstallers32W, RRF_RT_REG_MULTI_SZ, NULL, path, &size))
coret = call_coinstallers(path, function, devinfo, device_data); coret = call_coinstallers(path, function, devinfo, device_data);
heap_free(path); free(path);
} }
RegCloseKey(coinst_key); RegCloseKey(coinst_key);
} }
...@@ -3826,7 +3825,7 @@ BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION function, HDEVINFO devinfo, SP ...@@ -3826,7 +3825,7 @@ BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION function, HDEVINFO devinfo, SP
{ {
if (!RegGetValueW(class_key, NULL, installer32W, RRF_RT_REG_SZ, NULL, NULL, &size)) if (!RegGetValueW(class_key, NULL, installer32W, RRF_RT_REG_SZ, NULL, NULL, &size))
{ {
path = heap_alloc(size); path = malloc(size);
if (!RegGetValueW(class_key, NULL, installer32W, RRF_RT_REG_SZ, NULL, path, &size)) if (!RegGetValueW(class_key, NULL, installer32W, RRF_RT_REG_SZ, NULL, path, &size))
{ {
TRACE("Found class installer %s.\n", debugstr_w(path)); TRACE("Found class installer %s.\n", debugstr_w(path));
...@@ -3839,7 +3838,7 @@ BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION function, HDEVINFO devinfo, SP ...@@ -3839,7 +3838,7 @@ BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION function, HDEVINFO devinfo, SP
{ {
procname = strdupWtoA(procnameW + 1); procname = strdupWtoA(procnameW + 1);
classinst_proc = (void *)GetProcAddress(module, procname); classinst_proc = (void *)GetProcAddress(module, procname);
heap_free(procname); free(procname);
} }
else else
classinst_proc = (void *)GetProcAddress(module, "ClassInstall"); classinst_proc = (void *)GetProcAddress(module, "ClassInstall");
...@@ -3852,7 +3851,7 @@ BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION function, HDEVINFO devinfo, SP ...@@ -3852,7 +3851,7 @@ BOOL WINAPI SetupDiCallClassInstaller(DI_FUNCTION function, HDEVINFO devinfo, SP
FreeLibrary(module); FreeLibrary(module);
} }
} }
heap_free(path); free(path);
} }
RegCloseKey(class_key); RegCloseKey(class_key);
} }
...@@ -4249,7 +4248,7 @@ BOOL WINAPI SetupDiGetINFClassA(PCSTR inf, LPGUID class_guid, PSTR class_name, ...@@ -4249,7 +4248,7 @@ BOOL WINAPI SetupDiGetINFClassA(PCSTR inf, LPGUID class_guid, PSTR class_name,
if (class_name && size) if (class_name && size)
{ {
if (!(class_nameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)))) if (!(class_nameW = malloc(size * sizeof(WCHAR))))
{ {
RtlFreeUnicodeString(&infW); RtlFreeUnicodeString(&infW);
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
...@@ -4269,7 +4268,7 @@ BOOL WINAPI SetupDiGetINFClassA(PCSTR inf, LPGUID class_guid, PSTR class_name, ...@@ -4269,7 +4268,7 @@ BOOL WINAPI SetupDiGetINFClassA(PCSTR inf, LPGUID class_guid, PSTR class_name,
else else
if(required_size) *required_size = required_sizeW; if(required_size) *required_size = required_sizeW;
HeapFree(GetProcessHeap(), 0, class_nameW); free(class_nameW);
RtlFreeUnicodeString(&infW); RtlFreeUnicodeString(&infW);
return retval; return retval;
} }
...@@ -4607,7 +4606,7 @@ static BOOL device_matches_id(const struct device *device, const WCHAR *id_type, ...@@ -4607,7 +4606,7 @@ static BOOL device_matches_id(const struct device *device, const WCHAR *id_type,
if (!RegGetValueW(device->key, NULL, id_type, RRF_RT_REG_MULTI_SZ, NULL, NULL, &size)) if (!RegGetValueW(device->key, NULL, id_type, RRF_RT_REG_MULTI_SZ, NULL, NULL, &size))
{ {
device_ids = heap_alloc(size); device_ids = malloc(size);
if (!RegGetValueW(device->key, NULL, id_type, RRF_RT_REG_MULTI_SZ, NULL, device_ids, &size)) if (!RegGetValueW(device->key, NULL, id_type, RRF_RT_REG_MULTI_SZ, NULL, device_ids, &size))
{ {
for (p = device_ids, i = 0; *p; p += lstrlenW(p) + 1, i++) for (p = device_ids, i = 0; *p; p += lstrlenW(p) + 1, i++)
...@@ -4615,12 +4614,12 @@ static BOOL device_matches_id(const struct device *device, const WCHAR *id_type, ...@@ -4615,12 +4614,12 @@ static BOOL device_matches_id(const struct device *device, const WCHAR *id_type,
if (!wcsicmp(p, id)) if (!wcsicmp(p, id))
{ {
*driver_rank += min(i, 0xff); *driver_rank += min(i, 0xff);
heap_free(device_ids); free(device_ids);
return TRUE; return TRUE;
} }
} }
} }
heap_free(device_ids); free(device_ids);
} }
return FALSE; return FALSE;
...@@ -4718,7 +4717,7 @@ static void enum_compat_drivers_from_file(struct device *device, const WCHAR *pa ...@@ -4718,7 +4717,7 @@ static void enum_compat_drivers_from_file(struct device *device, const WCHAR *pa
driver.rank, debugstr_w(driver.manufacturer), debugstr_w(driver.description)); driver.rank, debugstr_w(driver.manufacturer), debugstr_w(driver.description));
driver_count++; driver_count++;
drivers = heap_realloc(drivers, driver_count * sizeof(*drivers)); drivers = realloc(drivers, driver_count * sizeof(*drivers));
drivers[driver_count - 1] = driver; drivers[driver_count - 1] = driver;
} }
} }
......
...@@ -130,7 +130,7 @@ static void promptdisk_browse(HWND hwnd, struct promptdisk_params *params) ...@@ -130,7 +130,7 @@ static void promptdisk_browse(HWND hwnd, struct promptdisk_params *params)
ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
ofn.hwndOwner = hwnd; ofn.hwndOwner = hwnd;
ofn.nMaxFile = MAX_PATH; ofn.nMaxFile = MAX_PATH;
ofn.lpstrFile = HeapAlloc(GetProcessHeap(), 0, MAX_PATH*sizeof(WCHAR)); ofn.lpstrFile = malloc(MAX_PATH * sizeof(WCHAR));
lstrcpyW(ofn.lpstrFile, params->FileSought); lstrcpyW(ofn.lpstrFile, params->FileSought);
if(GetOpenFileNameW(&ofn)) if(GetOpenFileNameW(&ofn))
...@@ -139,7 +139,7 @@ static void promptdisk_browse(HWND hwnd, struct promptdisk_params *params) ...@@ -139,7 +139,7 @@ static void promptdisk_browse(HWND hwnd, struct promptdisk_params *params)
if (last_slash) *last_slash = 0; if (last_slash) *last_slash = 0;
SetDlgItemTextW(hwnd, IDC_PATH, ofn.lpstrFile); SetDlgItemTextW(hwnd, IDC_PATH, ofn.lpstrFile);
} }
HeapFree(GetProcessHeap(), 0, ofn.lpstrFile); free(ofn.lpstrFile);
} }
/* Handles the messages sent to the SetupPromptForDisk dialog /* Handles the messages sent to the SetupPromptForDisk dialog
...@@ -201,11 +201,11 @@ UINT WINAPI SetupPromptForDiskA(HWND hwndParent, PCSTR DialogTitle, PCSTR DiskNa ...@@ -201,11 +201,11 @@ UINT WINAPI SetupPromptForDiskA(HWND hwndParent, PCSTR DialogTitle, PCSTR DiskNa
ret = SetupPromptForDiskW(hwndParent, DialogTitleW, DiskNameW, PathToSourceW, ret = SetupPromptForDiskW(hwndParent, DialogTitleW, DiskNameW, PathToSourceW,
FileSoughtW, TagFileW, DiskPromptStyle, PathBufferW, MAX_PATH, PathRequiredSize); FileSoughtW, TagFileW, DiskPromptStyle, PathBufferW, MAX_PATH, PathRequiredSize);
HeapFree(GetProcessHeap(), 0, DialogTitleW); free(DialogTitleW);
HeapFree(GetProcessHeap(), 0, DiskNameW); free(DiskNameW);
HeapFree(GetProcessHeap(), 0, PathToSourceW); free(PathToSourceW);
HeapFree(GetProcessHeap(), 0, FileSoughtW); free(FileSoughtW);
HeapFree(GetProcessHeap(), 0, TagFileW); free(TagFileW);
if(ret == DPROMPT_SUCCESS) if(ret == DPROMPT_SUCCESS)
{ {
......
...@@ -72,7 +72,7 @@ static const WCHAR *get_unknown_dirid(void) ...@@ -72,7 +72,7 @@ static const WCHAR *get_unknown_dirid(void)
if (!unknown_dirid) if (!unknown_dirid)
{ {
UINT len = GetSystemDirectoryW( NULL, 0 ) + lstrlenW(L"\\unknown"); UINT len = GetSystemDirectoryW( NULL, 0 ) + lstrlenW(L"\\unknown");
if (!(unknown_dirid = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL; if (!(unknown_dirid = malloc( len * sizeof(WCHAR) ))) return NULL;
GetSystemDirectoryW( unknown_dirid, len ); GetSystemDirectoryW( unknown_dirid, len );
lstrcatW( unknown_dirid, L"\\unknown" ); lstrcatW( unknown_dirid, L"\\unknown" );
} }
...@@ -155,7 +155,7 @@ static const WCHAR *create_system_dirid( int dirid ) ...@@ -155,7 +155,7 @@ static const WCHAR *create_system_dirid( int dirid )
return get_unknown_dirid(); return get_unknown_dirid();
} }
len = (lstrlenW(buffer) + 1) * sizeof(WCHAR); len = (lstrlenW(buffer) + 1) * sizeof(WCHAR);
if ((str = HeapAlloc( GetProcessHeap(), 0, len ))) memcpy( str, buffer, len ); if ((str = malloc( len ))) memcpy( str, buffer, len );
return str; return str;
} }
...@@ -184,7 +184,7 @@ static const WCHAR *create_printer_dirid( DWORD dirid ) ...@@ -184,7 +184,7 @@ static const WCHAR *create_printer_dirid( DWORD dirid )
return get_unknown_dirid(); return get_unknown_dirid();
} }
len = (lstrlenW(buffer) + 1) * sizeof(WCHAR); len = (lstrlenW(buffer) + 1) * sizeof(WCHAR);
if ((str = HeapAlloc( GetProcessHeap(), 0, len ))) memcpy( str, buffer, len ); if ((str = malloc( len ))) memcpy( str, buffer, len );
return str; return str;
} }
...@@ -199,7 +199,7 @@ static const WCHAR *get_csidl_dir( DWORD csidl ) ...@@ -199,7 +199,7 @@ static const WCHAR *get_csidl_dir( DWORD csidl )
return get_unknown_dirid(); return get_unknown_dirid();
} }
len = (lstrlenW(buffer) + 1) * sizeof(WCHAR); len = (lstrlenW(buffer) + 1) * sizeof(WCHAR);
if ((str = HeapAlloc( GetProcessHeap(), 0, len ))) memcpy( str, buffer, len ); if ((str = malloc( len ))) memcpy( str, buffer, len );
return str; return str;
} }
...@@ -244,22 +244,13 @@ static BOOL store_user_dirid( HINF hinf, int id, WCHAR *str ) ...@@ -244,22 +244,13 @@ static BOOL store_user_dirid( HINF hinf, int id, WCHAR *str )
for (i = 0; i < nb_user_dirids; i++) if (user_dirids[i].id == id) break; for (i = 0; i < nb_user_dirids; i++) if (user_dirids[i].id == id) break;
if (i < nb_user_dirids) HeapFree( GetProcessHeap(), 0, user_dirids[i].str ); if (i < nb_user_dirids) free( user_dirids[i].str );
else else
{ {
if (nb_user_dirids >= alloc_user_dirids) if (nb_user_dirids >= alloc_user_dirids)
{ {
int new_size = max( 32, alloc_user_dirids * 2 ); int new_size = max( 32, alloc_user_dirids * 2 );
struct user_dirid *new = realloc( user_dirids, new_size * sizeof(*new) );
struct user_dirid *new;
if (user_dirids)
new = HeapReAlloc( GetProcessHeap(), 0, user_dirids,
new_size * sizeof(*new) );
else
new = HeapAlloc( GetProcessHeap(), 0,
new_size * sizeof(*new) );
if (!new) return FALSE; if (!new) return FALSE;
user_dirids = new; user_dirids = new;
alloc_user_dirids = new_size; alloc_user_dirids = new_size;
...@@ -283,7 +274,7 @@ BOOL WINAPI SetupSetDirectoryIdA( HINF hinf, DWORD id, PCSTR dir ) ...@@ -283,7 +274,7 @@ BOOL WINAPI SetupSetDirectoryIdA( HINF hinf, DWORD id, PCSTR dir )
if (!id) /* clear everything */ if (!id) /* clear everything */
{ {
for (i = 0; i < nb_user_dirids; i++) HeapFree( GetProcessHeap(), 0, user_dirids[i].str ); for (i = 0; i < nb_user_dirids; i++) free( user_dirids[i].str );
nb_user_dirids = 0; nb_user_dirids = 0;
return TRUE; return TRUE;
} }
...@@ -313,7 +304,7 @@ BOOL WINAPI SetupSetDirectoryIdW( HINF hinf, DWORD id, PCWSTR dir ) ...@@ -313,7 +304,7 @@ BOOL WINAPI SetupSetDirectoryIdW( HINF hinf, DWORD id, PCWSTR dir )
if (!id) /* clear everything */ if (!id) /* clear everything */
{ {
for (i = 0; i < nb_user_dirids; i++) HeapFree( GetProcessHeap(), 0, user_dirids[i].str ); for (i = 0; i < nb_user_dirids; i++) free( user_dirids[i].str );
nb_user_dirids = 0; nb_user_dirids = 0;
return TRUE; return TRUE;
} }
...@@ -325,7 +316,7 @@ BOOL WINAPI SetupSetDirectoryIdW( HINF hinf, DWORD id, PCWSTR dir ) ...@@ -325,7 +316,7 @@ BOOL WINAPI SetupSetDirectoryIdW( HINF hinf, DWORD id, PCWSTR dir )
/* duplicate the string */ /* duplicate the string */
len = (lstrlenW(dir)+1) * sizeof(WCHAR); len = (lstrlenW(dir)+1) * sizeof(WCHAR);
if (!(str = HeapAlloc( GetProcessHeap(), 0, len ))) return FALSE; if (!(str = malloc( len ))) return FALSE;
memcpy( str, dir, len ); memcpy( str, dir, len );
return store_user_dirid( hinf, id, str ); return store_user_dirid( hinf, id, str );
} }
...@@ -66,7 +66,7 @@ HDSKSPC WINAPI SetupCreateDiskSpaceListW(PVOID Reserved1, DWORD Reserved2, UINT ...@@ -66,7 +66,7 @@ HDSKSPC WINAPI SetupCreateDiskSpaceListW(PVOID Reserved1, DWORD Reserved2, UINT
if (rc == 0) if (rc == 0)
return NULL; return NULL;
list = HeapAlloc(GetProcessHeap(),0,sizeof(DISKSPACELIST)); list = malloc(sizeof(DISKSPACELIST));
list->dwDriveCount = 0; list->dwDriveCount = 0;
...@@ -121,7 +121,7 @@ HDSKSPC WINAPI SetupDuplicateDiskSpaceListW(HDSKSPC DiskSpace, PVOID Reserved1, ...@@ -121,7 +121,7 @@ HDSKSPC WINAPI SetupDuplicateDiskSpaceListW(HDSKSPC DiskSpace, PVOID Reserved1,
return NULL; return NULL;
} }
list_copy = HeapAlloc(GetProcessHeap(), 0, sizeof(DISKSPACELIST)); list_copy = malloc(sizeof(DISKSPACELIST));
if (!list_copy) if (!list_copy)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
...@@ -177,7 +177,7 @@ BOOL WINAPI SetupQuerySpaceRequiredOnDriveW(HDSKSPC DiskSpace, ...@@ -177,7 +177,7 @@ BOOL WINAPI SetupQuerySpaceRequiredOnDriveW(HDSKSPC DiskSpace,
return FALSE; return FALSE;
} }
driveW = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(DriveSpec) + 2) * sizeof(WCHAR)); driveW = malloc((wcslen(DriveSpec) + 2) * sizeof(WCHAR));
if (!driveW) if (!driveW)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
...@@ -200,7 +200,7 @@ BOOL WINAPI SetupQuerySpaceRequiredOnDriveW(HDSKSPC DiskSpace, ...@@ -200,7 +200,7 @@ BOOL WINAPI SetupQuerySpaceRequiredOnDriveW(HDSKSPC DiskSpace,
} }
} }
HeapFree(GetProcessHeap(), 0, driveW); free(driveW);
if (!rc) SetLastError(ERROR_INVALID_DRIVE); if (!rc) SetLastError(ERROR_INVALID_DRIVE);
return rc; return rc;
...@@ -233,7 +233,7 @@ BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace, ...@@ -233,7 +233,7 @@ BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace,
len = MultiByteToWideChar(CP_ACP, 0, DriveSpec, -1, NULL, 0); len = MultiByteToWideChar(CP_ACP, 0, DriveSpec, -1, NULL, 0);
DriveSpecW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); DriveSpecW = malloc(len * sizeof(WCHAR));
if (!DriveSpecW) if (!DriveSpecW)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
...@@ -245,7 +245,7 @@ BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace, ...@@ -245,7 +245,7 @@ BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace,
ret = SetupQuerySpaceRequiredOnDriveW(DiskSpace, DriveSpecW, SpaceRequired, ret = SetupQuerySpaceRequiredOnDriveW(DiskSpace, DriveSpecW, SpaceRequired,
Reserved1, Reserved2); Reserved1, Reserved2);
HeapFree(GetProcessHeap(), 0, DriveSpecW); free(DriveSpecW);
return ret; return ret;
} }
...@@ -256,8 +256,8 @@ BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace, ...@@ -256,8 +256,8 @@ BOOL WINAPI SetupQuerySpaceRequiredOnDriveA(HDSKSPC DiskSpace,
BOOL WINAPI SetupDestroyDiskSpaceList(HDSKSPC DiskSpace) BOOL WINAPI SetupDestroyDiskSpaceList(HDSKSPC DiskSpace)
{ {
LPDISKSPACELIST list = DiskSpace; LPDISKSPACELIST list = DiskSpace;
HeapFree(GetProcessHeap(),0,list); free(list);
return TRUE; return TRUE;
} }
/*********************************************************************** /***********************************************************************
......
...@@ -147,9 +147,7 @@ static BOOL add_handled_dll( const WCHAR *name ) ...@@ -147,9 +147,7 @@ static BOOL add_handled_dll( const WCHAR *name )
WCHAR **new_dlls; WCHAR **new_dlls;
unsigned int new_count = max( 64, handled_total * 2 ); unsigned int new_count = max( 64, handled_total * 2 );
if (handled_dlls) new_dlls = HeapReAlloc( GetProcessHeap(), 0, handled_dlls, new_dlls = realloc( handled_dlls, new_count * sizeof(*handled_dlls) );
new_count * sizeof(*handled_dlls) );
else new_dlls = HeapAlloc( GetProcessHeap(), 0, new_count * sizeof(*handled_dlls) );
if (!new_dlls) return FALSE; if (!new_dlls) return FALSE;
handled_dlls = new_dlls; handled_dlls = new_dlls;
handled_total = new_count; handled_total = new_count;
...@@ -275,7 +273,7 @@ static BOOL build_fake_dll( HANDLE file, const WCHAR *name ) ...@@ -275,7 +273,7 @@ static BOOL build_fake_dll( HANDLE file, const WCHAR *name )
DWORD size, header_size = lfanew + sizeof(*nt); DWORD size, header_size = lfanew + sizeof(*nt);
info.handle = file; info.handle = file;
buffer = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, header_size + 8 * sizeof(IMAGE_SECTION_HEADER) ); buffer = calloc( 1, header_size + 8 * sizeof(IMAGE_SECTION_HEADER) );
dos = (IMAGE_DOS_HEADER *)buffer; dos = (IMAGE_DOS_HEADER *)buffer;
dos->e_magic = IMAGE_DOS_SIGNATURE; dos->e_magic = IMAGE_DOS_SIGNATURE;
...@@ -361,7 +359,7 @@ static BOOL build_fake_dll( HANDLE file, const WCHAR *name ) ...@@ -361,7 +359,7 @@ static BOOL build_fake_dll( HANDLE file, const WCHAR *name )
nt->OptionalHeader.SizeOfImage = ALIGN( info.mem_pos, section_alignment ); nt->OptionalHeader.SizeOfImage = ALIGN( info.mem_pos, section_alignment );
ret = xwrite( &info, buffer, header_size, 0 ); ret = xwrite( &info, buffer, header_size, 0 );
done: done:
HeapFree( GetProcessHeap(), 0, buffer ); free( buffer );
return ret; return ret;
} }
...@@ -387,7 +385,7 @@ static void create_directories( const WCHAR *name ) ...@@ -387,7 +385,7 @@ static void create_directories( const WCHAR *name )
WCHAR *path, *p; WCHAR *path, *p;
/* create the directory/directories */ /* create the directory/directories */
path = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name) + 1)*sizeof(WCHAR)); path = malloc((wcslen(name) + 1) * sizeof(WCHAR));
lstrcpyW(path, name); lstrcpyW(path, name);
p = wcschr(path, '\\'); p = wcschr(path, '\\');
...@@ -399,7 +397,7 @@ static void create_directories( const WCHAR *name ) ...@@ -399,7 +397,7 @@ static void create_directories( const WCHAR *name )
*p = '\\'; *p = '\\';
p = wcschr(p+1, '\\'); p = wcschr(p+1, '\\');
} }
HeapFree(GetProcessHeap(), 0, path); free(path);
} }
static inline WCHAR *prepend( WCHAR *buffer, const WCHAR *str, size_t len ) static inline WCHAR *prepend( WCHAR *buffer, const WCHAR *str, size_t len )
...@@ -448,7 +446,7 @@ static void *load_fake_dll( const WCHAR *name, SIZE_T *size ) ...@@ -448,7 +446,7 @@ static void *load_fake_dll( const WCHAR *name, SIZE_T *size )
while ((path = enum_load_path( i++ ))) maxlen = max( maxlen, lstrlenW(path) ); while ((path = enum_load_path( i++ ))) maxlen = max( maxlen, lstrlenW(path) );
maxlen += ARRAY_SIZE(pe_dir) + len + 1; maxlen += ARRAY_SIZE(pe_dir) + len + 1;
if (!(file = HeapAlloc( GetProcessHeap(), 0, maxlen * sizeof(WCHAR) ))) return NULL; if (!(file = malloc( maxlen * sizeof(WCHAR) ))) return NULL;
pos = maxlen - len - 1; pos = maxlen - len - 1;
lstrcpyW( file + pos, name ); lstrcpyW( file + pos, name );
...@@ -478,7 +476,7 @@ static void *load_fake_dll( const WCHAR *name, SIZE_T *size ) ...@@ -478,7 +476,7 @@ static void *load_fake_dll( const WCHAR *name, SIZE_T *size )
} }
done: done:
HeapFree( GetProcessHeap(), 0, file ); free( file );
if (res == 1) return data; if (res == 1) return data;
return NULL; return NULL;
} }
...@@ -667,7 +665,7 @@ static WCHAR* create_winsxs_dll_path( const xmlstr_t *arch, const xmlstr_t *name ...@@ -667,7 +665,7 @@ static WCHAR* create_winsxs_dll_path( const xmlstr_t *arch, const xmlstr_t *name
path_len = GetWindowsDirectoryW( NULL, 0 ) + ARRAY_SIZE( L"\\winsxs\\" ) path_len = GetWindowsDirectoryW( NULL, 0 ) + ARRAY_SIZE( L"\\winsxs\\" )
+ arch->len + name->len + key->len + version->len + 19; + arch->len + name->len + key->len + version->len + 19;
path = HeapAlloc( GetProcessHeap(), 0, path_len * sizeof(WCHAR) ); path = malloc( path_len * sizeof(WCHAR) );
GetWindowsDirectoryW( path, path_len ); GetWindowsDirectoryW( path, path_len );
lstrcatW( path, L"\\winsxs\\" ); lstrcatW( path, L"\\winsxs\\" );
append_manifest_filename( arch, name, key, version, lang, path, path_len ); append_manifest_filename( arch, name, key, version, lang, path, path_len );
...@@ -686,7 +684,7 @@ static BOOL create_manifest( const xmlstr_t *arch, const xmlstr_t *name, const x ...@@ -686,7 +684,7 @@ static BOOL create_manifest( const xmlstr_t *arch, const xmlstr_t *name, const x
path_len = GetWindowsDirectoryW( NULL, 0 ) + ARRAY_SIZE( L"\\winsxs\\manifests\\" ) path_len = GetWindowsDirectoryW( NULL, 0 ) + ARRAY_SIZE( L"\\winsxs\\manifests\\" )
+ arch->len + name->len + key->len + version->len + 18 + ARRAY_SIZE( L".manifest" ); + arch->len + name->len + key->len + version->len + 18 + ARRAY_SIZE( L".manifest" );
path = HeapAlloc( GetProcessHeap(), 0, path_len * sizeof(WCHAR) ); path = malloc( path_len * sizeof(WCHAR) );
GetWindowsDirectoryW( path, path_len ); GetWindowsDirectoryW( path, path_len );
lstrcatW( path, L"\\winsxs\\manifests\\" ); lstrcatW( path, L"\\winsxs\\manifests\\" );
append_manifest_filename( arch, name, key, version, lang, path, path_len ); append_manifest_filename( arch, name, key, version, lang, path, path_len );
...@@ -706,7 +704,7 @@ static BOOL create_manifest( const xmlstr_t *arch, const xmlstr_t *name, const x ...@@ -706,7 +704,7 @@ static BOOL create_manifest( const xmlstr_t *arch, const xmlstr_t *name, const x
CloseHandle( handle ); CloseHandle( handle );
if (!ret) DeleteFileW( path ); if (!ret) DeleteFileW( path );
} }
HeapFree( GetProcessHeap(), 0, path ); free( path );
return ret; return ret;
} }
...@@ -764,9 +762,8 @@ static BOOL CALLBACK register_manifest( HMODULE module, const WCHAR *type, WCHAR ...@@ -764,9 +762,8 @@ static BOOL CALLBACK register_manifest( HMODULE module, const WCHAR *type, WCHAR
if (!error && dest && name.ptr) if (!error && dest && name.ptr)
{ {
struct delay_copy *add = HeapAlloc( GetProcessHeap(), 0, struct delay_copy *add = malloc( sizeof(*add) +
sizeof(*add) + (dll_data->src_len + name.len + (dll_data->src_len + name.len + dest_len + name.len + 1) * sizeof(WCHAR) );
dest_len + name.len + 1) * sizeof(WCHAR) );
add->src = add->data; add->src = add->data;
memcpy( add->src, dll_data->src_dir, dll_data->src_len * sizeof(WCHAR) ); memcpy( add->src, dll_data->src_dir, dll_data->src_len * sizeof(WCHAR) );
MultiByteToWideChar( CP_UTF8, 0, name.ptr, name.len, MultiByteToWideChar( CP_UTF8, 0, name.ptr, name.len,
...@@ -783,7 +780,7 @@ static BOOL CALLBACK register_manifest( HMODULE module, const WCHAR *type, WCHAR ...@@ -783,7 +780,7 @@ static BOOL CALLBACK register_manifest( HMODULE module, const WCHAR *type, WCHAR
} }
if (!xmlstr_cmp( &elem, "assemblyIdentity" )) continue; if (!xmlstr_cmp( &elem, "assemblyIdentity" )) continue;
HeapFree( GetProcessHeap(), 0, dest ); free( dest );
dest = NULL; dest = NULL;
while (next_xml_attr( &buffer, &attr_name, &attr_value, &error )) while (next_xml_attr( &buffer, &attr_name, &attr_value, &error ))
{ {
...@@ -802,7 +799,7 @@ static BOOL CALLBACK register_manifest( HMODULE module, const WCHAR *type, WCHAR ...@@ -802,7 +799,7 @@ static BOOL CALLBACK register_manifest( HMODULE module, const WCHAR *type, WCHAR
} }
if (!arch.len) /* fixup the architecture */ if (!arch.len) /* fixup the architecture */
{ {
char *new_buffer = HeapAlloc( GetProcessHeap(), 0, len + sizeof(current_arch) ); char *new_buffer = malloc( len + sizeof(current_arch) );
memcpy( new_buffer, manifest, arch.ptr - manifest ); memcpy( new_buffer, manifest, arch.ptr - manifest );
strcpy( new_buffer + (arch.ptr - manifest), current_arch ); strcpy( new_buffer + (arch.ptr - manifest), current_arch );
memcpy( new_buffer + strlen(new_buffer), arch.ptr, len - (arch.ptr - manifest) ); memcpy( new_buffer + strlen(new_buffer), arch.ptr, len - (arch.ptr - manifest) );
...@@ -810,7 +807,7 @@ static BOOL CALLBACK register_manifest( HMODULE module, const WCHAR *type, WCHAR ...@@ -810,7 +807,7 @@ static BOOL CALLBACK register_manifest( HMODULE module, const WCHAR *type, WCHAR
arch.len = strlen( current_arch ); arch.len = strlen( current_arch );
dest = create_winsxs_dll_path( &arch, &name, &key, &version, &lang ); dest = create_winsxs_dll_path( &arch, &name, &key, &version, &lang );
create_manifest( &arch, &name, &key, &version, &lang, new_buffer, len + arch.len ); create_manifest( &arch, &name, &key, &version, &lang, new_buffer, len + arch.len );
HeapFree( GetProcessHeap(), 0, new_buffer ); free( new_buffer );
} }
else else
{ {
...@@ -820,7 +817,7 @@ static BOOL CALLBACK register_manifest( HMODULE module, const WCHAR *type, WCHAR ...@@ -820,7 +817,7 @@ static BOOL CALLBACK register_manifest( HMODULE module, const WCHAR *type, WCHAR
dest_len = wcslen( dest ); dest_len = wcslen( dest );
} }
} }
HeapFree( GetProcessHeap(), 0, dest ); free( dest );
return TRUE; return TRUE;
} }
...@@ -835,11 +832,11 @@ static BOOL CALLBACK register_resource( HMODULE module, LPCWSTR type, LPWSTR nam ...@@ -835,11 +832,11 @@ static BOOL CALLBACK register_resource( HMODULE module, LPCWSTR type, LPWSTR nam
if (!str) return FALSE; if (!str) return FALSE;
lenW = MultiByteToWideChar( CP_UTF8, 0, str, lenA, NULL, 0 ) + 1; lenW = MultiByteToWideChar( CP_UTF8, 0, str, lenA, NULL, 0 ) + 1;
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, lenW * sizeof(WCHAR) ))) return FALSE; if (!(buffer = malloc( lenW * sizeof(WCHAR) ))) return FALSE;
MultiByteToWideChar( CP_UTF8, 0, str, lenA, buffer, lenW ); MultiByteToWideChar( CP_UTF8, 0, str, lenA, buffer, lenW );
buffer[lenW - 1] = 0; buffer[lenW - 1] = 0;
*hr = IRegistrar_StringRegister( registrar, buffer ); *hr = IRegistrar_StringRegister( registrar, buffer );
HeapFree( GetProcessHeap(), 0, buffer ); free( buffer );
return TRUE; return TRUE;
} }
...@@ -945,7 +942,7 @@ static void delay_copy_files( struct list *delay_copy ) ...@@ -945,7 +942,7 @@ static void delay_copy_files( struct list *delay_copy )
ret = read_file( copy->src, &data, &size ); ret = read_file( copy->src, &data, &size );
if (ret != 1) if (ret != 1)
{ {
HeapFree( GetProcessHeap(), 0, copy ); free( copy );
continue; continue;
} }
...@@ -957,7 +954,7 @@ static void delay_copy_files( struct list *delay_copy ) ...@@ -957,7 +954,7 @@ static void delay_copy_files( struct list *delay_copy )
CloseHandle( h ); CloseHandle( h );
if (!ret) DeleteFileW( copy->dest ); if (!ret) DeleteFileW( copy->dest );
} }
HeapFree( GetProcessHeap(), 0, copy ); free( copy );
} }
} }
...@@ -1012,11 +1009,11 @@ static BOOL create_wildcard_dlls( const WCHAR *dirname, const WCHAR *wildcard, B ...@@ -1012,11 +1009,11 @@ static BOOL create_wildcard_dlls( const WCHAR *dirname, const WCHAR *wildcard, B
if (build_dir) maxlen = lstrlenW(build_dir) + ARRAY_SIZE(L"\\programs") + 1; if (build_dir) maxlen = lstrlenW(build_dir) + ARRAY_SIZE(L"\\programs") + 1;
for (i = 0; (path = enum_load_path(i)); i++) maxlen = max( maxlen, lstrlenW(path) ); for (i = 0; (path = enum_load_path(i)); i++) maxlen = max( maxlen, lstrlenW(path) );
maxlen += 2 * max_dll_name_len + 2 + ARRAY_SIZE(pe_dir) + 10; /* ".dll" */ maxlen += 2 * max_dll_name_len + 2 + ARRAY_SIZE(pe_dir) + 10; /* ".dll" */
if (!(file = HeapAlloc( GetProcessHeap(), 0, maxlen * sizeof(WCHAR) ))) return FALSE; if (!(file = malloc( maxlen * sizeof(WCHAR) ))) return FALSE;
if (!(dest = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(dirname) + max_dll_name_len) * sizeof(WCHAR) ))) if (!(dest = malloc( (wcslen(dirname) + max_dll_name_len) * sizeof(WCHAR) )))
{ {
HeapFree( GetProcessHeap(), 0, file ); free( file );
return FALSE; return FALSE;
} }
lstrcpyW( dest, dirname ); lstrcpyW( dest, dirname );
...@@ -1038,8 +1035,8 @@ static BOOL create_wildcard_dlls( const WCHAR *dirname, const WCHAR *wildcard, B ...@@ -1038,8 +1035,8 @@ static BOOL create_wildcard_dlls( const WCHAR *dirname, const WCHAR *wildcard, B
lstrcpyW( file, path ); lstrcpyW( file, path );
install_lib_dir( dest, file, wildcard, NULL, delete ); install_lib_dir( dest, file, wildcard, NULL, delete );
} }
HeapFree( GetProcessHeap(), 0, file ); free( file );
HeapFree( GetProcessHeap(), 0, dest ); free( dest );
return TRUE; return TRUE;
} }
...@@ -1101,7 +1098,7 @@ void cleanup_fake_dlls(void) ...@@ -1101,7 +1098,7 @@ void cleanup_fake_dlls(void)
{ {
if (file_buffer) VirtualFree( file_buffer, 0, MEM_RELEASE ); if (file_buffer) VirtualFree( file_buffer, 0, MEM_RELEASE );
file_buffer = NULL; file_buffer = NULL;
HeapFree( GetProcessHeap(), 0, handled_dlls ); free( handled_dlls );
handled_dlls = NULL; handled_dlls = NULL;
handled_count = handled_total = 0; handled_count = handled_total = 0;
if (registrar) IRegistrar_Release( registrar ); if (registrar) IRegistrar_Release( registrar );
......
...@@ -86,12 +86,12 @@ static WCHAR *get_field_string( INFCONTEXT *context, DWORD index, WCHAR *buffer, ...@@ -86,12 +86,12 @@ 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;
} }
...@@ -109,7 +109,7 @@ static WCHAR *dup_section_line_field( HINF hinf, const WCHAR *section, const WCH ...@@ -109,7 +109,7 @@ static WCHAR *dup_section_line_field( HINF hinf, const WCHAR *section, const WCH
if (!SetupFindFirstLineW( hinf, section, line, &context )) return NULL; if (!SetupFindFirstLineW( hinf, section, line, &context )) return NULL;
if (!SetupGetStringFieldW( &context, index, NULL, 0, &size )) return NULL; if (!SetupGetStringFieldW( &context, index, NULL, 0, &size )) return NULL;
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return NULL; if (!(buffer = malloc( size * sizeof(WCHAR) ))) return NULL;
if (!SetupGetStringFieldW( &context, index, buffer, size, NULL )) buffer[0] = 0; if (!SetupGetStringFieldW( &context, index, buffer, size, NULL )) buffer[0] = 0;
return buffer; return buffer;
} }
...@@ -261,10 +261,10 @@ static bool append_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *s ...@@ -261,10 +261,10 @@ static bool append_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *s
return false; return false;
} }
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, (size + str_size) * sizeof(WCHAR) ))) return false; if (!(buffer = malloc( (size + str_size) * sizeof(WCHAR) ))) return false;
if (RegQueryValueExW( hkey, value, NULL, NULL, (BYTE *)buffer, &size )) if (RegQueryValueExW( hkey, value, NULL, NULL, (BYTE *)buffer, &size ))
{ {
HeapFree( GetProcessHeap(), 0, buffer ); free( buffer );
return false; return false;
} }
...@@ -291,7 +291,7 @@ static bool append_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *s ...@@ -291,7 +291,7 @@ static bool append_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *s
RegSetValueExW( hkey, value, 0, REG_MULTI_SZ, (BYTE *)buffer, total ); RegSetValueExW( hkey, value, 0, REG_MULTI_SZ, (BYTE *)buffer, total );
} }
HeapFree( GetProcessHeap(), 0, buffer ); free( buffer );
return true; return true;
} }
...@@ -309,7 +309,7 @@ static void delete_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *s ...@@ -309,7 +309,7 @@ static void delete_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *s
if (RegQueryValueExW( hkey, value, NULL, &type, NULL, &size )) return; if (RegQueryValueExW( hkey, value, NULL, &type, NULL, &size )) return;
if (type != REG_MULTI_SZ) return; if (type != REG_MULTI_SZ) return;
/* allocate double the size, one for value before and one for after */ /* allocate double the size, one for value before and one for after */
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size * 2 * sizeof(WCHAR) ))) return; if (!(buffer = malloc( size * 2 * sizeof(WCHAR) ))) return;
if (RegQueryValueExW( hkey, value, NULL, NULL, (BYTE *)buffer, &size )) goto done; if (RegQueryValueExW( hkey, value, NULL, NULL, (BYTE *)buffer, &size )) goto done;
src = buffer; src = buffer;
dst = buffer + size; dst = buffer + size;
...@@ -331,7 +331,7 @@ static void delete_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *s ...@@ -331,7 +331,7 @@ static void delete_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *s
(BYTE *)(buffer + size), dst - (buffer + size) ); (BYTE *)(buffer + size), dst - (buffer + size) );
} }
done: done:
HeapFree( GetProcessHeap(), 0, buffer ); free( buffer );
} }
...@@ -353,10 +353,10 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context ...@@ -353,10 +353,10 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context
WCHAR *str; WCHAR *str;
if (!SetupGetStringFieldW( context, 5, NULL, 0, &size ) || !size) return TRUE; if (!SetupGetStringFieldW( context, 5, NULL, 0, &size ) || !size) return TRUE;
if (!(str = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return FALSE; if (!(str = malloc( size * sizeof(WCHAR) ))) return FALSE;
SetupGetStringFieldW( context, 5, str, size, NULL ); SetupGetStringFieldW( context, 5, str, size, NULL );
delete_multi_sz_value( hkey, value, str ); delete_multi_sz_value( hkey, value, str );
HeapFree( GetProcessHeap(), 0, str ); free( str );
} }
else RegDeleteValueW( hkey, value ); else RegDeleteValueW( hkey, value );
} }
...@@ -398,7 +398,7 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context ...@@ -398,7 +398,7 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context
if (!SetupGetMultiSzFieldW( context, 5, NULL, 0, &size )) size = 0; if (!SetupGetMultiSzFieldW( context, 5, NULL, 0, &size )) size = 0;
if (size) if (size)
{ {
if (!(str = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return FALSE; if (!(str = malloc( size * sizeof(WCHAR) ))) return FALSE;
SetupGetMultiSzFieldW( context, 5, str, size, NULL ); SetupGetMultiSzFieldW( context, 5, str, size, NULL );
} }
if (flags & FLG_ADDREG_APPEND) if (flags & FLG_ADDREG_APPEND)
...@@ -406,10 +406,10 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context ...@@ -406,10 +406,10 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context
if (!str) return TRUE; if (!str) return TRUE;
if (!append_multi_sz_value( hkey, value, str, size )) if (!append_multi_sz_value( hkey, value, str, size ))
{ {
HeapFree( GetProcessHeap(), 0, str ); free( str );
return FALSE; return FALSE;
} }
HeapFree( GetProcessHeap(), 0, str ); free( str );
return TRUE; return TRUE;
} }
/* else fall through to normal string handling */ /* else fall through to normal string handling */
...@@ -419,7 +419,7 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context ...@@ -419,7 +419,7 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context
if (!SetupGetStringFieldW( context, 5, NULL, 0, &size )) size = 0; if (!SetupGetStringFieldW( context, 5, NULL, 0, &size )) size = 0;
if (size) if (size)
{ {
if (!(str = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) return FALSE; if (!(str = malloc( size * sizeof(WCHAR) ))) return FALSE;
SetupGetStringFieldW( context, 5, str, size, NULL ); SetupGetStringFieldW( context, 5, str, size, NULL );
if (type == REG_LINK) size--; /* no terminating null for symlinks */ if (type == REG_LINK) size--; /* no terminating null for symlinks */
} }
...@@ -437,7 +437,7 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context ...@@ -437,7 +437,7 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context
if (str) RegSetValueExW( hkey, value, 0, type, (BYTE *)str, size * sizeof(WCHAR) ); if (str) RegSetValueExW( hkey, value, 0, type, (BYTE *)str, size * sizeof(WCHAR) );
else RegSetValueExW( hkey, value, 0, type, (const BYTE *)L"", sizeof(WCHAR) ); else RegSetValueExW( hkey, value, 0, type, (const BYTE *)L"", sizeof(WCHAR) );
} }
HeapFree( GetProcessHeap(), 0, str ); free( str );
return TRUE; return TRUE;
} }
else /* get the binary data */ else /* get the binary data */
...@@ -447,12 +447,12 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context ...@@ -447,12 +447,12 @@ static BOOL do_reg_operation( HKEY hkey, const WCHAR *value, INFCONTEXT *context
if (!SetupGetBinaryField( context, 5, NULL, 0, &size )) size = 0; if (!SetupGetBinaryField( context, 5, NULL, 0, &size )) size = 0;
if (size) if (size)
{ {
if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return FALSE; if (!(data = malloc( size ))) return FALSE;
TRACE( "setting binary data %s len %ld\n", debugstr_w(value), size ); TRACE( "setting binary data %s len %ld\n", debugstr_w(value), size );
SetupGetBinaryField( context, 5, data, size, NULL ); SetupGetBinaryField( context, 5, data, size, NULL );
} }
RegSetValueExW( hkey, value, 0, type, data, size ); RegSetValueExW( hkey, value, 0, type, data, size );
HeapFree( GetProcessHeap(), 0, data ); free( data );
return TRUE; return TRUE;
} }
} }
...@@ -592,13 +592,13 @@ static BOOL do_register_dll( struct register_dll_info *info, const WCHAR *path, ...@@ -592,13 +592,13 @@ static BOOL do_register_dll( struct register_dll_info *info, const WCHAR *path,
module = NULL; module = NULL;
if (!args) args = L"/RegServer"; if (!args) args = L"/RegServer";
len = lstrlenW(path) + lstrlenW(args) + 4; len = lstrlenW(path) + lstrlenW(args) + 4;
cmd_line = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); cmd_line = malloc( len * sizeof(WCHAR) );
swprintf( cmd_line, len, L"\"%s\" %s", path, args ); swprintf( cmd_line, len, L"\"%s\" %s", path, args );
memset( &startup, 0, sizeof(startup) ); memset( &startup, 0, sizeof(startup) );
startup.cb = sizeof(startup); startup.cb = sizeof(startup);
TRACE( "executing %s\n", debugstr_w(cmd_line) ); TRACE( "executing %s\n", debugstr_w(cmd_line) );
res = CreateProcessW( path, cmd_line, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &process_info ); res = CreateProcessW( path, cmd_line, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &process_info );
HeapFree( GetProcessHeap(), 0, cmd_line ); free( cmd_line );
if (!res) if (!res)
{ {
status.FailureCode = SPREG_LOADLIBRARY; status.FailureCode = SPREG_LOADLIBRARY;
...@@ -672,9 +672,7 @@ done: ...@@ -672,9 +672,7 @@ done:
if (info->modules_count >= info->modules_size) if (info->modules_count >= info->modules_size)
{ {
int new_size = max( 32, info->modules_size * 2 ); int new_size = max( 32, info->modules_size * 2 );
HMODULE *new = info->modules ? HMODULE *new = realloc( info->modules, new_size * sizeof(*new) );
HeapReAlloc( GetProcessHeap(), 0, info->modules, new_size * sizeof(*new) ) :
HeapAlloc( GetProcessHeap(), 0, new_size * sizeof(*new) );
if (new) if (new)
{ {
info->modules_size = new_size; info->modules_size = new_size;
...@@ -714,8 +712,8 @@ static BOOL register_dlls_callback( HINF hinf, PCWSTR field, void *arg ) ...@@ -714,8 +712,8 @@ static BOOL register_dlls_callback( HINF hinf, PCWSTR field, void *arg )
/* get dll name */ /* get dll name */
if (!SetupGetStringFieldW( &context, 3, buffer, ARRAY_SIZE( buffer ), NULL )) if (!SetupGetStringFieldW( &context, 3, buffer, ARRAY_SIZE( buffer ), NULL ))
goto done; goto done;
if (!(p = HeapReAlloc( GetProcessHeap(), 0, path, if (!(p = realloc( path, (lstrlenW(path) + lstrlenW(buffer) + 2) * sizeof(WCHAR) )))
(lstrlenW(path) + lstrlenW(buffer) + 2) * sizeof(WCHAR) ))) goto done; goto done;
path = p; path = p;
p += lstrlenW(p); p += lstrlenW(p);
if (p == path || p[-1] != '\\') *p++ = '\\'; if (p == path || p[-1] != '\\') *p++ = '\\';
...@@ -735,7 +733,7 @@ static BOOL register_dlls_callback( HINF hinf, PCWSTR field, void *arg ) ...@@ -735,7 +733,7 @@ static BOOL register_dlls_callback( HINF hinf, PCWSTR field, void *arg )
ret = do_register_dll( info, path, flags, timeout, args ); ret = do_register_dll( info, path, flags, timeout, args );
done: done:
HeapFree( GetProcessHeap(), 0, path ); free( path );
if (!ret) break; if (!ret) break;
} }
return ret; return ret;
...@@ -762,8 +760,8 @@ static BOOL fake_dlls_callback( HINF hinf, PCWSTR field, void *arg ) ...@@ -762,8 +760,8 @@ static BOOL fake_dlls_callback( HINF hinf, PCWSTR field, void *arg )
/* get dll name */ /* get dll name */
if (!SetupGetStringFieldW( &context, 3, buffer, ARRAY_SIZE( buffer ), NULL )) if (!SetupGetStringFieldW( &context, 3, buffer, ARRAY_SIZE( buffer ), NULL ))
goto done; goto done;
if (!(p = HeapReAlloc( GetProcessHeap(), 0, path, if (!(p = realloc( path, (lstrlenW(path) + lstrlenW(buffer) + 2) * sizeof(WCHAR) )))
(lstrlenW(path) + lstrlenW(buffer) + 2) * sizeof(WCHAR) ))) goto done; goto done;
path = p; path = p;
p += lstrlenW(p); p += lstrlenW(p);
if (p == path || p[-1] != '\\') *p++ = '\\'; if (p == path || p[-1] != '\\') *p++ = '\\';
...@@ -776,7 +774,7 @@ static BOOL fake_dlls_callback( HINF hinf, PCWSTR field, void *arg ) ...@@ -776,7 +774,7 @@ static BOOL fake_dlls_callback( HINF hinf, PCWSTR field, void *arg )
create_fake_dll( path, p ); /* ignore errors */ create_fake_dll( path, p ); /* ignore errors */
done: done:
HeapFree( GetProcessHeap(), 0, path ); free( path );
} }
return TRUE; return TRUE;
} }
...@@ -928,7 +926,7 @@ static BOOL profile_items_callback( HINF hinf, PCWSTR field, void *arg ) ...@@ -928,7 +926,7 @@ static BOOL profile_items_callback( HINF hinf, PCWSTR field, void *arg )
if (dir_len && filename_size) if (dir_len && filename_size)
{ {
cmdline = cmdline_end = HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR) * (dir_len+subdir_size+filename_size+1) ); cmdline = cmdline_end = malloc( sizeof(WCHAR) * (dir_len + subdir_size + filename_size + 1) );
lstrcpyW( cmdline_end, dir ); lstrcpyW( cmdline_end, dir );
cmdline_end += dir_len; cmdline_end += dir_len;
...@@ -965,7 +963,7 @@ static BOOL profile_items_callback( HINF hinf, PCWSTR field, void *arg ) ...@@ -965,7 +963,7 @@ static BOOL profile_items_callback( HINF hinf, PCWSTR field, void *arg )
done: done:
if (SUCCEEDED(initresult)) CoUninitialize(); if (SUCCEEDED(initresult)) CoUninitialize();
HeapFree( GetProcessHeap(), 0, cmdline ); free( cmdline );
} }
return TRUE; return TRUE;
...@@ -1011,7 +1009,7 @@ static BOOL iterate_section_fields( HINF hinf, PCWSTR section, PCWSTR key, ...@@ -1011,7 +1009,7 @@ static BOOL iterate_section_fields( HINF hinf, PCWSTR section, PCWSTR key,
} }
ret = TRUE; ret = TRUE;
done: done:
if (buffer != static_buffer) HeapFree( GetProcessHeap(), 0, buffer ); if (buffer != static_buffer) free( buffer );
return ret; return ret;
} }
...@@ -1166,7 +1164,7 @@ BOOL WINAPI SetupInstallFromInfSectionW( HWND owner, HINF hinf, PCWSTR section, ...@@ -1166,7 +1164,7 @@ BOOL WINAPI SetupInstallFromInfSectionW( HWND owner, HINF hinf, PCWSTR section,
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
CoUninitialize(); CoUninitialize();
HeapFree( GetProcessHeap(), 0, info.modules ); free( info.modules );
if (!ret) return FALSE; if (!ret) return FALSE;
} }
if (flags & SPINST_UNREGSVR) if (flags & SPINST_UNREGSVR)
...@@ -1188,7 +1186,7 @@ BOOL WINAPI SetupInstallFromInfSectionW( HWND owner, HINF hinf, PCWSTR section, ...@@ -1188,7 +1186,7 @@ BOOL WINAPI SetupInstallFromInfSectionW( HWND owner, HINF hinf, PCWSTR section,
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
CoUninitialize(); CoUninitialize();
HeapFree( GetProcessHeap(), 0, info.modules ); free( info.modules );
if (!ret) return FALSE; if (!ret) return FALSE;
} }
if (flags & SPINST_REGISTRY) if (flags & SPINST_REGISTRY)
...@@ -1389,23 +1387,23 @@ static BOOL add_service( SC_HANDLE scm, HINF hinf, const WCHAR *name, const WCHA ...@@ -1389,23 +1387,23 @@ static BOOL add_service( SC_HANDLE scm, HINF hinf, const WCHAR *name, const WCHA
if (!QueryServiceConfigW( service, NULL, 0, &size ) && if (!QueryServiceConfigW( service, NULL, 0, &size ) &&
GetLastError() == ERROR_INSUFFICIENT_BUFFER) GetLastError() == ERROR_INSUFFICIENT_BUFFER)
config = HeapAlloc( GetProcessHeap(), 0, size ); config = malloc( size );
if (config && QueryServiceConfigW( service, config, size, &size )) if (config && QueryServiceConfigW( service, config, size, &size ))
{ {
if (flags & SPSVCINST_NOCLOBBER_STARTTYPE) start_type = config->dwStartType; if (flags & SPSVCINST_NOCLOBBER_STARTTYPE) start_type = config->dwStartType;
if (flags & SPSVCINST_NOCLOBBER_ERRORCONTROL) error_control = config->dwErrorControl; if (flags & SPSVCINST_NOCLOBBER_ERRORCONTROL) error_control = config->dwErrorControl;
if (flags & SPSVCINST_NOCLOBBER_DISPLAYNAME) if (flags & SPSVCINST_NOCLOBBER_DISPLAYNAME)
{ {
HeapFree( GetProcessHeap(), 0, display_name ); free( display_name );
display_name = strdupW( config->lpDisplayName ); display_name = wcsdup( config->lpDisplayName );
} }
if (flags & SPSVCINST_NOCLOBBER_LOADORDERGROUP) if (flags & SPSVCINST_NOCLOBBER_LOADORDERGROUP)
{ {
HeapFree( GetProcessHeap(), 0, load_order ); free( load_order );
load_order = strdupW( config->lpLoadOrderGroup ); load_order = wcsdup( config->lpLoadOrderGroup );
} }
} }
HeapFree( GetProcessHeap(), 0, config ); free( config );
} }
TRACE( "changing %s display %s type %x start %x error %x binary %s loadorder %s startname %s\n", TRACE( "changing %s display %s type %x start %x error %x binary %s loadorder %s startname %s\n",
debugstr_w(name), debugstr_w(display_name), service_type, start_type, error_control, debugstr_w(name), debugstr_w(display_name), service_type, start_type, error_control,
...@@ -1441,11 +1439,11 @@ static BOOL add_service( SC_HANDLE scm, HINF hinf, const WCHAR *name, const WCHA ...@@ -1441,11 +1439,11 @@ static BOOL add_service( SC_HANDLE scm, HINF hinf, const WCHAR *name, const WCHA
done: done:
if (!service) WARN( "failed err %lu\n", GetLastError() ); if (!service) WARN( "failed err %lu\n", GetLastError() );
HeapFree( GetProcessHeap(), 0, binary_path ); free( binary_path );
HeapFree( GetProcessHeap(), 0, display_name ); free( display_name );
HeapFree( GetProcessHeap(), 0, start_name ); free( start_name );
HeapFree( GetProcessHeap(), 0, load_order ); free( load_order );
HeapFree( GetProcessHeap(), 0, descr.lpDescription ); free( descr.lpDescription );
return service != 0; return service != 0;
} }
...@@ -1562,7 +1560,7 @@ BOOL WINAPI SetupGetInfFileListA(PCSTR dir, DWORD style, PSTR buffer, ...@@ -1562,7 +1560,7 @@ BOOL WINAPI SetupGetInfFileListA(PCSTR dir, DWORD style, PSTR buffer,
dirW.Buffer = NULL; dirW.Buffer = NULL;
if ( buffer ) if ( buffer )
bufferW = HeapAlloc( GetProcessHeap(), 0, insize * sizeof( WCHAR )); bufferW = malloc( insize * sizeof( WCHAR ));
ret = SetupGetInfFileListW( dirW.Buffer, style, bufferW, insize, &outsizeW); ret = SetupGetInfFileListW( dirW.Buffer, style, bufferW, insize, &outsizeW);
...@@ -1573,7 +1571,7 @@ BOOL WINAPI SetupGetInfFileListA(PCSTR dir, DWORD style, PSTR buffer, ...@@ -1573,7 +1571,7 @@ BOOL WINAPI SetupGetInfFileListA(PCSTR dir, DWORD style, PSTR buffer,
if ( outsize ) *outsize = outsizeA; if ( outsize ) *outsize = outsizeA;
} }
HeapFree( GetProcessHeap(), 0, bufferW ); free( bufferW );
RtlFreeUnicodeString( &dirW ); RtlFreeUnicodeString( &dirW );
return ret; return ret;
} }
...@@ -1615,7 +1613,7 @@ BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer, ...@@ -1615,7 +1613,7 @@ BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer,
dir_len = lstrlenW( dir ); dir_len = lstrlenW( dir );
if ( !dir_len ) return FALSE; if ( !dir_len ) return FALSE;
msize = ( 7 + dir_len ) * sizeof( WCHAR ); /* \\*.inf\0 */ msize = ( 7 + dir_len ) * sizeof( WCHAR ); /* \\*.inf\0 */
filter = HeapAlloc( GetProcessHeap(), 0, msize ); filter = malloc( msize );
if( !filter ) if( !filter )
{ {
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
...@@ -1628,7 +1626,7 @@ BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer, ...@@ -1628,7 +1626,7 @@ BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer,
att = GetFileAttributesW( filter ); att = GetFileAttributesW( filter );
if (att != INVALID_FILE_ATTRIBUTES && !(att & FILE_ATTRIBUTE_DIRECTORY)) if (att != INVALID_FILE_ATTRIBUTES && !(att & FILE_ATTRIBUTE_DIRECTORY))
{ {
HeapFree( GetProcessHeap(), 0, filter ); free( filter );
SetLastError( ERROR_DIRECTORY ); SetLastError( ERROR_DIRECTORY );
return FALSE; return FALSE;
} }
...@@ -1638,7 +1636,7 @@ BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer, ...@@ -1638,7 +1636,7 @@ BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer,
DWORD msize; DWORD msize;
dir_len = GetWindowsDirectoryW( NULL, 0 ); dir_len = GetWindowsDirectoryW( NULL, 0 );
msize = ( 7 + 4 + dir_len ) * sizeof( WCHAR ); msize = ( 7 + 4 + dir_len ) * sizeof( WCHAR );
filter = HeapAlloc( GetProcessHeap(), 0, msize ); filter = malloc( msize );
if( !filter ) if( !filter )
{ {
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
...@@ -1653,7 +1651,7 @@ BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer, ...@@ -1653,7 +1651,7 @@ BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer,
if ( hdl == INVALID_HANDLE_VALUE ) if ( hdl == INVALID_HANDLE_VALUE )
{ {
if( outsize ) *outsize = 1; if( outsize ) *outsize = 1;
HeapFree( GetProcessHeap(), 0, filter ); free( filter );
return TRUE; return TRUE;
} }
size = 1; size = 1;
...@@ -1665,13 +1663,12 @@ BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer, ...@@ -1665,13 +1663,12 @@ BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer,
if (!fullname || ( name_len < len )) if (!fullname || ( name_len < len ))
{ {
name_len = ( name_len < len ) ? len : name_len; name_len = ( name_len < len ) ? len : name_len;
HeapFree( GetProcessHeap(), 0, fullname ); free( fullname );
fullname = HeapAlloc( GetProcessHeap(), 0, fullname = malloc( (2 + dir_len + name_len) * sizeof( WCHAR ) );
( 2 + dir_len + name_len) * sizeof( WCHAR ));
if( !fullname ) if( !fullname )
{ {
FindClose( hdl ); FindClose( hdl );
HeapFree( GetProcessHeap(), 0, filter ); free( filter );
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE; return FALSE;
} }
...@@ -1700,8 +1697,8 @@ BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer, ...@@ -1700,8 +1697,8 @@ BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer,
while( FindNextFileW( hdl, &finddata )); while( FindNextFileW( hdl, &finddata ));
FindClose( hdl ); FindClose( hdl );
HeapFree( GetProcessHeap(), 0, fullname ); free( fullname );
HeapFree( GetProcessHeap(), 0, filter ); free( filter );
if( outsize ) *outsize = size; if( outsize ) *outsize = size;
return TRUE; return TRUE;
} }
...@@ -67,7 +67,7 @@ static CRITICAL_SECTION setupapi_cs = { &critsect_debug, -1, 0, 0, 0, 0 }; ...@@ -67,7 +67,7 @@ static CRITICAL_SECTION setupapi_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
*/ */
VOID WINAPI MyFree(LPVOID lpMem) VOID WINAPI MyFree(LPVOID lpMem)
{ {
HeapFree(GetProcessHeap(), 0, lpMem); free(lpMem);
} }
...@@ -85,7 +85,7 @@ VOID WINAPI MyFree(LPVOID lpMem) ...@@ -85,7 +85,7 @@ VOID WINAPI MyFree(LPVOID lpMem)
*/ */
LPVOID WINAPI MyMalloc(DWORD dwSize) LPVOID WINAPI MyMalloc(DWORD dwSize)
{ {
return HeapAlloc(GetProcessHeap(), 0, dwSize); return malloc(dwSize);
} }
...@@ -109,10 +109,7 @@ LPVOID WINAPI MyMalloc(DWORD dwSize) ...@@ -109,10 +109,7 @@ LPVOID WINAPI MyMalloc(DWORD dwSize)
*/ */
LPVOID WINAPI MyRealloc(LPVOID lpSrc, DWORD dwSize) LPVOID WINAPI MyRealloc(LPVOID lpSrc, DWORD dwSize)
{ {
if (lpSrc == NULL) return realloc(lpSrc, dwSize);
return HeapAlloc(GetProcessHeap(), 0, dwSize);
return HeapReAlloc(GetProcessHeap(), 0, lpSrc, dwSize);
} }
...@@ -872,8 +869,8 @@ BOOL WINAPI SetupCopyOEMInfA( PCSTR source, PCSTR location, ...@@ -872,8 +869,8 @@ BOOL WINAPI SetupCopyOEMInfA( PCSTR source, PCSTR location,
done: done:
MyFree( destW ); MyFree( destW );
HeapFree( GetProcessHeap(), 0, sourceW ); free( sourceW );
HeapFree( GetProcessHeap(), 0, locationW ); free( locationW );
if (ret) SetLastError(ERROR_SUCCESS); if (ret) SetLastError(ERROR_SUCCESS);
return ret; return ret;
} }
...@@ -1121,7 +1118,7 @@ BOOL WINAPI SetupUninstallOEMInfA( PCSTR inf_file, DWORD flags, PVOID reserved ) ...@@ -1121,7 +1118,7 @@ BOOL WINAPI SetupUninstallOEMInfA( PCSTR inf_file, DWORD flags, PVOID reserved )
if (inf_file && !(inf_fileW = strdupAtoW( inf_file ))) return FALSE; if (inf_file && !(inf_fileW = strdupAtoW( inf_file ))) return FALSE;
ret = SetupUninstallOEMInfW( inf_fileW, flags, reserved ); ret = SetupUninstallOEMInfW( inf_fileW, flags, reserved );
HeapFree( GetProcessHeap(), 0, inf_fileW ); free( inf_fileW );
return ret; return ret;
} }
...@@ -1325,7 +1322,7 @@ BOOL WINAPI SetupGetFileCompressionInfoExA( PCSTR source, PSTR name, DWORD len, ...@@ -1325,7 +1322,7 @@ BOOL WINAPI SetupGetFileCompressionInfoExA( PCSTR source, PSTR name, DWORD len,
if (name) if (name)
{ {
ret = SetupGetFileCompressionInfoExW( sourceW, NULL, 0, &nb_chars, NULL, NULL, NULL ); ret = SetupGetFileCompressionInfoExW( sourceW, NULL, 0, &nb_chars, NULL, NULL, NULL );
if (!(nameW = HeapAlloc( GetProcessHeap(), 0, nb_chars * sizeof(WCHAR) ))) if (!(nameW = malloc( nb_chars * sizeof(WCHAR) )))
{ {
MyFree( sourceW ); MyFree( sourceW );
return FALSE; return FALSE;
...@@ -1346,7 +1343,7 @@ BOOL WINAPI SetupGetFileCompressionInfoExA( PCSTR source, PSTR name, DWORD len, ...@@ -1346,7 +1343,7 @@ BOOL WINAPI SetupGetFileCompressionInfoExA( PCSTR source, PSTR name, DWORD len,
} }
} }
if (required) *required = nb_chars; if (required) *required = nb_chars;
HeapFree( GetProcessHeap(), 0, nameW ); free( nameW );
MyFree( sourceW ); MyFree( sourceW );
return ret; return ret;
...@@ -1776,7 +1773,7 @@ BOOL WINAPI SetupLogErrorW(LPCWSTR message, LogSeverity severity) ...@@ -1776,7 +1773,7 @@ BOOL WINAPI SetupLogErrorW(LPCWSTR message, LogSeverity severity)
if (message) if (message)
{ {
len = WideCharToMultiByte(CP_ACP, 0, message, -1, NULL, 0, NULL, NULL); len = WideCharToMultiByte(CP_ACP, 0, message, -1, NULL, 0, NULL, NULL);
msg = HeapAlloc(GetProcessHeap(), 0, len); msg = malloc(len);
if (msg == NULL) if (msg == NULL)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
...@@ -1790,7 +1787,7 @@ BOOL WINAPI SetupLogErrorW(LPCWSTR message, LogSeverity severity) ...@@ -1790,7 +1787,7 @@ BOOL WINAPI SetupLogErrorW(LPCWSTR message, LogSeverity severity)
*/ */
ret = SetupLogErrorA(msg, severity); ret = SetupLogErrorA(msg, severity);
HeapFree(GetProcessHeap(), 0, msg); free(msg);
return ret; return ret;
} }
......
...@@ -158,15 +158,12 @@ static void *grow_array( void *array, unsigned int *count, size_t elem ) ...@@ -158,15 +158,12 @@ static void *grow_array( void *array, unsigned int *count, size_t elem )
unsigned int new_count = *count + *count / 2; unsigned int new_count = *count + *count / 2;
if (new_count < 32) new_count = 32; if (new_count < 32) new_count = 32;
if (array) new_array = _recalloc( array, new_count, elem );
new_array = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, array, new_count * elem );
else
new_array = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, new_count * elem );
if (new_array) if (new_array)
*count = new_count; *count = new_count;
else else
HeapFree( GetProcessHeap(), 0, array ); free( array );
return new_array; return new_array;
} }
...@@ -219,7 +216,7 @@ static int add_section( struct inf_file *file, const WCHAR *name ) ...@@ -219,7 +216,7 @@ static int add_section( struct inf_file *file, const WCHAR *name )
if (!(file->sections = grow_array( file->sections, &file->alloc_sections, if (!(file->sections = grow_array( file->sections, &file->alloc_sections,
sizeof(file->sections[0]) ))) return -1; sizeof(file->sections[0]) ))) return -1;
} }
if (!(section = HeapAlloc( GetProcessHeap(), 0, sizeof(*section) ))) return -1; if (!(section = malloc( sizeof(*section) ))) return -1;
section->name = name; section->name = name;
section->nb_lines = 0; section->nb_lines = 0;
section->alloc_lines = ARRAY_SIZE( section->lines ); section->alloc_lines = ARRAY_SIZE( section->lines );
...@@ -240,7 +237,7 @@ static struct line *add_line( struct inf_file *file, int section_index ) ...@@ -240,7 +237,7 @@ static struct line *add_line( struct inf_file *file, int section_index )
if (section->nb_lines == section->alloc_lines) /* need to grow the section */ if (section->nb_lines == section->alloc_lines) /* need to grow the section */
{ {
int size = sizeof(*section) - sizeof(section->lines) + 2*section->alloc_lines*sizeof(*line); int size = sizeof(*section) - sizeof(section->lines) + 2*section->alloc_lines*sizeof(*line);
if (!(section = HeapReAlloc( GetProcessHeap(), 0, section, size ))) return NULL; if (!(section = realloc( section, size ))) return NULL;
section->alloc_lines *= 2; section->alloc_lines *= 2;
file->sections[section_index] = section; file->sections[section_index] = section;
} }
...@@ -345,14 +342,14 @@ static const WCHAR *get_string_subst( const struct inf_file *file, const WCHAR * ...@@ -345,14 +342,14 @@ static const WCHAR *get_string_subst( const struct inf_file *file, const WCHAR *
return field->text; return field->text;
not_found: /* check for integer id */ not_found: /* check for integer id */
if ((dirid_str = HeapAlloc( GetProcessHeap(), 0, (*len+1) * sizeof(WCHAR) ))) if ((dirid_str = malloc( (*len + 1) * sizeof(WCHAR) )))
{ {
memcpy( dirid_str, str, *len * sizeof(WCHAR) ); memcpy( dirid_str, str, *len * sizeof(WCHAR) );
dirid_str[*len] = 0; dirid_str[*len] = 0;
dirid = wcstol( dirid_str, &end, 10 ); dirid = wcstol( dirid_str, &end, 10 );
if (!*end) ret = get_dirid_subst( file, dirid, len ); if (!*end) ret = get_dirid_subst( file, dirid, len );
if (no_trailing_slash && ret && *len && ret[*len - 1] == '\\') *len -= 1; if (no_trailing_slash && ret && *len && ret[*len - 1] == '\\') *len -= 1;
HeapFree( GetProcessHeap(), 0, dirid_str ); free( dirid_str );
return ret; return ret;
} }
return NULL; return NULL;
...@@ -860,12 +857,12 @@ static void free_inf_file( struct inf_file *file ) ...@@ -860,12 +857,12 @@ static void free_inf_file( struct inf_file *file )
{ {
unsigned int i; unsigned int i;
for (i = 0; i < file->nb_sections; i++) HeapFree( GetProcessHeap(), 0, file->sections[i] ); for (i = 0; i < file->nb_sections; i++) free( file->sections[i] );
HeapFree( GetProcessHeap(), 0, file->filename ); free( file->filename );
HeapFree( GetProcessHeap(), 0, file->sections ); free( file->sections );
HeapFree( GetProcessHeap(), 0, file->fields ); free( file->fields );
HeapFree( GetProcessHeap(), 0, file->strings ); HeapFree( GetProcessHeap(), 0, file->strings );
HeapFree( GetProcessHeap(), 0, file ); free( file );
} }
...@@ -896,14 +893,12 @@ static DWORD parse_buffer( struct inf_file *file, const WCHAR *buffer, const WCH ...@@ -896,14 +893,12 @@ static DWORD parse_buffer( struct inf_file *file, const WCHAR *buffer, const WCH
/* trim excess buffer space */ /* trim excess buffer space */
if (file->alloc_sections > file->nb_sections) if (file->alloc_sections > file->nb_sections)
{ {
file->sections = HeapReAlloc( GetProcessHeap(), 0, file->sections, file->sections = realloc( file->sections, file->nb_sections * sizeof(file->sections[0]) );
file->nb_sections * sizeof(file->sections[0]) );
file->alloc_sections = file->nb_sections; file->alloc_sections = file->nb_sections;
} }
if (file->alloc_fields > file->nb_fields) if (file->alloc_fields > file->nb_fields)
{ {
file->fields = HeapReAlloc( GetProcessHeap(), 0, file->fields, file->fields = realloc( file->fields, file->nb_fields * sizeof(file->fields[0]) );
file->nb_fields * sizeof(file->fields[0]) );
file->alloc_fields = file->nb_fields; file->alloc_fields = file->nb_fields;
} }
file->strings = HeapReAlloc( GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, file->strings, file->strings = HeapReAlloc( GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, file->strings,
...@@ -963,7 +958,7 @@ static struct inf_file *parse_file( HANDLE handle, const WCHAR *class, DWORD sty ...@@ -963,7 +958,7 @@ static struct inf_file *parse_file( HANDLE handle, const WCHAR *class, DWORD sty
if (class) FIXME( "class %s not supported yet\n", debugstr_w(class) ); if (class) FIXME( "class %s not supported yet\n", debugstr_w(class) );
if (!(file = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*file) ))) if (!(file = calloc( 1, sizeof(*file) )))
{ {
err = ERROR_NOT_ENOUGH_MEMORY; err = ERROR_NOT_ENOUGH_MEMORY;
goto done; goto done;
...@@ -993,12 +988,12 @@ static struct inf_file *parse_file( HANDLE handle, const WCHAR *class, DWORD sty ...@@ -993,12 +988,12 @@ static struct inf_file *parse_file( HANDLE handle, const WCHAR *class, DWORD sty
offset = sizeof(utf8_bom); offset = sizeof(utf8_bom);
} }
if ((new_buff = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) if ((new_buff = malloc( size * sizeof(WCHAR) )))
{ {
DWORD len = MultiByteToWideChar( codepage, 0, (char *)buffer + offset, DWORD len = MultiByteToWideChar( codepage, 0, (char *)buffer + offset,
size - offset, new_buff, size ); size - offset, new_buff, size );
err = parse_buffer( file, new_buff, new_buff + len, error_line ); err = parse_buffer( file, new_buff, new_buff + len, error_line );
HeapFree( GetProcessHeap(), 0, new_buff ); free( new_buff );
} }
} }
else else
...@@ -1068,7 +1063,7 @@ WCHAR *PARSER_get_dest_dir( INFCONTEXT *context ) ...@@ -1068,7 +1063,7 @@ WCHAR *PARSER_get_dest_dir( INFCONTEXT *context )
if (!SetupGetIntField( context, 1, &dirid )) return NULL; if (!SetupGetIntField( context, 1, &dirid )) return NULL;
if (!(dir = get_dirid_subst( context->Inf, dirid, &len1 ))) return NULL; if (!(dir = get_dirid_subst( context->Inf, dirid, &len1 ))) return NULL;
if (!SetupGetStringFieldW( context, 2, NULL, 0, &len2 )) len2 = 0; if (!SetupGetStringFieldW( context, 2, NULL, 0, &len2 )) len2 = 0;
if (!(ret = HeapAlloc( GetProcessHeap(), 0, (len1+len2+1) * sizeof(WCHAR) ))) return NULL; if (!(ret = malloc( (len1 + len2 + 1) * sizeof(WCHAR) ))) return NULL;
memcpy( ret, dir, len1 * sizeof(WCHAR) ); memcpy( ret, dir, len1 * sizeof(WCHAR) );
ptr = ret + len1; ptr = ret + len1;
if (len2 && ptr > ret && ptr[-1] != '\\') *ptr++ = '\\'; if (len2 && ptr > ret && ptr[-1] != '\\') *ptr++ = '\\';
...@@ -1114,7 +1109,7 @@ HINF WINAPI SetupOpenInfFileW( PCWSTR name, PCWSTR class, DWORD style, UINT *err ...@@ -1114,7 +1109,7 @@ HINF WINAPI SetupOpenInfFileW( PCWSTR name, PCWSTR class, DWORD style, UINT *err
if (wcschr( name, '\\' ) || wcschr( name, '/' )) if (wcschr( name, '\\' ) || wcschr( name, '/' ))
{ {
if (!(len = GetFullPathNameW( name, 0, NULL, NULL ))) return INVALID_HANDLE_VALUE; if (!(len = GetFullPathNameW( name, 0, NULL, NULL ))) return INVALID_HANDLE_VALUE;
if (!(path = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) if (!(path = malloc( len * sizeof(WCHAR) )))
{ {
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
...@@ -1128,7 +1123,7 @@ HINF WINAPI SetupOpenInfFileW( PCWSTR name, PCWSTR class, DWORD style, UINT *err ...@@ -1128,7 +1123,7 @@ HINF WINAPI SetupOpenInfFileW( PCWSTR name, PCWSTR class, DWORD style, UINT *err
static const WCHAR System32[] = {'\\','s','y','s','t','e','m','3','2','\\',0}; static const WCHAR System32[] = {'\\','s','y','s','t','e','m','3','2','\\',0};
len = GetWindowsDirectoryW( NULL, 0 ) + lstrlenW(name) + 12; len = GetWindowsDirectoryW( NULL, 0 ) + lstrlenW(name) + 12;
if (!(path = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) if (!(path = malloc( len * sizeof(WCHAR) )))
{ {
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
...@@ -1153,7 +1148,7 @@ HINF WINAPI SetupOpenInfFileW( PCWSTR name, PCWSTR class, DWORD style, UINT *err ...@@ -1153,7 +1148,7 @@ HINF WINAPI SetupOpenInfFileW( PCWSTR name, PCWSTR class, DWORD style, UINT *err
} }
if (!file) if (!file)
{ {
HeapFree( GetProcessHeap(), 0, path ); free( path );
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} }
TRACE( "%s -> %p\n", debugstr_w(path), file ); TRACE( "%s -> %p\n", debugstr_w(path), file );
...@@ -1781,7 +1776,7 @@ BOOL WINAPI SetupGetIntField( PINFCONTEXT context, DWORD index, PINT result ) ...@@ -1781,7 +1776,7 @@ BOOL WINAPI SetupGetIntField( PINFCONTEXT context, DWORD index, PINT result )
if (!(ret = SetupGetStringFieldA( context, index, localbuff, sizeof(localbuff), &required ))) if (!(ret = SetupGetStringFieldA( context, index, localbuff, sizeof(localbuff), &required )))
{ {
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FALSE; if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FALSE;
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, required ))) return FALSE; if (!(buffer = malloc( required ))) return FALSE;
if (!(ret = SetupGetStringFieldA( context, index, buffer, required, NULL ))) goto done; if (!(ret = SetupGetStringFieldA( context, index, buffer, required, NULL ))) goto done;
} }
/* The call to SetupGetStringFieldA succeeded. If buffer is empty we have an optional field */ /* The call to SetupGetStringFieldA succeeded. If buffer is empty we have an optional field */
...@@ -1798,7 +1793,7 @@ BOOL WINAPI SetupGetIntField( PINFCONTEXT context, DWORD index, PINT result ) ...@@ -1798,7 +1793,7 @@ BOOL WINAPI SetupGetIntField( PINFCONTEXT context, DWORD index, PINT result )
} }
done: done:
if (buffer != localbuff) HeapFree( GetProcessHeap(), 0, buffer ); if (buffer != localbuff) free( buffer );
return ret; return ret;
} }
......
...@@ -136,7 +136,7 @@ BOOL WINAPI SetupGetInfInformationA(LPCVOID InfSpec, DWORD SearchControl, ...@@ -136,7 +136,7 @@ BOOL WINAPI SetupGetInfInformationA(LPCVOID InfSpec, DWORD SearchControl,
if (InfSpec && SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE) if (InfSpec && SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE)
{ {
len = MultiByteToWideChar(CP_ACP, 0, InfSpec, -1, NULL, 0); len = MultiByteToWideChar(CP_ACP, 0, InfSpec, -1, NULL, 0);
inf = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); inf = malloc(len * sizeof(WCHAR));
if (!inf) if (!inf)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
...@@ -149,7 +149,7 @@ BOOL WINAPI SetupGetInfInformationA(LPCVOID InfSpec, DWORD SearchControl, ...@@ -149,7 +149,7 @@ BOOL WINAPI SetupGetInfInformationA(LPCVOID InfSpec, DWORD SearchControl,
ReturnBufferSize, RequiredSize); ReturnBufferSize, RequiredSize);
if (SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE) if (SearchControl >= INFINFO_INF_NAME_IS_ABSOLUTE)
HeapFree(GetProcessHeap(), 0, inf); free(inf);
return ret; return ret;
} }
...@@ -241,13 +241,13 @@ BOOL WINAPI SetupQueryInfFileInformationA(PSP_INF_INFORMATION InfInformation, ...@@ -241,13 +241,13 @@ BOOL WINAPI SetupQueryInfFileInformationA(PSP_INF_INFORMATION InfInformation,
if (!ret) if (!ret)
return FALSE; return FALSE;
filenameW = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); filenameW = malloc(size * sizeof(WCHAR));
ret = SetupQueryInfFileInformationW(InfInformation, InfIndex, ret = SetupQueryInfFileInformationW(InfInformation, InfIndex,
filenameW, size, &size); filenameW, size, &size);
if (!ret) if (!ret)
{ {
HeapFree(GetProcessHeap(), 0, filenameW); free(filenameW);
return FALSE; return FALSE;
} }
...@@ -256,7 +256,7 @@ BOOL WINAPI SetupQueryInfFileInformationA(PSP_INF_INFORMATION InfInformation, ...@@ -256,7 +256,7 @@ BOOL WINAPI SetupQueryInfFileInformationA(PSP_INF_INFORMATION InfInformation,
if (!ReturnBuffer) if (!ReturnBuffer)
{ {
HeapFree(GetProcessHeap(), 0, filenameW); free(filenameW);
if (ReturnBufferSize) if (ReturnBufferSize)
{ {
SetLastError(ERROR_INVALID_PARAMETER); SetLastError(ERROR_INVALID_PARAMETER);
...@@ -268,13 +268,13 @@ BOOL WINAPI SetupQueryInfFileInformationA(PSP_INF_INFORMATION InfInformation, ...@@ -268,13 +268,13 @@ BOOL WINAPI SetupQueryInfFileInformationA(PSP_INF_INFORMATION InfInformation,
if (size > ReturnBufferSize) if (size > ReturnBufferSize)
{ {
HeapFree(GetProcessHeap(), 0, filenameW); free(filenameW);
SetLastError(ERROR_INSUFFICIENT_BUFFER); SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE; return FALSE;
} }
WideCharToMultiByte(CP_ACP, 0, filenameW, -1, ReturnBuffer, size, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, filenameW, -1, ReturnBuffer, size, NULL, NULL);
HeapFree(GetProcessHeap(), 0, filenameW); free(filenameW);
return ret; return ret;
} }
...@@ -342,7 +342,7 @@ BOOL WINAPI SetupGetSourceFileLocationA( HINF hinf, PINFCONTEXT context, PCSTR f ...@@ -342,7 +342,7 @@ BOOL WINAPI SetupGetSourceFileLocationA( HINF hinf, PINFCONTEXT context, PCSTR f
if (!SetupGetSourceFileLocationW( hinf, context, filenameW, source_id, NULL, 0, &required )) if (!SetupGetSourceFileLocationW( hinf, context, filenameW, source_id, NULL, 0, &required ))
goto done; goto done;
if (!(bufferW = HeapAlloc( GetProcessHeap(), 0, required * sizeof(WCHAR) ))) if (!(bufferW = malloc( required * sizeof(WCHAR) )))
goto done; goto done;
if (!SetupGetSourceFileLocationW( hinf, context, filenameW, source_id, bufferW, required, NULL )) if (!SetupGetSourceFileLocationW( hinf, context, filenameW, source_id, bufferW, required, NULL ))
...@@ -364,8 +364,8 @@ BOOL WINAPI SetupGetSourceFileLocationA( HINF hinf, PINFCONTEXT context, PCSTR f ...@@ -364,8 +364,8 @@ BOOL WINAPI SetupGetSourceFileLocationA( HINF hinf, PINFCONTEXT context, PCSTR f
ret = TRUE; ret = TRUE;
done: done:
HeapFree( GetProcessHeap(), 0, filenameW ); free( filenameW );
HeapFree( GetProcessHeap(), 0, bufferW ); free( bufferW );
return ret; return ret;
} }
...@@ -381,19 +381,19 @@ static LPWSTR get_source_id( HINF hinf, PINFCONTEXT context, PCWSTR filename ) ...@@ -381,19 +381,19 @@ static LPWSTR get_source_id( HINF hinf, PINFCONTEXT context, PCWSTR filename )
if (!SetupGetStringFieldW( context, 1, NULL, 0, &size )) if (!SetupGetStringFieldW( context, 1, NULL, 0, &size ))
return NULL; return NULL;
if (!(source_id = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) ))) if (!(source_id = malloc( size * sizeof(WCHAR) )))
return NULL; return NULL;
if (!SetupGetStringFieldW( context, 1, source_id, size, NULL )) if (!SetupGetStringFieldW( context, 1, source_id, size, NULL ))
{ {
HeapFree( GetProcessHeap(), 0, source_id ); free( source_id );
return NULL; return NULL;
} }
if (!SetupFindFirstLineW( hinf, source_disks_names_platform, source_id, context ) && if (!SetupFindFirstLineW( hinf, source_disks_names_platform, source_id, context ) &&
!SetupFindFirstLineW( hinf, source_disks_names, source_id, context )) !SetupFindFirstLineW( hinf, source_disks_names, source_id, context ))
{ {
HeapFree( GetProcessHeap(), 0, source_id ); free( source_id );
return NULL; return NULL;
} }
return source_id; return source_id;
...@@ -421,10 +421,10 @@ BOOL WINAPI SetupGetSourceFileLocationW( HINF hinf, PINFCONTEXT context, PCWSTR ...@@ -421,10 +421,10 @@ BOOL WINAPI SetupGetSourceFileLocationW( HINF hinf, PINFCONTEXT context, PCWSTR
*source_id = wcstol( source_id_str, &end, 10 ); *source_id = wcstol( source_id_str, &end, 10 );
if (end == source_id_str || *end) if (end == source_id_str || *end)
{ {
HeapFree( GetProcessHeap(), 0, source_id_str ); free( source_id_str );
return FALSE; return FALSE;
} }
HeapFree( GetProcessHeap(), 0, source_id_str ); free( source_id_str );
if (SetupGetStringFieldW( context, 4, buffer, buffer_size, required_size )) if (SetupGetStringFieldW( context, 4, buffer, buffer_size, required_size ))
return TRUE; return TRUE;
...@@ -460,7 +460,7 @@ BOOL WINAPI SetupGetSourceInfoA( HINF hinf, UINT source_id, UINT info, ...@@ -460,7 +460,7 @@ BOOL WINAPI SetupGetSourceInfoA( HINF hinf, UINT source_id, UINT info,
if (!SetupGetSourceInfoW( hinf, source_id, info, NULL, 0, &required )) if (!SetupGetSourceInfoW( hinf, source_id, info, NULL, 0, &required ))
return FALSE; return FALSE;
if (!(bufferW = HeapAlloc( GetProcessHeap(), 0, required * sizeof(WCHAR) ))) if (!(bufferW = malloc( required * sizeof(WCHAR) )))
return FALSE; return FALSE;
if (!SetupGetSourceInfoW( hinf, source_id, info, bufferW, required, NULL )) if (!SetupGetSourceInfoW( hinf, source_id, info, bufferW, required, NULL ))
...@@ -482,7 +482,7 @@ BOOL WINAPI SetupGetSourceInfoA( HINF hinf, UINT source_id, UINT info, ...@@ -482,7 +482,7 @@ BOOL WINAPI SetupGetSourceInfoA( HINF hinf, UINT source_id, UINT info,
ret = TRUE; ret = TRUE;
done: done:
HeapFree( GetProcessHeap(), 0, bufferW ); free( bufferW );
return ret; return ret;
} }
...@@ -554,7 +554,7 @@ BOOL WINAPI SetupGetTargetPathA( HINF hinf, PINFCONTEXT context, PCSTR section, ...@@ -554,7 +554,7 @@ BOOL WINAPI SetupGetTargetPathA( HINF hinf, PINFCONTEXT context, PCSTR section,
if (!SetupGetTargetPathW( hinf, context, sectionW, NULL, 0, &required )) if (!SetupGetTargetPathW( hinf, context, sectionW, NULL, 0, &required ))
goto done; goto done;
if (!(bufferW = HeapAlloc( GetProcessHeap(), 0, required * sizeof(WCHAR) ))) if (!(bufferW = malloc( required * sizeof(WCHAR) )))
goto done; goto done;
if (!SetupGetTargetPathW( hinf, context, sectionW, bufferW, required, NULL )) if (!SetupGetTargetPathW( hinf, context, sectionW, bufferW, required, NULL ))
...@@ -576,8 +576,8 @@ BOOL WINAPI SetupGetTargetPathA( HINF hinf, PINFCONTEXT context, PCSTR section, ...@@ -576,8 +576,8 @@ BOOL WINAPI SetupGetTargetPathA( HINF hinf, PINFCONTEXT context, PCSTR section,
ret = TRUE; ret = TRUE;
done: done:
HeapFree( GetProcessHeap(), 0, sectionW ); free( sectionW );
HeapFree( GetProcessHeap(), 0, bufferW ); free( bufferW );
return ret; return ret;
} }
...@@ -622,11 +622,11 @@ BOOL WINAPI SetupGetTargetPathW( HINF hinf, PINFCONTEXT context, PCWSTR section, ...@@ -622,11 +622,11 @@ BOOL WINAPI SetupGetTargetPathW( HINF hinf, PINFCONTEXT context, PCWSTR section,
else else
{ {
SetLastError( ERROR_INSUFFICIENT_BUFFER ); SetLastError( ERROR_INSUFFICIENT_BUFFER );
if (dir != systemdir) HeapFree( GetProcessHeap(), 0, dir ); if (dir != systemdir) free( dir );
return FALSE; return FALSE;
} }
} }
if (dir != systemdir) HeapFree( GetProcessHeap(), 0, dir ); if (dir != systemdir) free( dir );
return TRUE; return TRUE;
} }
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "setupapi_private.h" #include "setupapi_private.h"
#include "winver.h" #include "winver.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(setupapi); WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
...@@ -105,13 +104,13 @@ static void free_file_op_queue( struct file_op_queue *queue ) ...@@ -105,13 +104,13 @@ static void free_file_op_queue( struct file_op_queue *queue )
while( op ) while( op )
{ {
HeapFree( GetProcessHeap(), 0, op->src_path ); free( op->src_path );
HeapFree( GetProcessHeap(), 0, op->src_file ); free( op->src_file );
HeapFree( GetProcessHeap(), 0, op->dst_path ); free( op->dst_path );
if (op->dst_file != op->src_file) HeapFree( GetProcessHeap(), 0, op->dst_file ); if (op->dst_file != op->src_file) free( op->dst_file );
t = op; t = op;
op = op->next; op = op->next;
HeapFree( GetProcessHeap(), 0, t ); free( t );
} }
} }
...@@ -242,7 +241,7 @@ UINT CALLBACK QUEUE_callback_WtoA( void *context, UINT notification, ...@@ -242,7 +241,7 @@ UINT CALLBACK QUEUE_callback_WtoA( void *context, UINT notification,
statusA.FailureCode = statusW->FailureCode; statusA.FailureCode = statusW->FailureCode;
ret = callback_ctx->orig_handler( callback_ctx->orig_context, notification, ret = callback_ctx->orig_handler( callback_ctx->orig_context, notification,
(UINT_PTR)&statusA, param2 ); (UINT_PTR)&statusA, param2 );
HeapFree( GetProcessHeap(), 0, (LPSTR)statusA.FileName ); free( (char *)statusA.FileName );
} }
break; break;
...@@ -253,7 +252,7 @@ UINT CALLBACK QUEUE_callback_WtoA( void *context, UINT notification, ...@@ -253,7 +252,7 @@ UINT CALLBACK QUEUE_callback_WtoA( void *context, UINT notification,
ret = callback_ctx->orig_handler( callback_ctx->orig_context, notification, ret = callback_ctx->orig_handler( callback_ctx->orig_context, notification,
(UINT_PTR)target, param2 ); (UINT_PTR)target, param2 );
HeapFree( GetProcessHeap(), 0, target ); free( target );
} }
break; break;
...@@ -274,10 +273,10 @@ UINT CALLBACK QUEUE_callback_WtoA( void *context, UINT notification, ...@@ -274,10 +273,10 @@ UINT CALLBACK QUEUE_callback_WtoA( void *context, UINT notification,
(UINT_PTR)&mediaA, (UINT_PTR)&path); (UINT_PTR)&mediaA, (UINT_PTR)&path);
MultiByteToWideChar(CP_ACP, 0, path, -1, (WCHAR *)param2, MAX_PATH); MultiByteToWideChar(CP_ACP, 0, path, -1, (WCHAR *)param2, MAX_PATH);
heap_free((char *)mediaA.Tagfile); free((char *)mediaA.Tagfile);
heap_free((char *)mediaA.Description); free((char *)mediaA.Description);
heap_free((char *)mediaA.SourcePath); free((char *)mediaA.SourcePath);
heap_free((char *)mediaA.SourceFile); free((char *)mediaA.SourceFile);
break; break;
} }
case SPFILENOTIFY_STARTQUEUE: case SPFILENOTIFY_STARTQUEUE:
...@@ -311,11 +310,11 @@ static void get_source_info( HINF hinf, const WCHAR *src_file, SP_FILE_COPY_PARA ...@@ -311,11 +310,11 @@ static void get_source_info( HINF hinf, const WCHAR *src_file, SP_FILE_COPY_PARA
} }
if (SetupGetStringFieldW( &disk_ctx, 1, NULL, 0, &len ) && len > sizeof(WCHAR) if (SetupGetStringFieldW( &disk_ctx, 1, NULL, 0, &len ) && len > sizeof(WCHAR)
&& (params->SourceDescription = heap_alloc( len * sizeof(WCHAR) ))) && (params->SourceDescription = malloc( len * sizeof(WCHAR) )))
SetupGetStringFieldW( &disk_ctx, 1, (WCHAR *)params->SourceDescription, len, NULL ); SetupGetStringFieldW( &disk_ctx, 1, (WCHAR *)params->SourceDescription, len, NULL );
if (SetupGetStringFieldW( &disk_ctx, 2, NULL, 0, &len ) && len > sizeof(WCHAR) if (SetupGetStringFieldW( &disk_ctx, 2, NULL, 0, &len ) && len > sizeof(WCHAR)
&& (params->SourceTagfile = heap_alloc( len * sizeof(WCHAR) ))) && (params->SourceTagfile = malloc( len * sizeof(WCHAR) )))
SetupGetStringFieldW( &disk_ctx, 2, (WCHAR *)params->SourceTagfile, len, NULL ); SetupGetStringFieldW( &disk_ctx, 2, (WCHAR *)params->SourceTagfile, len, NULL );
if (SetupGetStringFieldW( &disk_ctx, 4, NULL, 0, &len ) && len > sizeof(WCHAR) if (SetupGetStringFieldW( &disk_ctx, 4, NULL, 0, &len ) && len > sizeof(WCHAR)
...@@ -351,7 +350,7 @@ static WCHAR *get_destination_dir( HINF hinf, const WCHAR *section ) ...@@ -351,7 +350,7 @@ static WCHAR *get_destination_dir( HINF hinf, const WCHAR *section )
return dir; return dir;
GetSystemDirectoryW( systemdir, MAX_PATH ); GetSystemDirectoryW( systemdir, MAX_PATH );
return strdupW( systemdir ); return wcsdup( systemdir );
} }
struct extract_cab_ctx struct extract_cab_ctx
...@@ -430,7 +429,7 @@ HSPFILEQ WINAPI SetupOpenFileQueue(void) ...@@ -430,7 +429,7 @@ HSPFILEQ WINAPI SetupOpenFileQueue(void)
{ {
struct file_queue *queue; struct file_queue *queue;
if (!(queue = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*queue)))) if (!(queue = calloc( 1, sizeof(*queue) )))
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
queue->magic = FILE_QUEUE_MAGIC; queue->magic = FILE_QUEUE_MAGIC;
return queue; return queue;
...@@ -458,12 +457,12 @@ BOOL WINAPI SetupCloseFileQueue( HSPFILEQ handle ) ...@@ -458,12 +457,12 @@ BOOL WINAPI SetupCloseFileQueue( HSPFILEQ handle )
free_file_op_queue( &queue->delete_queue ); free_file_op_queue( &queue->delete_queue );
for (i = 0; i < queue->source_count; ++i) for (i = 0; i < queue->source_count; ++i)
{ {
heap_free( queue->sources[i]->desc ); free( queue->sources[i]->desc );
heap_free( queue->sources[i]->tag ); free( queue->sources[i]->tag );
heap_free( queue->sources[i] ); free( queue->sources[i] );
} }
heap_free( queue->sources ); free( queue->sources );
HeapFree( GetProcessHeap(), 0, queue ); free( queue );
return TRUE; return TRUE;
} }
...@@ -491,14 +490,14 @@ BOOL WINAPI SetupQueueCopyIndirectA( SP_FILE_COPY_PARAMS_A *paramsA ) ...@@ -491,14 +490,14 @@ BOOL WINAPI SetupQueueCopyIndirectA( SP_FILE_COPY_PARAMS_A *paramsA )
ret = SetupQueueCopyIndirectW( &paramsW ); ret = SetupQueueCopyIndirectW( &paramsW );
heap_free( (WCHAR *)paramsW.SourceRootPath ); free( (WCHAR *)paramsW.SourceRootPath );
heap_free( (WCHAR *)paramsW.SourcePath ); free( (WCHAR *)paramsW.SourcePath );
heap_free( (WCHAR *)paramsW.SourceFilename ); free( (WCHAR *)paramsW.SourceFilename );
heap_free( (WCHAR *)paramsW.SourceDescription ); free( (WCHAR *)paramsW.SourceDescription );
heap_free( (WCHAR *)paramsW.SourceTagfile ); free( (WCHAR *)paramsW.SourceTagfile );
heap_free( (WCHAR *)paramsW.TargetDirectory ); free( (WCHAR *)paramsW.TargetDirectory );
heap_free( (WCHAR *)paramsW.TargetFilename ); free( (WCHAR *)paramsW.TargetFilename );
heap_free( (WCHAR *)paramsW.SecurityDescriptor ); free( (WCHAR *)paramsW.SecurityDescriptor );
return ret; return ret;
} }
...@@ -522,11 +521,11 @@ static struct source_media *get_source_media(struct file_queue *queue, ...@@ -522,11 +521,11 @@ static struct source_media *get_source_media(struct file_queue *queue,
} }
} }
queue->sources = heap_realloc( queue->sources, ++queue->source_count * sizeof(*queue->sources) ); queue->sources = realloc( queue->sources, ++queue->source_count * sizeof(*queue->sources) );
queue->sources[i] = heap_alloc( sizeof(*queue->sources[i]) ); queue->sources[i] = malloc( sizeof(*queue->sources[i]) );
lstrcpyW(queue->sources[i]->root, root); lstrcpyW(queue->sources[i]->root, root);
queue->sources[i]->desc = strdupW(desc); queue->sources[i]->desc = wcsdup( desc );
queue->sources[i]->tag = strdupW(tag); queue->sources[i]->tag = wcsdup( tag );
queue->sources[i]->resolved = FALSE; queue->sources[i]->resolved = FALSE;
queue->sources[i]->cabinet = FALSE; queue->sources[i]->cabinet = FALSE;
...@@ -541,12 +540,12 @@ BOOL WINAPI SetupQueueCopyIndirectW( PSP_FILE_COPY_PARAMS_W params ) ...@@ -541,12 +540,12 @@ BOOL WINAPI SetupQueueCopyIndirectW( PSP_FILE_COPY_PARAMS_W params )
struct file_queue *queue = params->QueueHandle; struct file_queue *queue = params->QueueHandle;
struct file_op *op; struct file_op *op;
if (!(op = HeapAlloc( GetProcessHeap(), 0, sizeof(*op) ))) return FALSE; if (!(op = malloc( sizeof(*op) ))) return FALSE;
op->style = params->CopyStyle; op->style = params->CopyStyle;
op->src_path = strdupW( params->SourcePath ); op->src_path = wcsdup( params->SourcePath );
op->src_file = strdupW( params->SourceFilename ); op->src_file = wcsdup( params->SourceFilename );
op->dst_path = strdupW( params->TargetDirectory ); op->dst_path = wcsdup( params->TargetDirectory );
op->dst_file = strdupW( params->TargetFilename ); op->dst_file = wcsdup( params->TargetFilename );
/* some defaults */ /* some defaults */
if (!op->dst_file) op->dst_file = op->src_file; if (!op->dst_file) op->dst_file = op->src_file;
...@@ -672,9 +671,9 @@ BOOL WINAPI SetupQueueDefaultCopyW( HSPFILEQ queue, HINF hinf, PCWSTR src_root, ...@@ -672,9 +671,9 @@ BOOL WINAPI SetupQueueDefaultCopyW( HSPFILEQ queue, HINF hinf, PCWSTR src_root,
ret = SetupQueueCopyIndirectW( &params ); ret = SetupQueueCopyIndirectW( &params );
heap_free( (WCHAR *)params.TargetDirectory ); free( (WCHAR *)params.TargetDirectory );
heap_free( (WCHAR *)params.SourceDescription ); free( (WCHAR *)params.SourceDescription );
heap_free( (WCHAR *)params.SourceTagfile ); free( (WCHAR *)params.SourceTagfile );
return ret; return ret;
} }
...@@ -687,7 +686,7 @@ BOOL WINAPI SetupQueueDeleteA( HSPFILEQ handle, PCSTR part1, PCSTR part2 ) ...@@ -687,7 +686,7 @@ BOOL WINAPI SetupQueueDeleteA( HSPFILEQ handle, PCSTR part1, PCSTR part2 )
struct file_queue *queue = handle; struct file_queue *queue = handle;
struct file_op *op; struct file_op *op;
if (!(op = heap_alloc_zero( sizeof(*op) ))) return FALSE; if (!(op = calloc( 1, sizeof(*op) ))) return FALSE;
op->dst_path = strdupAtoW( part1 ); op->dst_path = strdupAtoW( part1 );
op->dst_file = strdupAtoW( part2 ); op->dst_file = strdupAtoW( part2 );
queue_file_op( &queue->delete_queue, op ); queue_file_op( &queue->delete_queue, op );
...@@ -703,9 +702,9 @@ BOOL WINAPI SetupQueueDeleteW( HSPFILEQ handle, PCWSTR part1, PCWSTR part2 ) ...@@ -703,9 +702,9 @@ BOOL WINAPI SetupQueueDeleteW( HSPFILEQ handle, PCWSTR part1, PCWSTR part2 )
struct file_queue *queue = handle; struct file_queue *queue = handle;
struct file_op *op; struct file_op *op;
if (!(op = heap_alloc_zero( sizeof(*op) ))) return FALSE; if (!(op = calloc( 1, sizeof(*op) ))) return FALSE;
op->dst_path = strdupW( part1 ); op->dst_path = wcsdup( part1 );
op->dst_file = strdupW( part2 ); op->dst_file = wcsdup( part2 );
queue_file_op( &queue->delete_queue, op ); queue_file_op( &queue->delete_queue, op );
return TRUE; return TRUE;
} }
...@@ -720,7 +719,7 @@ BOOL WINAPI SetupQueueRenameA( HSPFILEQ handle, PCSTR SourcePath, PCSTR SourceFi ...@@ -720,7 +719,7 @@ BOOL WINAPI SetupQueueRenameA( HSPFILEQ handle, PCSTR SourcePath, PCSTR SourceFi
struct file_queue *queue = handle; struct file_queue *queue = handle;
struct file_op *op; struct file_op *op;
if (!(op = heap_alloc_zero( sizeof(*op) ))) return FALSE; if (!(op = calloc( 1, sizeof(*op) ))) return FALSE;
op->src_path = strdupAtoW( SourcePath ); op->src_path = strdupAtoW( SourcePath );
op->src_file = strdupAtoW( SourceFilename ); op->src_file = strdupAtoW( SourceFilename );
op->dst_path = strdupAtoW( TargetPath ? TargetPath : SourcePath ); op->dst_path = strdupAtoW( TargetPath ? TargetPath : SourcePath );
...@@ -739,11 +738,11 @@ BOOL WINAPI SetupQueueRenameW( HSPFILEQ handle, PCWSTR SourcePath, PCWSTR Source ...@@ -739,11 +738,11 @@ BOOL WINAPI SetupQueueRenameW( HSPFILEQ handle, PCWSTR SourcePath, PCWSTR Source
struct file_queue *queue = handle; struct file_queue *queue = handle;
struct file_op *op; struct file_op *op;
if (!(op = heap_alloc_zero( sizeof(*op) ))) return FALSE; if (!(op = calloc( 1, sizeof(*op) ))) return FALSE;
op->src_path = strdupW( SourcePath ); op->src_path = wcsdup( SourcePath );
op->src_file = strdupW( SourceFilename ); op->src_file = wcsdup( SourceFilename );
op->dst_path = strdupW( TargetPath ? TargetPath : SourcePath ); op->dst_path = wcsdup( TargetPath ? TargetPath : SourcePath );
op->dst_file = strdupW( TargetFilename ); op->dst_file = wcsdup( TargetFilename );
queue_file_op( &queue->rename_queue, op ); queue_file_op( &queue->rename_queue, op );
return TRUE; return TRUE;
} }
...@@ -835,13 +834,13 @@ BOOL WINAPI SetupQueueCopySectionW( HSPFILEQ queue, PCWSTR src_root, HINF hinf, ...@@ -835,13 +834,13 @@ BOOL WINAPI SetupQueueCopySectionW( HSPFILEQ queue, PCWSTR src_root, HINF hinf,
if (!SetupQueueCopyIndirectW( &params )) goto end; if (!SetupQueueCopyIndirectW( &params )) goto end;
heap_free( (WCHAR *)params.SourceDescription ); free( (WCHAR *)params.SourceDescription );
heap_free( (WCHAR *)params.SourceTagfile ); free( (WCHAR *)params.SourceTagfile );
} while (SetupFindNextLine( &context, &context )); } while (SetupFindNextLine( &context, &context ));
ret = TRUE; ret = TRUE;
end: end:
HeapFree(GetProcessHeap(), 0, dest_dir); free( dest_dir );
return ret; return ret;
} }
...@@ -890,7 +889,7 @@ BOOL WINAPI SetupQueueDeleteSectionW( HSPFILEQ queue, HINF hinf, HINF hlist, PCW ...@@ -890,7 +889,7 @@ BOOL WINAPI SetupQueueDeleteSectionW( HSPFILEQ queue, HINF hinf, HINF hlist, PCW
ret = TRUE; ret = TRUE;
done: done:
HeapFree( GetProcessHeap(), 0, dest_dir ); free( dest_dir );
return ret; return ret;
} }
...@@ -939,7 +938,7 @@ BOOL WINAPI SetupQueueRenameSectionW( HSPFILEQ queue, HINF hinf, HINF hlist, PCW ...@@ -939,7 +938,7 @@ BOOL WINAPI SetupQueueRenameSectionW( HSPFILEQ queue, HINF hinf, HINF hlist, PCW
ret = TRUE; ret = TRUE;
done: done:
HeapFree( GetProcessHeap(), 0, dest_dir ); free( dest_dir );
return ret; return ret;
} }
...@@ -969,7 +968,7 @@ static BOOL create_full_pathW(const WCHAR *path) ...@@ -969,7 +968,7 @@ static BOOL create_full_pathW(const WCHAR *path)
int len; int len;
WCHAR *new_path; WCHAR *new_path;
new_path = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(path) + 1) * sizeof(WCHAR)); new_path = malloc((lstrlenW(path) + 1) * sizeof(WCHAR));
lstrcpyW(new_path, path); lstrcpyW(new_path, path);
while((len = lstrlenW(new_path)) && new_path[len - 1] == '\\') while((len = lstrlenW(new_path)) && new_path[len - 1] == '\\')
...@@ -1005,7 +1004,7 @@ static BOOL create_full_pathW(const WCHAR *path) ...@@ -1005,7 +1004,7 @@ static BOOL create_full_pathW(const WCHAR *path)
new_path[len] = '\\'; new_path[len] = '\\';
} }
HeapFree(GetProcessHeap(), 0, new_path); free(new_path);
return ret; return ret;
} }
...@@ -1108,8 +1107,8 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, ...@@ -1108,8 +1107,8 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
UINT length; UINT length;
DWORD ret; DWORD ret;
VersionSource = HeapAlloc(GetProcessHeap(),0,VersionSizeSource); VersionSource = malloc(VersionSizeSource);
VersionTarget = HeapAlloc(GetProcessHeap(),0,VersionSizeTarget); VersionTarget = malloc(VersionSizeTarget);
ret = GetFileVersionInfoW(source,0,VersionSizeSource,VersionSource); ret = GetFileVersionInfoW(source,0,VersionSizeSource,VersionSource);
if (ret) if (ret)
...@@ -1164,8 +1163,8 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, ...@@ -1164,8 +1163,8 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
} }
} }
} }
HeapFree(GetProcessHeap(),0,VersionSource); free(VersionSource);
HeapFree(GetProcessHeap(),0,VersionTarget); free(VersionTarget);
} }
} }
if (style & (SP_COPY_NOOVERWRITE | SP_COPY_FORCE_NOOVERWRITE)) if (style & (SP_COPY_NOOVERWRITE | SP_COPY_FORCE_NOOVERWRITE))
...@@ -1295,14 +1294,14 @@ BOOL WINAPI SetupInstallFileExW( HINF hinf, PINFCONTEXT inf_context, PCWSTR sour ...@@ -1295,14 +1294,14 @@ BOOL WINAPI SetupInstallFileExW( HINF hinf, PINFCONTEXT inf_context, PCWSTR sour
if (!SetupFindFirstLineW( hinf, L"CopyFiles", NULL, inf_context )) return FALSE; if (!SetupFindFirstLineW( hinf, L"CopyFiles", NULL, inf_context )) return FALSE;
} }
if (!SetupGetStringFieldW( inf_context, 1, NULL, 0, &len )) return FALSE; if (!SetupGetStringFieldW( inf_context, 1, NULL, 0, &len )) return FALSE;
if (!(inf_source = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) if (!(inf_source = malloc( len * sizeof(WCHAR) )))
{ {
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE; return FALSE;
} }
if (!SetupGetStringFieldW( inf_context, 1, inf_source, len, NULL )) if (!SetupGetStringFieldW( inf_context, 1, inf_source, len, NULL ))
{ {
HeapFree( GetProcessHeap(), 0, inf_source ); free( inf_source );
return FALSE; return FALSE;
} }
source = inf_source; source = inf_source;
...@@ -1311,7 +1310,7 @@ BOOL WINAPI SetupInstallFileExW( HINF hinf, PINFCONTEXT inf_context, PCWSTR sour ...@@ -1311,7 +1310,7 @@ BOOL WINAPI SetupInstallFileExW( HINF hinf, PINFCONTEXT inf_context, PCWSTR sour
{ {
lstrcpyW( dest_path, dest_dir ); lstrcpyW( dest_path, dest_dir );
lstrcatW( dest_path, L"\\" ); lstrcatW( dest_path, L"\\" );
heap_free( dest_dir ); free( dest_dir );
} }
} }
else if (!source) else if (!source)
...@@ -1323,9 +1322,9 @@ BOOL WINAPI SetupInstallFileExW( HINF hinf, PINFCONTEXT inf_context, PCWSTR sour ...@@ -1323,9 +1322,9 @@ BOOL WINAPI SetupInstallFileExW( HINF hinf, PINFCONTEXT inf_context, PCWSTR sour
len = lstrlenW( source ) + 1; len = lstrlenW( source ) + 1;
if (absolute) len += lstrlenW( root ) + 1; if (absolute) len += lstrlenW( root ) + 1;
if (!(p = buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) if (!(p = buffer = malloc( len * sizeof(WCHAR) )))
{ {
HeapFree( GetProcessHeap(), 0, inf_source ); free( inf_source );
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE; return FALSE;
} }
...@@ -1343,8 +1342,8 @@ BOOL WINAPI SetupInstallFileExW( HINF hinf, PINFCONTEXT inf_context, PCWSTR sour ...@@ -1343,8 +1342,8 @@ BOOL WINAPI SetupInstallFileExW( HINF hinf, PINFCONTEXT inf_context, PCWSTR sour
ret = do_file_copyW( buffer, dest_path, style, handler, context ); ret = do_file_copyW( buffer, dest_path, style, handler, context );
HeapFree( GetProcessHeap(), 0, inf_source ); free( inf_source );
HeapFree( GetProcessHeap(), 0, buffer ); free( buffer );
return ret; return ret;
} }
...@@ -1477,7 +1476,7 @@ BOOL WINAPI SetupCommitFileQueueW( HWND owner, HSPFILEQ handle, PSP_FILE_CALLBAC ...@@ -1477,7 +1476,7 @@ BOOL WINAPI SetupCommitFileQueueW( HWND owner, HSPFILEQ handle, PSP_FILE_CALLBAC
lstrcatW(op->media->root, L"\\"); lstrcatW(op->media->root, L"\\");
lstrcatW(op->media->root, op->src_path); lstrcatW(op->media->root, op->src_path);
heap_free(op->src_path); free(op->src_path);
op->src_path = NULL; op->src_path = NULL;
} }
...@@ -1742,7 +1741,7 @@ PVOID WINAPI SetupInitDefaultQueueCallbackEx( HWND owner, HWND progress, UINT ms ...@@ -1742,7 +1741,7 @@ PVOID WINAPI SetupInitDefaultQueueCallbackEx( HWND owner, HWND progress, UINT ms
{ {
struct default_callback_context *context; struct default_callback_context *context;
if ((context = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*context) ))) if ((context = calloc( 1, sizeof(*context) )))
{ {
context->magic = 0x43515053; /* "SPQC" */ context->magic = 0x43515053; /* "SPQC" */
context->owner = owner; context->owner = owner;
...@@ -1758,7 +1757,7 @@ PVOID WINAPI SetupInitDefaultQueueCallbackEx( HWND owner, HWND progress, UINT ms ...@@ -1758,7 +1757,7 @@ PVOID WINAPI SetupInitDefaultQueueCallbackEx( HWND owner, HWND progress, UINT ms
*/ */
void WINAPI SetupTermDefaultQueueCallback( PVOID context ) void WINAPI SetupTermDefaultQueueCallback( PVOID context )
{ {
HeapFree( GetProcessHeap(), 0, context ); free( context );
} }
......
...@@ -47,29 +47,13 @@ ...@@ -47,29 +47,13 @@
extern HINSTANCE SETUPAPI_hInstance DECLSPEC_HIDDEN; extern HINSTANCE SETUPAPI_hInstance DECLSPEC_HIDDEN;
static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
{
return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
}
static inline WCHAR *strdupW( const WCHAR *str )
{
WCHAR *ret = NULL;
if (str)
{
int len = (lstrlenW(str) + 1) * sizeof(WCHAR);
if ((ret = HeapAlloc( GetProcessHeap(), 0, len ))) memcpy( ret, str, len );
}
return ret;
}
static inline char *strdupWtoA( const WCHAR *str ) static inline char *strdupWtoA( const WCHAR *str )
{ {
char *ret = NULL; char *ret = NULL;
if (str) if (str)
{ {
DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL ); DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
if ((ret = HeapAlloc( GetProcessHeap(), 0, len ))) if ((ret = malloc( len )))
WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL ); WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
} }
return ret; return ret;
...@@ -81,7 +65,7 @@ static inline WCHAR *strdupAtoW( const char *str ) ...@@ -81,7 +65,7 @@ static inline WCHAR *strdupAtoW( const char *str )
if (str) if (str)
{ {
DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) if ((ret = malloc( len * sizeof(WCHAR) )))
MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len ); MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
} }
return ret; return ret;
......
...@@ -53,12 +53,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(setupapi); ...@@ -53,12 +53,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
static void * CDECL sc_cb_alloc(ULONG cb) static void * CDECL sc_cb_alloc(ULONG cb)
{ {
return HeapAlloc(GetProcessHeap(), 0, cb); return malloc(cb);
} }
static void CDECL sc_cb_free(void *pv) static void CDECL sc_cb_free(void *pv)
{ {
HeapFree(GetProcessHeap(), 0, pv); free(pv);
} }
static INT_PTR CDECL sc_cb_open(char *pszFile, int oflag, int pmode) static INT_PTR CDECL sc_cb_open(char *pszFile, int oflag, int pmode)
......
...@@ -399,7 +399,7 @@ DWORD WINAPI StringTableAddStringEx(HSTRING_TABLE hTable, LPWSTR string, ...@@ -399,7 +399,7 @@ DWORD WINAPI StringTableAddStringEx(HSTRING_TABLE hTable, LPWSTR string,
len = sizeof(DWORD) + (lstrlenW(string)+1)*sizeof(WCHAR) + table->max_extra_size; len = sizeof(DWORD) + (lstrlenW(string)+1)*sizeof(WCHAR) + table->max_extra_size;
if (table->nextoffset + len >= table->allocated) { if (table->nextoffset + len >= table->allocated) {
table->allocated <<= 1; table->allocated <<= 1;
table->data = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, table->data, table->allocated); table->data = _recalloc(table->data, 1, table->allocated);
} }
/* hash string */ /* hash string */
......
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