From 3223798d30d7ff81b57ec3a598ab7270be87c599 Mon Sep 17 00:00:00 2001 From: Vitaliy Margolen Date: Sun, 19 Apr 2009 20:33:27 -0600 Subject: [PATCH] dinput: Make props array a part of the generic joystick struct. It's much easier to free it on release. --- dlls/dinput/joystick_linux.c | 6 ------ dlls/dinput/joystick_osx.c | 6 ------ dlls/dinput/joystick_private.h | 4 +++- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index c7facab9d21..3a8487b947f 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -462,11 +462,6 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di } newDevice->generic.base.data_format.wine_df = df; - /* create default properties */ - newDevice->generic.props = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwNumObjs*sizeof(ObjProps)); - if (newDevice->generic.props == 0) - goto FAILED; - /* initialize default properties */ for (i = 0; i < c_dfDIJoystick2.dwNumObjs; i++) { newDevice->generic.props[i].lDevMin = -32767; @@ -510,7 +505,6 @@ FAILED1: release_DataFormat(&newDevice->generic.base.data_format); HeapFree(GetProcessHeap(),0,newDevice->axis_map); HeapFree(GetProcessHeap(),0,newDevice->generic.name); - HeapFree(GetProcessHeap(),0,newDevice->generic.props); HeapFree(GetProcessHeap(),0,newDevice); *pdev = 0; diff --git a/dlls/dinput/joystick_osx.c b/dlls/dinput/joystick_osx.c index 1446b6e60ed..8d7f2095b41 100644 --- a/dlls/dinput/joystick_osx.c +++ b/dlls/dinput/joystick_osx.c @@ -724,11 +724,6 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di } newDevice->generic.base.data_format.wine_df = df; - /* create default properties */ - newDevice->generic.props = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwNumObjs*sizeof(ObjProps)); - if (newDevice->generic.props == 0) - goto FAILED; - /* initialize default properties */ get_osx_device_elements_props(newDevice); @@ -761,7 +756,6 @@ FAILED: HeapFree(GetProcessHeap(), 0, df); release_DataFormat(&newDevice->generic.base.data_format); HeapFree(GetProcessHeap(),0,newDevice->generic.name); - HeapFree(GetProcessHeap(),0,newDevice->generic.props); HeapFree(GetProcessHeap(),0,newDevice); *pdev = 0; diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h index d1f16667b3f..265c7f01914 100644 --- a/dlls/dinput/joystick_private.h +++ b/dlls/dinput/joystick_private.h @@ -29,6 +29,8 @@ #include "dinput_private.h" #include "device_private.h" +/* Number of objects in the default data format */ +#define MAX_PROPS 164 struct JoystickGenericImpl; typedef void joy_polldev_handler(struct JoystickGenericImpl *This); @@ -37,7 +39,7 @@ typedef struct JoystickGenericImpl { struct IDirectInputDevice2AImpl base; - ObjProps *props; + ObjProps props[MAX_PROPS]; DIDEVCAPS devcaps; DIJOYSTATE2 js; /* wine data */ GUID guidProduct;