diff --git a/core/lib/list.c b/core/lib/list.c index 3a1ecc5f9..c37041692 100644 --- a/core/lib/list.c +++ b/core/lib/list.c @@ -43,7 +43,7 @@ * * Author: Adam Dunkels * - * $Id: list.c,v 1.4 2010/04/30 07:18:24 adamdunkels Exp $ + * $Id: list.c,v 1.5 2010/06/15 18:54:27 adamdunkels Exp $ */ #include "lib/list.h" @@ -311,4 +311,20 @@ list_insert(list_t list, void *previtem, void *newitem) } } /*---------------------------------------------------------------------------*/ +/** + * \brief Get the next item following this item + * \param item A list item + * \returns A next item on the list + * + * This function takes a list item and returns the next + * item on the list, or NULL if there are no more items on + * the list. This function is used when iterating through + * lists. + */ +void * +list_item_next(void *item) +{ + return item == NULL? NULL: ((struct list *)item)->next; +} +/*---------------------------------------------------------------------------*/ /** @} */ diff --git a/core/lib/list.h b/core/lib/list.h index d7dad5073..f98364be3 100644 --- a/core/lib/list.h +++ b/core/lib/list.h @@ -64,7 +64,7 @@ * * Author: Adam Dunkels * - * $Id: list.h,v 1.3 2009/05/06 15:07:35 adamdunkels Exp $ + * $Id: list.h,v 1.4 2010/06/15 18:54:27 adamdunkels Exp $ */ #ifndef __LIST_H__ #define __LIST_H__ @@ -113,6 +113,8 @@ void list_copy(list_t dest, list_t src); void list_insert(list_t list, void *previtem, void *newitem); +void * list_item_next(void *item); + #endif /* __LIST_H__ */ /** @} */