fr_tlist_t *parent; //!< the parent entry which holds this list. May be NULL.
size_t offset; //!< Positive offset from start of structure to #fr_tlist_t.
- char const *type; //!< of items contained within the list. Used for talloc
- ///< validation.
fr_dlist_head_t dlist_head;
};
+#define tlist_type(_list) ((_list)->dlist_head.type)
+
struct fr_tlist_s {
fr_tlist_head_t *list_head; //!< the list which holds this entry
fr_tlist_head_t *children; //!< any child list
static inline void _fr_tlist_init(fr_tlist_head_t *list_head, size_t offset, char const *type)
{
list_head->offset = offset;
- list_head->type = type;
list_head->parent = NULL;
/*
{
void *item;
- if (!list_head->type) return;
+ if (!tlist_type(list_head)) return;
fr_assert_msg(fr_tlist_initialised(list_head), "CONSISTENCY CHECK FAILED %s[%i]: tlist not initialised",
file, line);
fr_assert_msg(entry->list_head == list_head, "CONSISTENCY CHECK FAILED %s[%i]: tlist entry %p has wrong parent",
file, line, entry);
- item = _talloc_get_type_abort(item, list_head->type, __location__);
+ item = _talloc_get_type_abort(item, tlist_type(list_head), __location__);
if (entry->children) {
- fr_assert_msg(entry->children->type != NULL, "CONSISTENCY CHECK FAILED %s[%i]: tlist entry %p has non-talloc'd child list",
+ fr_assert_msg(tlist_type(entry->children) != NULL, "CONSISTENCY CHECK FAILED %s[%i]: tlist entry %p has non-talloc'd child list",
file, line, entry);
- fr_assert_msg(strcmp(entry->children->type, list_head->type) == 0,
+ fr_assert_msg(strcmp(tlist_type(entry->children), tlist_type(list_head)) == 0,
"CONSISTENCY CHECK FAILED %s[%i]: tlist entry %p has different child type from parent",
file, line, entry);
/*
* Must be both talloced or both not
*/
- if (!fr_cond_assert((list_dst->type && list_src->type) || (!list_dst->type && !list_src->type))) return -1;
+ if (!fr_cond_assert((tlist_type(list_dst) && tlist_type(list_src)) || (!tlist_type(list_dst) && !tlist_type(list_src)))) return -1;
/*
* Must be of the same type
*/
- if (!fr_cond_assert(!list_dst->type || (strcmp(list_dst->type, list_src->type) == 0))) return -1;
+ if (!fr_cond_assert(!tlist_type(list_dst) || (strcmp(tlist_type(list_dst), tlist_type(list_src)) == 0))) return -1;
#endif
item = fr_dlist_head(&list_src->dlist_head);
/*
* Must be both talloced or both not
*/
- if (!fr_cond_assert((list_dst->type && list_src->type) || (!list_dst->type && !list_src->type))) return -1;
+ if (!fr_cond_assert((tlist_type(list_dst) && tlist_type(list_src)) || (!tlist_type(list_dst) && !tlist_type(list_src)))) return -1;
/*
* Must be of the same type
*/
- if (!fr_cond_assert(!list_dst->type || (strcmp(list_dst->type, list_src->type) == 0))) return -1;
+ if (!fr_cond_assert(!tlist_type(list_dst) || (strcmp(tlist_type(list_dst), tlist_type(list_src)) == 0))) return -1;
#endif
middle = fr_dlist_head(&list_dst->dlist_head);
*/
fr_dlist_init(&children->dlist_head, fr_tlist_t, dlist_entry);
children->dlist_head.offset += list_head->offset;
- children->dlist_head.type = list_head->type;
+ children->dlist_head.type = list_head->dlist_head.type;
children->offset = list_head->offset;
- children->type = list_head->type;
children->parent = NULL;
entry->children = children;