Added a function for obtaining the next item on the list. This makes list iterations nicer, as the ->next pointer now is hidden within the list abstraction.
This commit is contained in:
parent
01b1359b1f
commit
a84cc7c8a0
2 changed files with 20 additions and 2 deletions
|
@ -43,7 +43,7 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $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;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue