]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add function to get tlist from dlist head
authorAlan T. DeKok <aland@freeradius.org>
Tue, 5 Apr 2022 22:25:32 +0000 (18:25 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 7 Apr 2022 15:23:36 +0000 (11:23 -0400)
because a lot of dlist callbacks give the dlist head, and we
sometimes wish to convert that back to a tlist

src/lib/util/tlist.h

index baa45c0d3f78dbd34e7636a6c0016675f3d85155..d22ec9dbdbc70885f00e675446544ccf3d22f463 100644 (file)
@@ -65,6 +65,14 @@ static inline void *fr_tlist_entry_to_item(size_t offset, fr_tlist_t const *entr
        return (void *)(((uintptr_t) entry) - offset);
 }
 
+/** Get a fr_tlist_head_t from a fr_dlist_head_t
+ *
+ */
+static inline fr_tlist_head_t *fr_tlist_head_from_dlist(fr_dlist_head_t *dlist_head)
+{
+       return (fr_tlist_head_t *)(((uintptr_t) dlist_head) - offsetof(fr_tlist_head_t, dlist_head));
+}
+
 /** Initialise a linked list without metadata
  *
  */