mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-30 23:28:06 +02:00
exec_list: Add foreach_list_typed and foreach_list_typed_const
These variations are parameterized by the type of the nodes in the list. This enables skipping the explicit usage of exec_node_data in the loop body.
This commit is contained in:
parent
304ea90233
commit
4cfbad9e4d
1 changed files with 12 additions and 0 deletions
12
list.h
12
list.h
|
|
@ -347,4 +347,16 @@ struct exec_list {
|
|||
; (__node)->next != NULL \
|
||||
; (__node) = (__node)->next)
|
||||
|
||||
#define foreach_list_typed(__type, __node, __field, __list) \
|
||||
for (__type * __node = \
|
||||
exec_node_data(__type, (__list)->head, __field); \
|
||||
(__node)->__field.next != NULL; \
|
||||
(__node) = exec_node_data(__type, (__node)->__field.next, __field))
|
||||
|
||||
#define foreach_list_typed_const(__type, __node, __field, __list) \
|
||||
for (const __type * __node = \
|
||||
exec_node_data(__type, (__list)->head, __field); \
|
||||
(__node)->__field.next != NULL; \
|
||||
(__node) = exec_node_data(__type, (__node)->__field.next, __field))
|
||||
|
||||
#endif /* LIST_CONTAINER_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue