Jacek Caban : user32: Use ACCEL struct in accelerator object.

Alexandre Julliard julliard at winehq.org
Wed Mar 2 15:39:50 CST 2022


Module: wine
Branch: master
Commit: dadace10ec7bd9768037b78a5613bbbc724cef1a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=dadace10ec7bd9768037b78a5613bbbc724cef1a

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Mar  2 15:05:44 2022 +0100

user32: Use ACCEL struct in accelerator object.

Instead of PE_ACCEL.

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, 13 insertions(+), 12 deletions(-)

diff --git a/dlls/user32/resource.c b/dlls/user32/resource.c
index 81f717c29cc..912b7f95227 100644
--- a/dlls/user32/resource.c
+++ b/dlls/user32/resource.c
@@ -46,7 +46,7 @@ struct accelerator
 {
     struct user_object obj;
     unsigned int       count;
-    PE_ACCEL           table[1];
+    ACCEL              table[1];
 };
 
 /**********************************************************************
@@ -55,19 +55,25 @@ struct accelerator
 HACCEL WINAPI LoadAcceleratorsW(HINSTANCE instance, LPCWSTR name)
 {
     struct accelerator *accel;
-    const PE_ACCEL *table;
+    const PE_ACCEL *pe_table;
+    unsigned int i;
     HRSRC rsrc;
     HACCEL handle;
     DWORD count;
 
     if (!(rsrc = FindResourceW( instance, name, (LPWSTR)RT_ACCELERATOR ))) return 0;
-    table = LoadResource( instance, rsrc );
-    count = SizeofResource( instance, rsrc ) / sizeof(*table);
+    pe_table = LoadResource( instance, rsrc );
+    count = SizeofResource( instance, rsrc ) / sizeof(*pe_table);
     if (!count) return 0;
     accel = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( struct accelerator, table[count] ));
     if (!accel) return 0;
     accel->count = count;
-    memcpy( accel->table, table, count * sizeof(*table) );
+    for (i = 0; i < count; i++)
+    {
+        accel->table[i].fVirt = pe_table[i].fVirt;
+        accel->table[i].key   = pe_table[i].key;
+        accel->table[i].cmd   = pe_table[i].cmd;
+    }
     if (!(handle = alloc_user_handle( &accel->obj, NTUSER_OBJ_ACCEL )))
         HeapFree( GetProcessHeap(), 0, accel );
     TRACE_(accel)("%p %s returning %p\n", instance, debugstr_w(name), handle );
@@ -185,7 +191,6 @@ HACCEL WINAPI CreateAcceleratorTableW(LPACCEL lpaccel, INT count)
 {
     struct accelerator *accel;
     HACCEL handle;
-    int i;
 
     if (count < 1)
     {
@@ -195,12 +200,8 @@ HACCEL WINAPI CreateAcceleratorTableW(LPACCEL lpaccel, INT count)
     accel = HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( struct accelerator, table[count] ));
     if (!accel) return 0;
     accel->count = count;
-    for (i = 0; i < count; i++)
-    {
-        accel->table[i].fVirt = lpaccel[i].fVirt;
-        accel->table[i].key   = lpaccel[i].key;
-        accel->table[i].cmd   = lpaccel[i].cmd;
-    }
+    memcpy( accel->table, lpaccel, count * sizeof(*lpaccel) );
+
     if (!(handle = alloc_user_handle( &accel->obj, NTUSER_OBJ_ACCEL )))
         HeapFree( GetProcessHeap(), 0, accel );
     TRACE_(accel)("returning %p\n", handle );




More information about the wine-cvs mailing list