The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Functions
tlist.h File Reference

Tree list implementation. More...

#include <freeradius-devel/util/dlist.h>
+ Include dependency graph for tlist.h:

Go to the source code of this file.

Data Structures

struct  fr_tlist_head_s
 
struct  fr_tlist_s
 

Macros

#define FR_TLIST_ENTRY(_name)   _name ## _entry_t
 Expands to the type name used for the entry wrapper structure. More...
 
#define fr_tlist_foreach_entry(_list_head, _iter)    for (void *_iter = fr_dlist_head(&_list_head->dlist_head); _iter; _iter = fr_dlist_next(&_list_head->dlist_head, _iter))
 Iterate over the contents of a list, only one level. More...
 
#define FR_TLIST_FUNCS(_name, _element_type, _element_entry)
 Define type specific wrapper functions for tlists. More...
 
#define FR_TLIST_HEAD(_name)   _name ## _head_t
 Expands to the type name used for the head wrapper structure. More...
 
#define fr_tlist_init(_head, _type, _field)    _Generic((((_type *)0)->_field), fr_tlist_t: _fr_tlist_init(_head, offsetof(_type, _field), NULL))
 Initialise the head structure of a tlist. More...
 
#define fr_tlist_talloc_init(_head, _type, _field)    _Generic((((_type *)0)->_field), fr_tlist_t: _fr_tlist_init(_head, offsetof(_type, _field), #_type))
 Initialise the head structure of a tlist. More...
 
#define FR_TLIST_TYPES(_name)
 Define type specific wrapper structs for tlists. More...
 
#define FR_TLIST_VERIFY(_head)   fr_tlist_verify(__FILE__, __LINE__, _head)
 
#define tlist_type(_list)   ((_list)->dlist_head.type)
 

Typedefs

typedef struct fr_tlist_head_s fr_tlist_head_t
 
typedef struct fr_tlist_s fr_tlist_t
 

Functions

static void _fr_tlist_init (fr_tlist_head_t *list_head, size_t offset, char const *type)
 Initialise common fields in a tlist. More...
 
static int fr_tlist_add_children (fr_tlist_t *entry, fr_tlist_head_t *children)
 Add a pre-initialized child tlist to a parent entry. More...
 
static void fr_tlist_clear (fr_tlist_head_t *list_head)
 Remove all elements in a tlist. More...
 
static bool fr_tlist_empty (fr_tlist_head_t const *list_head)
 Check whether a list has any items. More...
 
static bool fr_tlist_entry_in_a_list (fr_tlist_t const *entry)
 Check if a list entry is part of a list. More...
 
static void fr_tlist_entry_init (fr_tlist_t *entry)
 Initialise a linked list without metadata. More...
 
static void * fr_tlist_entry_to_item (fr_tlist_head_t const *list_head, fr_tlist_t const *entry)
 Get the item from a fr_tlist_t. More...
 
static void fr_tlist_entry_unlink (fr_tlist_t *entry)
 
static void * fr_tlist_head (fr_tlist_head_t const *list_head)
 Return the HEAD item of a list or NULL if the list is empty. More...
 
static fr_tlist_head_tfr_tlist_head_from_dlist (fr_dlist_head_t *dlist_head)
 Get a fr_tlist_head_t from a fr_dlist_head_t. More...
 
static bool fr_tlist_in_list (fr_tlist_head_t *list_head, void *ptr)
 Check if a list entry is part of a tlist. More...
 
static void fr_tlist_init_children (fr_tlist_t *entry, fr_tlist_head_t *children)
 Initialize a child tlist based on a parent entry. More...
 
static bool fr_tlist_initialised (fr_tlist_head_t const *list_head)
 Check if the list head is initialised. More...
 
static int fr_tlist_insert_after (fr_tlist_head_t *list_head, void *pos, void *ptr)
 Insert an item after an item already in the list. More...
 
static int fr_tlist_insert_before (fr_tlist_head_t *list_head, void *pos, void *ptr)
 Insert an item after an item already in the list. More...
 
static int fr_tlist_insert_head (fr_tlist_head_t *list_head, void *ptr)
 Insert an item into the head of a list. More...
 
static int fr_tlist_insert_tail (fr_tlist_head_t *list_head, void *ptr)
 Insert an item into the tail of a list. More...
 
static fr_tlist_tfr_tlist_item_to_entry (fr_tlist_head_t const *list_head, void const *item)
 Find the tlist pointers within a list item. More...
 
static int fr_tlist_move (fr_tlist_head_t *list_dst, fr_tlist_head_t *list_src)
 Merge two lists, inserting the source at the tail of the destination. More...
 
static int fr_tlist_move_head (fr_tlist_head_t *list_dst, fr_tlist_head_t *list_src)
 Merge two lists, inserting the source at the head of the destination. More...
 
static void * fr_tlist_next (fr_tlist_head_t const *list_head, void const *ptr)
 Get the next item in a list. More...
 
static void fr_tlist_noop (void)
 
static unsigned int fr_tlist_num_elements (fr_tlist_head_t const *list_head)
 Return the number of elements in the tlist. More...
 
static void * fr_tlist_parent (fr_tlist_head_t *list_head, void const *ptr)
 
static void * fr_tlist_pop_head (fr_tlist_head_t *list_head)
 Remove the head item in a list. More...
 
static void * fr_tlist_pop_tail (fr_tlist_head_t *list_head)
 Remove the tail item in a list. More...
 
static void * fr_tlist_prev (fr_tlist_head_t const *list_head, void const *ptr)
 Get the previous item in a list. More...
 
static void fr_tlist_recursive_sort (fr_tlist_head_t *head, void **ptr, fr_cmp_t cmp)
 Recursive sort routine for tlist. More...
 
static void * fr_tlist_remove (fr_tlist_head_t *list_head, void *ptr)
 Remove an item from the list. More...
 
static fr_tlist_head_tfr_tlist_remove_children (fr_tlist_t *entry)
 Remove a child tlist from a parent entry. More...
 
static void * fr_tlist_replace (fr_tlist_head_t *list_head, void *item, void *ptr)
 Replace an item in a dlist. More...
 
static void fr_tlist_sort (fr_tlist_head_t *list, fr_cmp_t cmp)
 Sort a tlist using merge sort. More...
 
static void * fr_tlist_sort_merge (fr_tlist_head_t *head, void **a, void **b, fr_cmp_t cmp)
 Merge phase of a merge sort of a dlist. More...
 
static void fr_tlist_sort_split (fr_tlist_head_t *head, void **source, void **front, void **back)
 Split phase of a merge sort of a dlist. More...
 
static void * fr_tlist_tail (fr_tlist_head_t const *list_head)
 Return the TAIL item of a list or NULL if the list is empty. More...
 
static void fr_tlist_talloc_free (fr_tlist_head_t *head)
 Free all items in a doubly linked list (with talloc) More...
 
static void fr_tlist_talloc_free_head (fr_tlist_head_t *list_head)
 Free the first item in the list. More...
 
static void * fr_tlist_talloc_free_item (fr_tlist_head_t *list_head, void *ptr)
 Free the item specified. More...
 
static void fr_tlist_talloc_free_tail (fr_tlist_head_t *list_head)
 Free the last item in the list. More...
 
static void fr_tlist_talloc_free_to_tail (fr_tlist_head_t *head, void *ptr)
 Free items in a doubly linked list (with talloc) More...
 
static void fr_tlist_talloc_reverse_free (fr_tlist_head_t *head)
 Free all items in a doubly linked list from the tail backwards. More...
 
static void fr_tlist_verify (char const *file, int line, fr_tlist_head_t const *list_head)
 Check all items in the list are valid. More...
 

Detailed Description

Tree list implementation.

Definition in file tlist.h.


Data Structure Documentation

◆ fr_tlist_head_s

struct fr_tlist_head_s

Definition at line 35 of file tlist.h.

+ Collaboration diagram for fr_tlist_head_s:
Data Fields
fr_dlist_head_t dlist_head
fr_tlist_t * parent the parent entry which holds this list. May be NULL.

◆ fr_tlist_s

struct fr_tlist_s

Definition at line 43 of file tlist.h.

+ Collaboration diagram for fr_tlist_s:
Data Fields
fr_tlist_head_t * children any child list
fr_dlist_t dlist_entry the doubly linked list of entries.
fr_tlist_head_t * list_head the list which holds this entry

Macro Definition Documentation

◆ FR_TLIST_ENTRY

#define FR_TLIST_ENTRY (   _name)    _name ## _entry_t

Expands to the type name used for the entry wrapper structure.

Parameters
[in]_namePrefix we add to type-specific structures.
Returns
fr_tlist_<name>_entry_t

Definition at line 762 of file tlist.h.

◆ fr_tlist_foreach_entry

#define fr_tlist_foreach_entry (   _list_head,
  _iter 
)     for (void *_iter = fr_dlist_head(&_list_head->dlist_head); _iter; _iter = fr_dlist_next(&_list_head->dlist_head, _iter))

Iterate over the contents of a list, only one level.

Parameters
[in]_list_headto iterate over.
[in]_iterName of iteration variable. Will be declared in the scope of the loop.

Definition at line 179 of file tlist.h.

◆ FR_TLIST_FUNCS

#define FR_TLIST_FUNCS (   _name,
  _element_type,
  _element_entry 
)

Define type specific wrapper functions for tlists.

Note
This macro should be used inside the source file that will use the type specific functions.
Parameters
[in]_namePrefix we add to type-specific tlist functions.
[in]_element_typeType of structure that'll be inserted into the tlist.
[in]_element_entryField in the _element_type that holds the tlist entry information.

Definition at line 790 of file tlist.h.

◆ FR_TLIST_HEAD

#define FR_TLIST_HEAD (   _name)    _name ## _head_t

Expands to the type name used for the head wrapper structure.

Parameters
[in]_namePrefix we add to type-specific structures.
Returns
fr_tlist_<name>_head_t

Definition at line 769 of file tlist.h.

◆ fr_tlist_init

#define fr_tlist_init (   _head,
  _type,
  _field 
)     _Generic((((_type *)0)->_field), fr_tlist_t: _fr_tlist_init(_head, offsetof(_type, _field), NULL))

Initialise the head structure of a tlist.

Note
This variant does not perform talloc validation.

This function should only be called for the top level of the list. Please call fr_tlist_add_child() when adding a child list to an existing entry.

typedef struct {
fr_tlist_t tlist;
char const *field_a;
int *field_b;
...
} my_struct_t;
int my_func(my_struct_t *a, my_struct_t *b)
{
fr_tlist_init(&head, my_struct_t, tlist);
}
static int fr_tlist_insert_head(fr_tlist_head_t *list_head, void *ptr)
Insert an item into the head of a list.
Definition: tlist.h:224
#define fr_tlist_init(_head, _type, _field)
Initialise the head structure of a tlist.
Definition: tlist.h:138
static fr_slen_t head
Definition: xlat.h:406
Parameters
[in]_headstructure to initialise.
[in]_typeof item being stored in the list, e.g. fr_value_box_t, fr_dict_attr_t etc...
[in]_fieldContaining the fr_tlist_t within item being stored.

Definition at line 138 of file tlist.h.

◆ fr_tlist_talloc_init

#define fr_tlist_talloc_init (   _head,
  _type,
  _field 
)     _Generic((((_type *)0)->_field), fr_tlist_t: _fr_tlist_init(_head, offsetof(_type, _field), #_type))

Initialise the head structure of a tlist.

Note
This variant DOES perform talloc validation. All items inserted into the list must be allocated with talloc.

Initialise the head structure of a tlist.

Parameters
[in]_headstructure to initialise.
[in]_typeof item being stored in the list, e.g. fr_value_box_t, fr_dict_attr_t etc...
[in]_fieldContaining the fr_tlist_t within item being stored.

Definition at line 153 of file tlist.h.

◆ FR_TLIST_TYPES

#define FR_TLIST_TYPES (   _name)
Value:
typedef struct { fr_tlist_t entry; } FR_TLIST_ENTRY(_name); \
typedef struct { fr_tlist_head_t head; } FR_TLIST_HEAD(_name); \
#define FR_TLIST_ENTRY(_name)
Expands to the type name used for the entry wrapper structure.
Definition: tlist.h:762
#define FR_TLIST_HEAD(_name)
Expands to the type name used for the head wrapper structure.
Definition: tlist.h:769

Define type specific wrapper structs for tlists.

Note
This macro should be used inside the header for the area of code which will use type specific functions.

Definition at line 776 of file tlist.h.

◆ FR_TLIST_VERIFY

#define FR_TLIST_VERIFY (   _head)    fr_tlist_verify(__FILE__, __LINE__, _head)

Definition at line 520 of file tlist.h.

◆ tlist_type

#define tlist_type (   _list)    ((_list)->dlist_head.type)

Definition at line 41 of file tlist.h.

Typedef Documentation

◆ fr_tlist_head_t

Definition at line 1 of file tlist.h.

◆ fr_tlist_t

typedef struct fr_tlist_s fr_tlist_t

Definition at line 1 of file tlist.h.

Function Documentation

◆ _fr_tlist_init()

static void _fr_tlist_init ( fr_tlist_head_t list_head,
size_t  offset,
char const *  type 
)
inlinestatic

Initialise common fields in a tlist.

The dlist entries point to the tlist structure, which then points to the real structure.

Definition at line 160 of file tlist.h.

◆ fr_tlist_add_children()

static int fr_tlist_add_children ( fr_tlist_t entry,
fr_tlist_head_t children 
)
inlinestatic

Add a pre-initialized child tlist to a parent entry.

Parameters
[in]entrythe entry which will be the parent of the children
[in]childrenstructure to initialise. Usually in the same parent structure as "entry"

Definition at line 958 of file tlist.h.

◆ fr_tlist_clear()

static void fr_tlist_clear ( fr_tlist_head_t list_head)
inlinestatic

Remove all elements in a tlist.

Parameters
[in]list_headto clear.

Definition at line 186 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_empty()

static bool fr_tlist_empty ( fr_tlist_head_t const *  list_head)
inlinestatic

Check whether a list has any items.

Returns
  • True if it does not.
  • False if it does.

Definition at line 317 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_entry_in_a_list()

static bool fr_tlist_entry_in_a_list ( fr_tlist_t const *  entry)
inlinestatic

Check if a list entry is part of a list.

This works because the fr_tlist_head_t has an entry in the list. So if next and prev both point to the entry for the object being passed in, then it can't be part of a list with a fr_tlist_head_t.

Returns
  • True if in a list.
  • False otherwise.

Definition at line 99 of file tlist.h.

◆ fr_tlist_entry_init()

static void fr_tlist_entry_init ( fr_tlist_t entry)
inlinestatic

Initialise a linked list without metadata.

Definition at line 77 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_entry_to_item()

static void* fr_tlist_entry_to_item ( fr_tlist_head_t const *  list_head,
fr_tlist_t const *  entry 
)
inlinestatic

Get the item from a fr_tlist_t.

Definition at line 61 of file tlist.h.

+ Here is the caller graph for this function:

◆ fr_tlist_entry_unlink()

static void fr_tlist_entry_unlink ( fr_tlist_t entry)
inlinestatic

Definition at line 83 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_head()

static void* fr_tlist_head ( fr_tlist_head_t const *  list_head)
inlinestatic

Return the HEAD item of a list or NULL if the list is empty.

Parameters
[in]list_headto return the HEAD item from.
Returns
  • The HEAD item.
  • NULL if no items exist in the list.

Definition at line 306 of file tlist.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_tlist_head_from_dlist()

static fr_tlist_head_t* fr_tlist_head_from_dlist ( fr_dlist_head_t dlist_head)
inlinestatic

Get a fr_tlist_head_t from a fr_dlist_head_t.

Definition at line 69 of file tlist.h.

+ Here is the caller graph for this function:

◆ fr_tlist_in_list()

static bool fr_tlist_in_list ( fr_tlist_head_t list_head,
void *  ptr 
)
inlinestatic

Check if a list entry is part of a tlist.

This works because the fr_tlist_head_t has an entry in the list. So if next and prev both point to the entry for the object being passed in, then it can't be part of a list with a fr_tlist_head_t.

Returns
  • True if in a list.
  • False otherwise.

Definition at line 206 of file tlist.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_tlist_init_children()

static void fr_tlist_init_children ( fr_tlist_t entry,
fr_tlist_head_t children 
)
inlinestatic

Initialize a child tlist based on a parent entry.

Parameters
[in]entrythe entry which will be the parent of the children
[in]childrenstructure to initialise. Usually in the same parent structure as "entry"

Definition at line 932 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_initialised()

static bool fr_tlist_initialised ( fr_tlist_head_t const *  list_head)
inlinestatic

Check if the list head is initialised.

Memory must be zeroed out or initialised.

Returns
  • True if tlist initialised.
  • False if tlist not initialised

Definition at line 332 of file tlist.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_tlist_insert_after()

static int fr_tlist_insert_after ( fr_tlist_head_t list_head,
void *  pos,
void *  ptr 
)
inlinestatic

Insert an item after an item already in the list.

Note
If fr_tlist_talloc_init was used to initialise fr_tlist_head_t ptr must be a talloced chunk of the type passed to fr_tlist_talloc_init.
Parameters
[in]list_headto insert ptr into.
[in]posto insert ptr after.
[in]ptrto insert.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 267 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_insert_before()

static int fr_tlist_insert_before ( fr_tlist_head_t list_head,
void *  pos,
void *  ptr 
)
inlinestatic

Insert an item after an item already in the list.

Note
If fr_tlist_talloc_init was used to initialise fr_tlist_head_t ptr must be a talloced chunk of the type passed to fr_tlist_talloc_init.
Parameters
[in]list_headto insert ptr into.
[in]posto insert ptr before.
[in]ptrto insert.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 289 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_insert_head()

static int fr_tlist_insert_head ( fr_tlist_head_t list_head,
void *  ptr 
)
inlinestatic

Insert an item into the head of a list.

Note
If fr_tlist_talloc_init was used to initialise fr_tlist_head_t ptr must be a talloced chunk of the type passed to fr_tlist_talloc_init.
Parameters
[in]list_headto insert ptr into.
[in]ptrto insert.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 224 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_insert_tail()

static int fr_tlist_insert_tail ( fr_tlist_head_t list_head,
void *  ptr 
)
inlinestatic

Insert an item into the tail of a list.

Note
If fr_tlist_talloc_init was used to initialise fr_tlist_head_t ptr must be a talloced chunk of the type passed to fr_tlist_talloc_init.
Parameters
[in]list_headto insert ptr into.
[in]ptrto insert.
Returns
  • 0 on success.
  • -1 on failure.

Definition at line 245 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_item_to_entry()

static fr_tlist_t* fr_tlist_item_to_entry ( fr_tlist_head_t const *  list_head,
void const *  item 
)
inlinestatic

Find the tlist pointers within a list item.

Definition at line 53 of file tlist.h.

+ Here is the caller graph for this function:

◆ fr_tlist_move()

static int fr_tlist_move ( fr_tlist_head_t list_dst,
fr_tlist_head_t list_src 
)
inlinestatic

Merge two lists, inserting the source at the tail of the destination.

Returns
  • 0 on success.
  • -1 on failure.

Definition at line 534 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_move_head()

static int fr_tlist_move_head ( fr_tlist_head_t list_dst,
fr_tlist_head_t list_src 
)
inlinestatic

Merge two lists, inserting the source at the head of the destination.

Returns
  • 0 on success.
  • -1 on failure.

Definition at line 572 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_next()

static void* fr_tlist_next ( fr_tlist_head_t const *  list_head,
void const *  ptr 
)
inlinestatic

Get the next item in a list.

Note
If fr_dlist_talloc_init was used to initialise fr_dlist_head_t ptr must be a talloced chunk of the type passed to fr_tlist_talloc_init.
Parameters
[in]list_headcontaining ptr.
[in]ptrto retrieve the next item from. If ptr is NULL, the HEAD of the list will be returned.
Returns
  • The next item in the list if ptr is not NULL.
  • The head of the list if ptr is NULL.
  • NULL if ptr is the tail of the list (no more items).

Definition at line 362 of file tlist.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_tlist_noop()

static void fr_tlist_noop ( void  )
inlinestatic

Definition at line 751 of file tlist.h.

◆ fr_tlist_num_elements()

static unsigned int fr_tlist_num_elements ( fr_tlist_head_t const *  list_head)
inlinestatic

Return the number of elements in the tlist.

Parameters
[in]list_headof list to count elements for.

Definition at line 694 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_parent()

static void* fr_tlist_parent ( fr_tlist_head_t list_head,
void const *  ptr 
)
inlinestatic

Definition at line 913 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_pop_head()

static void* fr_tlist_pop_head ( fr_tlist_head_t list_head)
inlinestatic

Remove the head item in a list.

Parameters
[in]list_headto remove head item from.
Returns
  • The item removed.
  • NULL if not items in tlist.

Definition at line 429 of file tlist.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_tlist_pop_tail()

static void* fr_tlist_pop_tail ( fr_tlist_head_t list_head)
inlinestatic

Remove the tail item in a list.

Parameters
[in]list_headto remove tail item from.
Returns
  • The item removed.
  • NULL if not items in tlist.

Definition at line 445 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_prev()

static void* fr_tlist_prev ( fr_tlist_head_t const *  list_head,
void const *  ptr 
)
inlinestatic

Get the previous item in a list.

Note
If fr_dlist_talloc_init was used to initialise fr_dlist_head_t ptr must be a talloced chunk of the type passed to fr_tlist_talloc_init.
Parameters
[in]list_headcontaining ptr.
[in]ptrto retrieve the prev item from. If ptr is NULL, the HEAD of the list will be returned.
Returns
  • The prev item in the list if ptr is not NULL.
  • The head of the list if ptr is NULL.
  • NULL if ptr is the tail of the list (no more items).

Definition at line 380 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_recursive_sort()

static void fr_tlist_recursive_sort ( fr_tlist_head_t head,
void **  ptr,
fr_cmp_t  cmp 
)
inlinestatic

Recursive sort routine for tlist.

Parameters
[in]headof the list being sorted
[in,out]ptrto the first item in the current section of the list being sorted.
[in]cmpcomparison function to sort with

Definition at line 734 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_remove()

static void* fr_tlist_remove ( fr_tlist_head_t list_head,
void *  ptr 
)
inlinestatic

Remove an item from the list.

Note
If fr_tlist_talloc_init was used to initialise fr_tlist_head_t ptr must be a talloced chunk of the type passed to fr_tlist_talloc_init.

When removing items in an iteration loop, the iterator variable must be assigned the item returned by this function.

If the iterator variable is not updated, the item removed will be the last item iterated over, as its prev/prev pointers are set to point to itself.

my_item_t *item = NULL;
while ((item = fr_tlist_prev(&head, item))) {
if (item->should_be_removed) {
...do things with item
continue;
}
}
return item
Definition: dcursor.h:553
static void * fr_tlist_remove(fr_tlist_head_t *list_head, void *ptr)
Remove an item from the list.
Definition: tlist.h:413
static void * fr_tlist_prev(fr_tlist_head_t const *list_head, void const *ptr)
Get the previous item in a list.
Definition: tlist.h:380
Parameters
[in]list_headto remove ptr from.
[in]ptrto remove.
Returns
  • The previous item in the list (makes iteration easier).
  • NULL if we just removed the head of the list.

Definition at line 413 of file tlist.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_tlist_remove_children()

static fr_tlist_head_t* fr_tlist_remove_children ( fr_tlist_t entry)
inlinestatic

Remove a child tlist from a parent entry.

Parameters
[in]entrythe entry which will have the children removed

Definition at line 974 of file tlist.h.

◆ fr_tlist_replace()

static void* fr_tlist_replace ( fr_tlist_head_t list_head,
void *  item,
void *  ptr 
)
inlinestatic

Replace an item in a dlist.

Parameters
list_headin which the original item is.
itemto replace.
ptrreplacement item.
Returns
  • The item replaced
  • NULL if nothing replaced

Definition at line 463 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_sort()

static void fr_tlist_sort ( fr_tlist_head_t list,
fr_cmp_t  cmp 
)
inlinestatic

Sort a tlist using merge sort.

Note
This routine temporarily breaks the doubly linked nature of the list
Parameters
[in,out]listto sort
[in]cmpcomparison function to sort with

Definition at line 746 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_sort_merge()

static void* fr_tlist_sort_merge ( fr_tlist_head_t head,
void **  a,
void **  b,
fr_cmp_t  cmp 
)
inlinestatic

Merge phase of a merge sort of a dlist.

Note
Only to be used within a merge sort
Parameters
[in]headof the original list being sorted
[in]afirst element of first list being merged
[in]bfirst element of second list being merged
[in]cmpcomparison function for the sort
Returns
pointer to first item in merged list

Definition at line 723 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_sort_split()

static void fr_tlist_sort_split ( fr_tlist_head_t head,
void **  source,
void **  front,
void **  back 
)
inlinestatic

Split phase of a merge sort of a dlist.

Note
Only to be used within a merge sort
Parameters
[in]headof the original list being sorted
[in]sourcefirst item in the section of the list to split
[out]frontfirst item of the first half of the split list
[out]backfirst item of the second half of the split list

Definition at line 708 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_tail()

static void* fr_tlist_tail ( fr_tlist_head_t const *  list_head)
inlinestatic

Return the TAIL item of a list or NULL if the list is empty.

Parameters
[in]list_headto return the TAIL item from.
Returns
  • The TAIL item.
  • NULL if no items exist in the list.

Definition at line 344 of file tlist.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_tlist_talloc_free()

static void fr_tlist_talloc_free ( fr_tlist_head_t head)
inlinestatic

Free all items in a doubly linked list (with talloc)

Parameters
[in]headof list to free.

Definition at line 663 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_talloc_free_head()

static void fr_tlist_talloc_free_head ( fr_tlist_head_t list_head)
inlinestatic

Free the first item in the list.

Parameters
[in]list_headto free head item in.

Definition at line 609 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_talloc_free_item()

static void* fr_tlist_talloc_free_item ( fr_tlist_head_t list_head,
void *  ptr 
)
inlinestatic

Free the item specified.

Parameters
[in]list_headto free item in.
[in]ptrto remove and free.
Returns
  • NULL if no more items in the list.
  • Previous item in the list

Definition at line 631 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_talloc_free_tail()

static void fr_tlist_talloc_free_tail ( fr_tlist_head_t list_head)
inlinestatic

Free the last item in the list.

Parameters
[in]list_headto free tail item in.

Definition at line 618 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_talloc_free_to_tail()

static void fr_tlist_talloc_free_to_tail ( fr_tlist_head_t head,
void *  ptr 
)
inlinestatic

Free items in a doubly linked list (with talloc)

Parameters
[in]headof list to free.
[in]ptrremove and free from this to the tail.

Definition at line 645 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_talloc_reverse_free()

static void fr_tlist_talloc_reverse_free ( fr_tlist_head_t head)
inlinestatic

Free all items in a doubly linked list from the tail backwards.

Parameters
[in]headof list to free.

Definition at line 678 of file tlist.h.

+ Here is the call graph for this function:

◆ fr_tlist_verify()

static void fr_tlist_verify ( char const *  file,
int  line,
fr_tlist_head_t const *  list_head 
)
inlinestatic

Check all items in the list are valid.

Checks item talloc headers and types to ensure they're consistent with what we expect.

Does nothing if the list was not initialised with fr_tlist_talloc_init.

Definition at line 489 of file tlist.h.

+ Here is the call graph for this function: