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