]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
More efficient function for unlinking all items from a list
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 11 Dec 2020 17:32:01 +0000 (10:32 -0700)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 11 Dec 2020 17:32:01 +0000 (10:32 -0700)
src/lib/util/dlist.h

index 8ae78d2c15ca1a2cf2ecf59fadb33b23e3741c24..36d6681243250a3b2cf037444d1a9eec86f58054 100644 (file)
@@ -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