From: Alan T. DeKok Date: Tue, 5 Apr 2022 22:25:32 +0000 (-0400) Subject: add function to get tlist from dlist head X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=beb12e090503fe55839445509fa449ed299d803b;p=thirdparty%2Ffreeradius-server.git add function to get tlist from dlist head because a lot of dlist callbacks give the dlist head, and we sometimes wish to convert that back to a tlist --- diff --git a/src/lib/util/tlist.h b/src/lib/util/tlist.h index baa45c0d3f..d22ec9dbdb 100644 --- a/src/lib/util/tlist.h +++ b/src/lib/util/tlist.h @@ -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 * */