[dpdk-dev] [RFC] rte_hash: introduce hash list into hash lib

Stephen Hemminger stephen at networkplumber.org
Wed Aug 28 13:50:36 CEST 2019


On Wed, 28 Aug 2019 14:51:49 +0800
Bing Zhao <bingz at mellanox.com> wrote:

> +
> +/* To enable the deletion when iterating the list */
> +#ifndef LIST_FOREACH_SAFE
> +#define LIST_FOREACH_SAFE(var, head, field, tvar)			\
> +	for ((var) = ((head)->lh_first);				\
> +		(var) && ((tvar) = ((var)->field.le_next), 1);		\
> +		(var) = (tvar))
> +#endif
> +
> +/* To move the whole list from one head to another */
> +#define LIST_MOVE_TO_NEW_HEAD(new, old, field) do {			\
> +	(new)->lh_first = (old)->lh_first;				\
> +	if (((new)->lh_first) != NULL)					\
> +		(new)->lh_first->field.le_prev = &(new)->lh_first;	\
> +} while (/*CONSTCOND*/0)
> +

Why not use BSD style lists, rather than reinventing it here.


More information about the dev mailing list