On Wed, 28 Aug 2019 14:51:49 +0800
Bing Zhao <[email protected]> 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.