Zebediah Figura : setupapi: Avoid unnecessary buffer allocation in SetupDiCreateDeviceInfoA().
Alexandre Julliard
julliard at winehq.org
Wed Nov 28 14:11:48 CST 2018
Module: wine
Branch: master
Commit: ad5314040b559a00325a85565fe9da3f2b6765c5
URL: https://source.winehq.org/git/wine.git/?a=commit;h=ad5314040b559a00325a85565fe9da3f2b6765c5
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Tue Nov 27 19:55:35 2018 -0600
setupapi: Avoid unnecessary buffer allocation in SetupDiCreateDeviceInfoA().
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/setupapi/devinst.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index 8ce1344..a9145ad 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -1341,8 +1341,8 @@ BOOL WINAPI SetupDiCreateDeviceInfoA(HDEVINFO DeviceInfoSet, const char *name,
const GUID *ClassGuid, PCSTR DeviceDescription, HWND hwndParent, DWORD CreationFlags,
PSP_DEVINFO_DATA DeviceInfoData)
{
+ WCHAR nameW[MAX_DEVICE_ID_LEN];
BOOL ret = FALSE;
- LPWSTR DeviceNameW = NULL;
LPWSTR DeviceDescriptionW = NULL;
if (!name || strlen(name) >= MAX_DEVICE_ID_LEN)
@@ -1351,23 +1351,18 @@ BOOL WINAPI SetupDiCreateDeviceInfoA(HDEVINFO DeviceInfoSet, const char *name,
return FALSE;
}
- DeviceNameW = MultiByteToUnicode(name, CP_ACP);
- if (DeviceNameW == NULL) return FALSE;
+ MultiByteToWideChar(CP_ACP, 0, name, -1, nameW, sizeof(nameW));
if (DeviceDescription)
{
DeviceDescriptionW = MultiByteToUnicode(DeviceDescription, CP_ACP);
if (DeviceDescriptionW == NULL)
- {
- MyFree(DeviceNameW);
return FALSE;
- }
}
- ret = SetupDiCreateDeviceInfoW(DeviceInfoSet, DeviceNameW, ClassGuid, DeviceDescriptionW,
+ ret = SetupDiCreateDeviceInfoW(DeviceInfoSet, nameW, ClassGuid, DeviceDescriptionW,
hwndParent, CreationFlags, DeviceInfoData);
- MyFree(DeviceNameW);
MyFree(DeviceDescriptionW);
return ret;
More information about the wine-cvs
mailing list