[gtk+] gdk: Use G_N_ELEMENTS() when iterating over constant arrays



commit 7e137b25245af2c086d40faba603351fa4f1006c
Author: Benjamin Otte <otte redhat com>
Date:   Sat Nov 4 23:58:17 2017 +0100

    gdk: Use G_N_ELEMENTS() when iterating over constant arrays
    
    And do that everywhere.
    
    Because if we don't, we're gonna crash sometimes.

 gdk/wayland/gdkcursor-wayland.c |    5 ++---
 gdk/x11/gdkcursor-x11.c         |    3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/gdk/wayland/gdkcursor-wayland.c b/gdk/wayland/gdkcursor-wayland.c
index a2ad42b..925e5b1 100644
--- a/gdk/wayland/gdkcursor-wayland.c
+++ b/gdk/wayland/gdkcursor-wayland.c
@@ -99,8 +99,7 @@ static const struct {
   { "nesw-resize",  "fd_double_arrow" },
   { "nwse-resize",  "bd_double_arrow" },
   { "zoom-in",      "left_ptr" },
-  { "zoom-out",     "left_ptr" },
-  { NULL, NULL }
+  { "zoom-out",     "left_ptr" }
 };
 
 static const gchar *
@@ -108,7 +107,7 @@ name_fallback (const gchar *name)
 {
   gint i;
 
-  for (i = 0; name_map[i].css_name; i++)
+  for (i = 0; i < G_N_ELEMENTS (name_map); i++)
     {
       if (g_str_equal (name_map[i].css_name, name))
         return name_map[i].traditional_name;
diff --git a/gdk/x11/gdkcursor-x11.c b/gdk/x11/gdkcursor-x11.c
index 90e6020..38f3dbf 100644
--- a/gdk/x11/gdkcursor-x11.c
+++ b/gdk/x11/gdkcursor-x11.c
@@ -140,8 +140,7 @@ static const struct {
   { "nesw-resize",  "fd_double_arrow",     XC_X_cursor },
   { "nwse-resize",  "bd_double_arrow",     XC_X_cursor },
   { "zoom-in",      "left_ptr",            XC_draped_box },
-  { "zoom-out",     "left_ptr",            XC_draped_box },
-  { NULL, NULL, XC_X_cursor }
+  { "zoom-out",     "left_ptr",            XC_draped_box }
 };
 
 #ifdef HAVE_XCURSOR


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]