From: Zebediah Figura zfigura@codeweavers.com
Rename it to dinput_device_init() accordingly.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/device.c | 11 ++--------- dlls/dinput/device_private.h | 4 ++-- dlls/dinput/joystick_hid.c | 4 ++-- dlls/dinput/keyboard.c | 5 ++--- dlls/dinput/mouse.c | 5 ++--- 5 files changed, 10 insertions(+), 19 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 6af1500ab64..9e7cb20453c 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -2144,13 +2144,9 @@ static const IDirectInputDevice8WVtbl dinput_device_w_vtbl = dinput_device_GetImageInfo, };
-HRESULT dinput_device_alloc( SIZE_T size, const struct dinput_device_vtbl *vtbl, const GUID *guid, - struct dinput *dinput, void **out ) +void dinput_device_init( struct dinput_device *device, const struct dinput_device_vtbl *vtbl, + const GUID *guid, struct dinput *dinput ) { - struct dinput_device *device; - - if (!(device = calloc( 1, size ))) return DIERR_OUTOFMEMORY; - device->IDirectInputDevice8A_iface.lpVtbl = &dinput_device_a_vtbl; device->IDirectInputDevice8W_iface.lpVtbl = &dinput_device_w_vtbl; device->ref = 1; @@ -2164,9 +2160,6 @@ HRESULT dinput_device_alloc( SIZE_T size, const struct dinput_device_vtbl *vtbl, device->dinput = dinput; IDirectInput_AddRef( &dinput->IDirectInput7A_iface ); device->vtbl = vtbl; - - *out = device; - return DI_OK; }
static const GUID *object_instance_guid( const DIDEVICEOBJECTINSTANCEW *instance ) diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index 772c5d35786..31696f00536 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -123,8 +123,8 @@ struct dinput_device struct object_properties *object_properties; };
-extern HRESULT dinput_device_alloc( SIZE_T size, const struct dinput_device_vtbl *vtbl, const GUID *guid, - struct dinput *dinput, void **out ) DECLSPEC_HIDDEN; +extern void dinput_device_init( struct dinput_device *device, const struct dinput_device_vtbl *vtbl, + const GUID *guid, struct dinput *dinput ); extern HRESULT dinput_device_init_device_format( IDirectInputDevice8W *iface ); extern void dinput_device_destroy( IDirectInputDevice8W *iface );
diff --git a/dlls/dinput/joystick_hid.c b/dlls/dinput/joystick_hid.c index 017755f3feb..5fdc563054b 100644 --- a/dlls/dinput/joystick_hid.c +++ b/dlls/dinput/joystick_hid.c @@ -2049,8 +2049,8 @@ HRESULT hid_joystick_create_device( struct dinput *dinput, const GUID *guid, IDi if (!IsEqualGUID( &device_path_guid, &instance.guidInstance )) return DIERR_DEVICENOTREG; }
- hr = dinput_device_alloc( sizeof(struct hid_joystick), &hid_joystick_vtbl, guid, dinput, (void **)&impl ); - if (FAILED(hr)) return hr; + if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; + dinput_device_init( &impl->base, &hid_joystick_vtbl, guid, dinput ); impl->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": hid_joystick.base.crit"); impl->base.dwCoopLevel = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND; impl->base.read_event = CreateEventW( NULL, TRUE, FALSE, NULL ); diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index f8f7a5a3195..873a2d98434 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -167,15 +167,14 @@ HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instan HRESULT keyboard_create_device( struct dinput *dinput, const GUID *guid, IDirectInputDevice8W **out ) { struct keyboard *impl; - HRESULT hr;
TRACE( "dinput %p, guid %s, out %p.\n", dinput, debugstr_guid( guid ), out );
*out = NULL; if (!IsEqualGUID( &GUID_SysKeyboard, guid )) return DIERR_DEVICENOTREG;
- if (FAILED(hr = dinput_device_alloc( sizeof(struct keyboard), &keyboard_vtbl, guid, dinput, (void **)&impl ))) - return hr; + if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; + dinput_device_init( &impl->base, &keyboard_vtbl, guid, dinput ); impl->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": struct keyboard*->base.crit");
keyboard_enum_device( 0, 0, &impl->base.instance, dinput->dwVersion ); diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c index 622dc1994d1..1572e73bac2 100644 --- a/dlls/dinput/mouse.c +++ b/dlls/dinput/mouse.c @@ -96,15 +96,14 @@ HRESULT mouse_create_device( struct dinput *dinput, const GUID *guid, IDirectInp struct mouse *impl; HKEY hkey, appkey; WCHAR buffer[20]; - HRESULT hr;
TRACE( "dinput %p, guid %s, out %p\n", dinput, debugstr_guid( guid ), out );
*out = NULL; if (!IsEqualGUID( &GUID_SysMouse, guid )) return DIERR_DEVICENOTREG;
- if (FAILED(hr = dinput_device_alloc( sizeof(struct mouse), &mouse_vtbl, guid, dinput, (void **)&impl ))) - return hr; + if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY; + dinput_device_init( &impl->base, &mouse_vtbl, guid, dinput ); impl->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": struct mouse*->base.crit");
mouse_enum_device( 0, 0, &impl->base.instance, dinput->dwVersion );