From 60948ab1f07127431bc9a02f54736ecffaa4e686 Mon Sep 17 00:00:00 2001 From: Vitaliy Margolen Date: Tue, 9 Jan 2007 13:43:59 -0700 Subject: [PATCH] dinput: [joystick_linux] Reuse the same properties array. --- dlls/dinput/joystick_linux.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index e4a891d8118..c297f705c15 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -654,7 +654,6 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat( { JoystickImpl *This = (JoystickImpl *)iface; unsigned int i; - ObjProps * new_props = 0; HRESULT hr; TRACE("(%p,%p)\n",This,df); @@ -662,13 +661,8 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat( hr = IDirectInputDevice2AImpl_SetDataFormat(iface, df); if (FAILED(hr)) return hr; - new_props = HeapAlloc(GetProcessHeap(),0,df->dwNumObjs*sizeof(ObjProps)); - if (!new_props) return DIERR_OUTOFMEMORY; - - HeapFree(GetProcessHeap(),0,This->props); - - This->props = new_props; - for (i = 0; i < df->dwNumObjs; i++) { + for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) + { This->props[i].lMin = 0; This->props[i].lMax = 0xffff; This->props[i].lDeadZone = 1000; @@ -925,10 +919,10 @@ static HRESULT WINAPI JoystickAImpl_SetProperty( if (!HIWORD(rguid)) { switch (LOWORD(rguid)) { case (DWORD)DIPROP_RANGE: { - LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph; + LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph; if (ph->dwHow == DIPH_DEVICE) { TRACE("proprange(%d,%d) all\n", pr->lMin, pr->lMax); - for (i = 0; i < This->base.data_format.user_df->dwNumObjs; i++) { + for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) { This->props[i].lMin = pr->lMin; This->props[i].lMax = pr->lMax; } @@ -945,10 +939,10 @@ static HRESULT WINAPI JoystickAImpl_SetProperty( break; } case (DWORD)DIPROP_DEADZONE: { - LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph; + LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph; if (ph->dwHow == DIPH_DEVICE) { TRACE("deadzone(%d) all\n", pd->dwData); - for (i = 0; i < This->base.data_format.user_df->dwNumObjs; i++) + for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) This->props[i].lDeadZone = pd->dwData; } else { int obj = find_property(&This->base.data_format, ph); @@ -962,10 +956,10 @@ static HRESULT WINAPI JoystickAImpl_SetProperty( break; } case (DWORD)DIPROP_SATURATION: { - LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph; + LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph; if (ph->dwHow == DIPH_DEVICE) { TRACE("saturation(%d) all\n", pd->dwData); - for (i = 0; i < This->base.data_format.user_df->dwNumObjs; i++) + for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) This->props[i].lSaturation = pd->dwData; } else { int obj = find_property(&This->base.data_format, ph);