SLISTPlatform Common

Data Structures

struct sl_slist_node

Macros

#define container_of (ptr, type, member)   (type *)((uintptr_t)(ptr) - ((uintptr_t)(&((type *)0)->member)))
#define SL_SLIST_ENTRY container_of
#define SL_SLIST_FOR_EACH (list_head, iterator)    for ((iterator) = (list_head); (iterator) != NULL; (iterator) = (iterator)->node)
#define SL_SLIST_FOR_EACH_ENTRY (list_head, entry, type, member)

Typedefs

typedef struct sl_slist_node sl_slist_node_t

Functions

void sl_slist_init ( sl_slist_node_t **head)
void sl_slist_insert ( sl_slist_node_t *item, sl_slist_node_t *pos)
sl_slist_node_t * sl_slist_pop ( sl_slist_node_t **head)
void sl_slist_push ( sl_slist_node_t **head, sl_slist_node_t *item)
void sl_slist_push_back ( sl_slist_node_t **head, sl_slist_node_t *item)
void sl_slist_remove ( sl_slist_node_t **head, sl_slist_node_t *item)
void sl_slist_sort ( sl_slist_node_t **head, bool(*cmp_fnct)( sl_slist_node_t *item_l, sl_slist_node_t *item_r))

Macro Definition Documentation

#define SL_SLIST_FOR_EACH_ENTRY ( list_head,
entry,
type,
member
)
Value:
for ( (entry) = SL_SLIST_ENTRY(list_head, type, member); \
&((entry)->member) != NULL; \
(entry) = SL_SLIST_ENTRY((entry)->member.node, type, member))

Definition at line 54 of file sl_slist.h .

Function Documentation

void sl_slist_init ( sl_slist_node_t ** head )

Initializes a singly-linked list.

Parameters
head Pointer to pointer of head element of list.

Initializes a singly-linked list.

Definition at line 32 of file sl_slist.c .

void sl_slist_insert ( sl_slist_node_t * item,
sl_slist_node_t * pos
)

Insert item after given item.

Parameters
item Pointer to item to add.
pos Pointer to item after which the item to add will be inserted.

Insert item after given item.

Definition at line 85 of file sl_slist.c .

sl_slist_node_t * sl_slist_pop ( sl_slist_node_t ** head )

Removes and returns first element of list.

Parameters
head Pointer to pointer of head element of list.
Returns
Pointer to item that was at top of the list.

Removes and returns first element of list.

Definition at line 66 of file sl_slist.c .

void sl_slist_push ( sl_slist_node_t ** head,
sl_slist_node_t * item
)

Add given item at beginning of list.

Parameters
head Pointer to pointer of head element of list.
item Pointer to item to add.

Add given item at beginning of list.

Definition at line 40 of file sl_slist.c .

void sl_slist_push_back ( sl_slist_node_t ** head,
sl_slist_node_t * item
)

Add item at end of list.

Parameters
head Pointer to pointer of head element of list.
item Pointer to item to add.

Add item at end of list.

Definition at line 50 of file sl_slist.c .

void sl_slist_remove ( sl_slist_node_t ** head,
sl_slist_node_t * item
)

Remove item from list.

Parameters
head Pointer to pointer of head element of list.
item Pointer to item to remove.
Note
(1) An EFM_ASSERT is thrown if the item is not found within the list.

Remove item from list.

Definition at line 95 of file sl_slist.c .

void sl_slist_sort ( sl_slist_node_t ** head,
bool(*)( sl_slist_node_t *item_l, sl_slist_node_t *item_r) cmp_fnct
)

Sorts list items.

Parameters
head Pointer to pointer of head element of list.
cmp_fnct Pointer to function to use for sorting the list. item_l Pointer to left item. item_r Pointer to right item. Returns whether the two items are ordered (true) or not (false).

Sorts list items.

Definition at line 113 of file sl_slist.c .