From f62d3b77aacc87f0781b37996e3ae54691530a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 21 Jun 2006 16:13:34 +0000 Subject: [PATCH] Added a list_get_last_item() call - one day we should make most of them inline. Or use the C++ list implementation where possible. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17901 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/util/list.h | 1 + src/system/kernel/util/list.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/headers/private/kernel/util/list.h b/headers/private/kernel/util/list.h index 4a523cd14b..79fce6b3b1 100644 --- a/headers/private/kernel/util/list.h +++ b/headers/private/kernel/util/list.h @@ -48,6 +48,7 @@ extern void list_add_link_to_tail(struct list *list, void *_link); extern void list_remove_link(void *_link); extern void *list_get_next_item(struct list *list, void *item); extern void *list_get_prev_item(struct list *list, void *item); +extern void *list_get_last_item(struct list *list); extern void list_add_item(struct list *list, void *item); extern void list_remove_item(struct list *list, void *item); extern void list_insert_item_before(struct list *list, void *before, void *item); diff --git a/src/system/kernel/util/list.c b/src/system/kernel/util/list.c index 36ef598df1..ce7cc1d853 100644 --- a/src/system/kernel/util/list.c +++ b/src/system/kernel/util/list.c @@ -134,6 +134,13 @@ list_get_prev_item(struct list *list, void *item) } +void * +list_get_last_item(struct list *list) +{ + return list_is_empty(list) ? NULL : GET_ITEM(list, list->link.prev); +} + + /** Adds an item to the end of the list. * Similar to list_add_link_to_tail() but works on the item, not the link. */