Jacek Caban : user32: Use CreateAcceleratorTableW in CreateAcceleratorTableA.
Alexandre Julliard
julliard at winehq.org
Wed Mar 2 15:39:51 CST 2022
Module: wine
Branch: master
Commit: e58b561ced05410f638927540544fbe84b47906e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=e58b561ced05410f638927540544fbe84b47906e
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Mar 2 15:06:17 2022 +0100
user32: Use CreateAcceleratorTableW in CreateAcceleratorTableA.
Instead of accessing accelerators object directly.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/resource.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/dlls/user32/resource.c b/dlls/user32/resource.c
index ce64833e413..7c15e1905a5 100644
--- a/dlls/user32/resource.c
+++ b/dlls/user32/resource.c
@@ -152,10 +152,10 @@ INT WINAPI CopyAcceleratorTableW(HACCEL src, LPACCEL dst, INT count)
/*********************************************************************
* CreateAcceleratorTableA (USER32.@)
*/
-HACCEL WINAPI CreateAcceleratorTableA(LPACCEL lpaccel, INT count)
+HACCEL WINAPI CreateAcceleratorTableA( ACCEL *accel, INT count )
{
- struct accelerator *accel;
HACCEL handle;
+ ACCEL *table;
int i;
if (count < 1)
@@ -163,22 +163,21 @@ HACCEL WINAPI CreateAcceleratorTableA(LPACCEL lpaccel, INT count)
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
- accel = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( struct accelerator, table[count] ));
- if (!accel) return 0;
- accel->count = count;
+ table = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*table) );
+ if (!table) return 0;
for (i = 0; i < count; i++)
{
- accel->table[i].fVirt = lpaccel[i].fVirt;
- accel->table[i].cmd = lpaccel[i].cmd;
- if (!(lpaccel[i].fVirt & FVIRTKEY))
+ table[i].fVirt = accel[i].fVirt;
+ table[i].cmd = accel[i].cmd;
+ if (!(accel[i].fVirt & FVIRTKEY))
{
- char ch = lpaccel[i].key;
- MultiByteToWideChar( CP_ACP, 0, &ch, 1, &accel->table[i].key, 1 );
+ char ch = accel[i].key;
+ 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 )))
- HeapFree( GetProcessHeap(), 0, accel );
+ handle = CreateAcceleratorTableW( table, count );
+ HeapFree( GetProcessHeap(), 0, table );
TRACE_(accel)("returning %p\n", handle );
return handle;
}
More information about the wine-cvs
mailing list