Added list_contains feature
This commit is contained in:
parent
a7bc3aac8d
commit
9327edb91f
@ -324,4 +324,26 @@ list_item_next(void *item)
|
||||
return item == NULL ? NULL : ((struct list *)item)->next;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Check if the list contains an item
|
||||
* \param list The list that is checked
|
||||
* \param item An item to look for in the list
|
||||
* \returns 0 if the list does not contains the item, and 1 otherwise
|
||||
*
|
||||
* This function searches for an item in the list and returns
|
||||
* 0 if the list does not contain the item, and 1 if the item
|
||||
* is present in the list.
|
||||
*/
|
||||
int
|
||||
list_contains(list_t list, void *item)
|
||||
{
|
||||
struct list *l;
|
||||
for(l = *list; l != NULL; l = l->next) {
|
||||
if(item == l) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
@ -151,6 +151,8 @@ void list_insert(list_t list, void *previtem, void *newitem);
|
||||
|
||||
void * list_item_next(void *item);
|
||||
|
||||
int list_contains(list_t list, void *item);
|
||||
|
||||
#endif /* LIST_H_ */
|
||||
|
||||
/** @} */
|
||||
|
Loading…
Reference in New Issue
Block a user