dinput: Don't copy no longer used user data format object array.

This commit is contained in:
Vitaliy Margolen 2007-01-09 13:45:00 -07:00 committed by Alexandre Julliard
parent da78a7af5e
commit a1dd4cb76a

View file

@ -288,8 +288,6 @@ void release_DataFormat(DataFormat * format)
format->dt = NULL;
HeapFree(GetProcessHeap(), 0, format->offsets);
format->offsets = NULL;
if (format->user_df)
HeapFree(GetProcessHeap(), 0, format->user_df->rgodf);
HeapFree(GetProcessHeap(), 0, format->user_df);
format->user_df = NULL;
}
@ -300,48 +298,6 @@ inline LPDIOBJECTDATAFORMAT dataformat_to_odf(LPCDIDATAFORMAT df, int idx)
return (LPDIOBJECTDATAFORMAT)((LPBYTE)df->rgodf + idx * df->dwObjSize);
}
/* Make all instances sequential */
static void calculate_ids(LPDIDATAFORMAT df)
{
int i, axis = 0, pov = 0, button = 0;
int axis_base, pov_base, button_base;
DWORD type;
/* Make two passes over the format. The first counts the number
* for each type and the second sets the id */
for (i = 0; i < df->dwNumObjs; i++)
{
type = DIDFT_GETTYPE(df->rgodf[i].dwType);
if (type & DIDFT_AXIS) axis++;
else if (type & DIDFT_POV) pov++;
else if (type & DIDFT_BUTTON) button++;
}
axis_base = 0;
pov_base = axis_base + axis;
button_base = pov_base + pov;
axis = pov = button = 0;
for (i = 0; i < df->dwNumObjs; i++)
{
type = DIDFT_GETTYPE(df->rgodf[i].dwType);
if (type & DIDFT_AXIS)
{
type |= DIDFT_MAKEINSTANCE(axis_base + axis++);
TRACE("axis type = 0x%08x\n", type);
} else if (type & DIDFT_POV)
{
type |= DIDFT_MAKEINSTANCE(pov_base + pov++);
TRACE("POV type = 0x%08x\n", type);
} else if (type & DIDFT_BUTTON)
{
type |= DIDFT_MAKEINSTANCE(button_base + button++);
TRACE("button type = 0x%08x\n", type);
}
df->rgodf[i].dwType = type;
}
}
HRESULT create_DataFormat(LPCDIDATAFORMAT asked_format, DataFormat *format)
{
DataTransform *dt;
@ -363,10 +319,6 @@ HRESULT create_DataFormat(LPCDIDATAFORMAT asked_format, DataFormat *format)
goto failed;
memcpy(format->user_df, asked_format, asked_format->dwSize);
if (!(format->user_df->rgodf = HeapAlloc(GetProcessHeap(), 0, asked_format->dwNumObjs*asked_format->dwObjSize)))
goto failed;
memcpy(format->user_df->rgodf, asked_format->rgodf, asked_format->dwNumObjs*asked_format->dwObjSize);
TRACE("Creating DataTransform :\n");
for (i = 0; i < format->wine_df->dwNumObjs; i++)
@ -469,8 +421,6 @@ HRESULT create_DataFormat(LPCDIDATAFORMAT asked_format, DataFormat *format)
HeapFree(GetProcessHeap(), 0, done);
/* Last step - reset all instances of the new format */
calculate_ids(format->user_df);
return DI_OK;
failed:
@ -479,8 +429,6 @@ failed:
format->dt = NULL;
HeapFree(GetProcessHeap(), 0, format->offsets);
format->offsets = NULL;
if (format->user_df)
HeapFree(GetProcessHeap(), 0, format->user_df->rgodf);
HeapFree(GetProcessHeap(), 0, format->user_df);
format->user_df = NULL;