Messages in this thread Patch in this message | | | From | Dmitry Torokhov <> | Subject | [RFC/PATCH] Introduce list_get() and list_get_tail() | Date | Sat, 8 Jul 2006 01:24:21 -0400 |
| |
From: Dmitry Torokhov <dtor@mail.ru>
Add primitives to access first and last elements of a list instead of accessng pointers directly.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru> ---
We have primitives to iterate over lists and to add/delete elements, why not for accessing head/tail?
include/linux/list.h | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+)
Index: work/include/linux/list.h =================================================================== --- work.orig/include/linux/list.h +++ work/include/linux/list.h @@ -571,6 +571,24 @@ static inline void list_splice_init(stru prefetch(rcu_dereference((pos))->next), (pos) != (head); \ (pos) = (pos)->next) +/** + * list_get - get first element in a list + * @head: the head of your list + */ +static inline struct list_head *list_get(struct list_head *head) +{ + return head->next; +} + +/** + * list_get_tail - get last element in a list + * @head: the head of your list + */ +static inline struct list_head *list_get_tail(struct list_head *head) +{ + return head->prev; +} + /* * Double linked lists with a single pointer list head. * Mostly useful for hash tables where the two pointer list head is - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |