From: Alan T. DeKok Date: Fri, 25 Mar 2022 19:43:43 +0000 (-0400) Subject: add fr_tlist_parent() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=17c6c86072946177ed88233d2d0bdad1afb42ada;p=thirdparty%2Ffreeradius-server.git add fr_tlist_parent() --- diff --git a/src/lib/util/tlist.h b/src/lib/util/tlist.h index 6164a3448c..d7e4856d82 100644 --- a/src/lib/util/tlist.h +++ b/src/lib/util/tlist.h @@ -1035,11 +1035,19 @@ DIAG_OFF(unused-function) \ { return FR_TLIST_HEAD(_name) *fr_tlist_remove_children(&ptr->_element_entry) } DIAG_ON(unused-function) +static inline void *fr_tlist_parent(fr_tlist_head_t *list_head, void const *ptr) +{ + fr_tlist_t *entry; -/* - * Functions which are specific to tlists - */ + if (!ptr || !list_head) return NULL; + entry = fr_tlist_item_to_entry(list_head->offset, ptr); + if (!entry->list_head) return NULL; + + if (!entry->list_head->parent) return NULL; + + return fr_tlist_entry_to_item(entry->list_head->offset, entry->list_head->parent); +} /** Initialize a child tlist based on a parent entry *