[PATCH] winex11.drv: Avoid ARRAY_SIZE-like macros

Michael Stefaniuc mstefani at winehq.org
Sat Jul 7 16:39:08 CDT 2018


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 dlls/winex11.drv/clipboard.c | 10 +++++-----
 dlls/winex11.drv/desktop.c   |  5 ++---
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
index c55a2661fb..296c00c3a5 100644
--- a/dlls/winex11.drv/clipboard.c
+++ b/dlls/winex11.drv/clipboard.c
@@ -187,7 +187,6 @@ static const struct
 
 static struct list format_list = LIST_INIT( format_list );
 
-#define NB_BUILTIN_FORMATS (sizeof(builtin_formats) / sizeof(builtin_formats[0]))
 #define GET_ATOM(prop)  (((prop) < FIRST_XATOM) ? (Atom)(prop) : X11DRV_Atoms[(prop) - FIRST_XATOM])
 
 static DWORD clipboard_thread_id;
@@ -295,9 +294,9 @@ static void register_builtin_formats(void)
     struct clipboard_format *formats;
     unsigned int i;
 
-    if (!(formats = HeapAlloc( GetProcessHeap(), 0, NB_BUILTIN_FORMATS * sizeof(*formats)))) return;
+    if (!(formats = HeapAlloc( GetProcessHeap(), 0, ARRAY_SIZE(builtin_formats) * sizeof(*formats)))) return;
 
-    for (i = 0; i < NB_BUILTIN_FORMATS; i++)
+    for (i = 0; i < ARRAY_SIZE(builtin_formats); i++)
     {
         if (builtin_formats[i].name)
             formats[i].id = RegisterClipboardFormatW( builtin_formats[i].name );
@@ -983,7 +982,7 @@ static HANDLE import_targets( Atom type, const void *data, size_t size )
     register_x11_formats( properties, count );
 
     /* the builtin formats contain duplicates, so allocate some extra space */
-    if (!(formats = HeapAlloc( GetProcessHeap(), 0, (count + NB_BUILTIN_FORMATS) * sizeof(*formats ))))
+    if (!(formats = HeapAlloc( GetProcessHeap(), 0, (count + ARRAY_SIZE(builtin_formats)) * sizeof(*formats ))))
         return 0;
 
     pos = 0;
@@ -1454,7 +1453,8 @@ static BOOL export_targets( Display *display, Window win, Atom prop, Atom target
     if (!(formats = get_clipboard_formats( &count ))) return FALSE;
 
     /* the builtin formats contain duplicates, so allocate some extra space */
-    if (!(targets = HeapAlloc( GetProcessHeap(), 0, (count + NB_BUILTIN_FORMATS) * sizeof(*targets) )))
+    if (!(targets = HeapAlloc( GetProcessHeap(), 0,
+                               (count + ARRAY_SIZE(builtin_formats)) * sizeof(*targets) )))
     {
         HeapFree( GetProcessHeap(), 0, formats );
         return FALSE;
diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c
index 4df8784a97..559efe2beb 100644
--- a/dlls/winex11.drv/desktop.c
+++ b/dlls/winex11.drv/desktop.c
@@ -73,7 +73,6 @@ static struct screen_size {
     {1920, 1200},
     {2560, 1600}
 };
-#define NUM_DESKTOP_MODES (sizeof(screen_sizes) / sizeof(struct screen_size))
 
 #define _NET_WM_STATE_REMOVE 0
 #define _NET_WM_STATE_ADD 1
@@ -88,7 +87,7 @@ static void make_modes(void)
 
     /* original specified desktop size */
     X11DRV_Settings_AddOneMode(screen_width, screen_height, 0, 60);
-    for (i=0; i<NUM_DESKTOP_MODES; i++)
+    for (i=0; i<ARRAY_SIZE(screen_sizes); i++)
     {
         if ( (screen_sizes[i].width <= max_width) && (screen_sizes[i].height <= max_height) )
         {
@@ -160,7 +159,7 @@ void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height )
     dd_modes = X11DRV_Settings_SetHandlers("desktop", 
                                            X11DRV_desktop_GetCurrentMode, 
                                            X11DRV_desktop_SetCurrentMode, 
-                                           NUM_DESKTOP_MODES+2, 1);
+                                           ARRAY_SIZE(screen_sizes)+2, 1);
     make_modes();
     X11DRV_Settings_AddDepthModes();
     dd_mode_count = X11DRV_Settings_GetModeCount();
-- 
2.14.4




More information about the wine-devel mailing list