diff options
Diffstat (limited to 'glib/glist.c')
-rw-r--r-- | glib/glist.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/glib/glist.c b/glib/glist.c index 70a97ea2db..a24751cbc3 100644 --- a/glib/glist.c +++ b/glib/glist.c @@ -33,7 +33,7 @@ static GRealListAllocator *current_allocator = NULL; GListAllocator* -g_list_allocator_new () +g_list_allocator_new (void) { GRealListAllocator* allocator = g_new (GRealListAllocator, 1); @@ -80,7 +80,7 @@ g_list_set_allocator (GListAllocator* fallocator) GList* -g_list_alloc () +g_list_alloc (void) { GList *new_list; @@ -300,6 +300,16 @@ g_list_nth (GList *list, return list; } +gpointer +g_list_nth_data (GList *list, + guint n) +{ + while ((n-- > 0) && list) + list = list->next; + + return list ? list->data : NULL; +} + GList* g_list_find (GList *list, gpointer data) @@ -314,6 +324,42 @@ g_list_find (GList *list, return list; } +gint +g_list_position (GList *list, + GList *link) +{ + gint i; + + i = 0; + while (list) + { + if (list == link) + return i; + i++; + list = list->next; + } + + return -1; +} + +gint +g_list_index (GList *list, + gpointer data) +{ + gint i; + + i = 0; + while (list) + { + if (list->data == data) + return i; + i++; + list = list->next; + } + + return -1; +} + GList* g_list_last (GList *list) { |