user32: Use CreateAcceleratorTableW in CreateAcceleratorTableA.

Instead of accessing accelerators object directly.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-03-02 15:06:17 +01:00 committed by Alexandre Julliard
parent ec036bc605
commit e58b561ced
1 changed files with 12 additions and 13 deletions

View File

@ -152,10 +152,10 @@ INT WINAPI CopyAcceleratorTableW(HACCEL src, LPACCEL dst, INT count)
/********************************************************************* /*********************************************************************
* CreateAcceleratorTableA (USER32.@) * CreateAcceleratorTableA (USER32.@)
*/ */
HACCEL WINAPI CreateAcceleratorTableA(LPACCEL lpaccel, INT count) HACCEL WINAPI CreateAcceleratorTableA( ACCEL *accel, INT count )
{ {
struct accelerator *accel;
HACCEL handle; HACCEL handle;
ACCEL *table;
int i; int i;
if (count < 1) if (count < 1)
@ -163,22 +163,21 @@ HACCEL WINAPI CreateAcceleratorTableA(LPACCEL lpaccel, INT count)
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
return 0; return 0;
} }
accel = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( struct accelerator, table[count] )); table = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*table) );
if (!accel) return 0; if (!table) return 0;
accel->count = count;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
accel->table[i].fVirt = lpaccel[i].fVirt; table[i].fVirt = accel[i].fVirt;
accel->table[i].cmd = lpaccel[i].cmd; table[i].cmd = accel[i].cmd;
if (!(lpaccel[i].fVirt & FVIRTKEY)) if (!(accel[i].fVirt & FVIRTKEY))
{ {
char ch = lpaccel[i].key; char ch = accel[i].key;
MultiByteToWideChar( CP_ACP, 0, &ch, 1, &accel->table[i].key, 1 ); MultiByteToWideChar( CP_ACP, 0, &ch, 1, &table[i].key, 1 );
} }
else accel->table[i].key = lpaccel[i].key; else table[i].key = accel[i].key;
} }
if (!(handle = alloc_user_handle( &accel->obj, NTUSER_OBJ_ACCEL ))) handle = CreateAcceleratorTableW( table, count );
HeapFree( GetProcessHeap(), 0, accel ); HeapFree( GetProcessHeap(), 0, table );
TRACE_(accel)("returning %p\n", handle ); TRACE_(accel)("returning %p\n", handle );
return handle; return handle;
} }