mirror of
https://github.com/xcat2/xNBA.git
synced 2025-01-19 05:53:16 +00:00
Add list_for_each_entry_safe.
This commit is contained in:
parent
ceba6ecb75
commit
7cd0390013
@ -138,8 +138,23 @@ static inline int list_empty ( const struct list_head *head ) {
|
||||
* @v member The name of the list_struct within the struct
|
||||
*/
|
||||
#define list_for_each_entry( pos, head, member ) \
|
||||
for ( pos = list_entry ( (head)->next, typeof ( *pos ), member); \
|
||||
for ( pos = list_entry ( (head)->next, typeof ( *pos ), member ); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry ( pos->member.next, typeof ( *pos ), member ) )
|
||||
|
||||
/**
|
||||
* Iterate over entries in a list, safe against deletion of entries
|
||||
*
|
||||
* @v pos The type * to use as a loop counter
|
||||
* @v tmp Another type * to use for temporary storage
|
||||
* @v head The head for your list
|
||||
* @v member The name of the list_struct within the struct
|
||||
*/
|
||||
#define list_for_each_entry_safe( pos, tmp, head, member ) \
|
||||
for ( pos = list_entry ( (head)->next, typeof ( *pos ), member ), \
|
||||
tmp = list_entry ( pos->member.next, typeof ( *tmp ), member ); \
|
||||
&pos->member != (head); \
|
||||
pos = tmp, \
|
||||
tmp = list_entry ( tmp->member.next, typeof ( *tmp ), member ) )
|
||||
|
||||
#endif /* _GPXE_LIST_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user