diff options
author | Christian Hergert <christian@hergert.me> | 2015-09-13 03:20:02 -0700 |
---|---|---|
committer | Christian Hergert <christian@hergert.me> | 2015-09-13 03:20:02 -0700 |
commit | ca7bd22034dbcfd9d6454904b6a42f4b494a1b29 (patch) | |
tree | 482c240fae7d16af19689e04db3b2f63cac540bf | |
parent | 094785b790c3080ced41b0f7bec6e019b924dca0 (diff) | |
download | glib-ca7bd22034dbcfd9d6454904b6a42f4b494a1b29.tar.gz |
arraylist: add g_array_list_last()
-rw-r--r-- | glib/garraylist.h | 2 | ||||
-rw-r--r-- | glib/tests/arraylist.c | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/glib/garraylist.h b/glib/garraylist.h index b8859086f..43351bfd2 100644 --- a/glib/garraylist.h +++ b/glib/garraylist.h @@ -71,6 +71,8 @@ void g_array_list_remove_index (GArrayList *list, GLIB_AVAILABLE_IN_2_46 void g_array_list_destroy (GArrayList *list); +#define g_array_list_last(list) (((list)->len == 0) ? NULL : g_array_list_index((list),(list)->len-1)) + G_END_DECLS #endif /* __G_ARRAY_LIST_H__ */ diff --git a/glib/tests/arraylist.c b/glib/tests/arraylist.c index 8d92acb3d..81712c8d0 100644 --- a/glib/tests/arraylist.c +++ b/glib/tests/arraylist.c @@ -45,6 +45,8 @@ test_basic (GArrayList *al) g_assert_cmpint (al->len, ==, i); } + g_assert_cmpint (GPOINTER_TO_SIZE (g_array_list_last(al)), ==, 1000); + list = g_array_list_peek (al); for (iter = list; iter; iter = iter->next) |