[Spice-devel] [server PATCH 7/8] red_worker: use a generic SAFE_FOREACH macro
Uri Lublin
uril at redhat.com
Mon Jul 8 09:29:14 PDT 2013
On 07/08/2013 01:57 PM, Christophe Fergeau wrote:
> On Mon, Jul 08, 2013 at 01:32:29PM +0300, Uri Lublin wrote:
>> Introduce SAFE_FOREACH macro
>>
>> Make other safe iterators use SAFE_FOREACH
> There's already a RING_FOREACH_SAFE() macro in spice-common/ring.h, could
> it be useful here?
>
Hi Christophe,
Thanks for the review.
These macros in red_worker.c are similar to using RING_FOREACH_SAFE, but
offer some convenience.
For example, the following are equivalent:
RCC_FOREACH_SAFE(link, next, rcc, channel) {
f(rcc);
}
----------------
if (channel)
RING_FOREACH_SAFE(link, next, &(channel)->clients) {
rcc = SPICE_CONTAINEROF(link, RedChannelClient, channel_link);
f(rcc);
}
And the following are equivalent:
WORKER_FOREACH_DCC_SAFE(worker, link, next, dcc) {
g(dcc)
}
-------------------
if (worker && worker->display_channel)
RING_FOREACH_SAFE(link, next,
&(worker)->display_channel->common.base.clients) {
dcc = SPICE_CONTAINEROF(link, DisplayChannelClient,
common.base.channel_link);
g(dcc);
}
Thanks,
Uri.
More information about the Spice-devel
mailing list