gdk: Use G_N_ELEMENTS() when iterating over constant arrays

And do that everywhere.

Because if we don't, we're gonna crash sometimes.
This commit is contained in:
Benjamin Otte 2017-11-04 23:58:17 +01:00
parent d092e8dd78
commit 7e137b2524
2 changed files with 3 additions and 5 deletions

View File

@ -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;

View File

@ -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