From: Arran Cudbard-Bell Date: Fri, 11 Dec 2020 17:32:01 +0000 (-0700) Subject: More efficient function for unlinking all items from a list X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=264147369ca4772b8499c60202f056022f785d7d;p=thirdparty%2Ffreeradius-server.git More efficient function for unlinking all items from a list --- diff --git a/src/lib/util/dlist.h b/src/lib/util/dlist.h index 8ae78d2c15c..36d66812432 100644 --- a/src/lib/util/dlist.h +++ b/src/lib/util/dlist.h @@ -145,6 +145,16 @@ static inline void _fr_dlist_init(fr_dlist_head_t *list_head, size_t offset, cha list_head->num_elements = 0; } +/** Efficiently remove all elements in a dlist + * + * @param[in] list_head to clear. + */ +static inline void fr_dlist_clear(fr_dlist_head_t *list_head) +{ + fr_dlist_entry_init(&list_head->entry); + list_head->num_elements = 0; +} + /** Insert an item into the head of a list * * @note If #fr_dlist_talloc_init was used to initialise #fr_dlist_head_t