]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add fr_tlist_parent()
authorAlan T. DeKok <aland@freeradius.org>
Fri, 25 Mar 2022 19:43:43 +0000 (15:43 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 26 Mar 2022 01:52:05 +0000 (21:52 -0400)
src/lib/util/tlist.h

index 6164a3448c5746561f80a5b42ebe4abb67d432b7..d7e4856d825caa1cfb12e0c67c50a863defe8147 100644 (file)
@@ -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
  *