[dpdk-dev] [PATCH 1/2] eal: add stailq safe iterator macro

Thomas Monjalon thomas.monjalon at 6wind.com
Fri Jul 22 18:16:28 CEST 2016


2016-07-22 17:01, Sergio Gonzalez Monroy:
> Removing/freeing elements elements within a STAILQ_FOREACH loop
> is not safe. FreeBSD defines STAILQ_FOREACH_SAFE macro, which permits
> these operations safely.
> 
> This patch defines this macro for Linux systems, where it is not defined.
[...]
> +#ifndef SLIST_FOREACH_SAFE
> +#define SLIST_FOREACH_SAFE(var, head, field, tvar)                      \
> +	for ((var) = SLIST_FIRST((head));                               \
> +	    (var) && ((tvar) = SLIST_NEXT((var), field), 1);            \
> +	    (var) = (tvar))
> +#endif

The patch 2 requires STAILQ_FOREACH_SAFE, not SLIST_FOREACH_SAFE.




More information about the dev mailing list