From 6b3ae7e7b7b001b6d4dfd78d49e07f115e05ae64 Mon Sep 17 00:00:00 2001 From: Ed Kellett Date: Wed, 21 Oct 2020 20:29:26 +0100 Subject: [PATCH] Add a comment explaining ITER_COMM_CHANNELS --- include/channel.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/include/channel.h b/include/channel.h index fe8c566c..cce63c28 100644 --- a/include/channel.h +++ b/include/channel.h @@ -204,9 +204,24 @@ int iter_comm_channels_step(rb_dlink_node *pos1, rb_dlink_node *pos2, struct membership **ms1, struct membership **ms2, struct Channel **chptr); -#define ITER_COMM_CHANNELS(pos1, pos2, head1, head2, ms1, ms2, chptr) for ((pos1) = (head1), (pos2) = (head2); \ - iter_comm_channels_step((pos1), (pos2), &(ms1), &(ms2), &(chptr)); \ - (ms1) && ((pos1) = (pos1)->next), (ms2) && ((pos2) = (pos2)->next)) + +/* Iterate two sorted linked lists of channels, with heads headN, in lockstep. + At each iteration, chptr will be a channel in at least one of the lists, + and each msN will be non-null iff the channel is in its corresponding list. + + head1 and head2 must be linked list heads. + pos1, pos2, ms1, ms2 must be names of modifiable variables, and should not + be modified during iteration. It is safe to break or continue at any point + without any special cleanup. + + rb_dlink_node_t *pos1, *pos2, *head1, *head2; + struct membership *ms1, *ms2; + struct Channel *chptr; +*/ +#define ITER_COMM_CHANNELS(pos1, pos2, head1, head2, ms1, ms2, chptr) \ + for ((pos1) = (head1), (pos2) = (head2); \ + iter_comm_channels_step((pos1), (pos2), &(ms1), &(ms2), &(chptr)); \ + (ms1) && ((pos1) = (pos1)->next), (ms2) && ((pos2) = (pos2)->next)) extern rb_dlink_list global_channel_list;