[Mesa-dev] [RFC 1/2] glsl/list: Add an iteration helper that starts after the given node
Kenneth Graunke
kenneth at whitecape.org
Mon Sep 19 05:27:37 UTC 2016
On Thursday, September 15, 2016 9:00:35 PM PDT Jason Ekstrand wrote:
> ---
> src/compiler/glsl/list.h | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/src/compiler/glsl/list.h b/src/compiler/glsl/list.h
> index b5b5b36..8371519 100644
> --- a/src/compiler/glsl/list.h
> +++ b/src/compiler/glsl/list.h
> @@ -714,6 +714,15 @@ inline void exec_node::insert_before(exec_list *before)
> __node = __next, __next = \
> exec_node_data(__type, (__next)->__field.next, __field))
>
Perhaps add:
/* __after must be a valid list node (not the tail sentinel) */
(if after is the tail sentinel, __node will be NULL, and then trying to
obtain (__node)->__field.next will dereference that NULL pointer.)
Either way, patch 1 is
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
(I haven't thought about patch 2, sorry)
> +#define foreach_list_typed_safe_after(__type, __node, __field, __after) \
> + for (__type * __node = \
> + exec_node_data(__type, (__after)->__field.next, __field), \
> + * __next = \
> + exec_node_data(__type, (__node)->__field.next, __field); \
> + (__node)->__field.next != NULL; \
> + __node = __next, __next = \
> + exec_node_data(__type, (__next)->__field.next, __field))
> +
> #define foreach_list_typed_reverse_safe(__type, __node, __field, __list) \
> for (__type * __node = \
> exec_node_data(__type, (__list)->tail_sentinel.prev, __field), \
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160918/dec0a02e/attachment.sig>
More information about the mesa-dev
mailing list