Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions

Doubly linked list, linked lists that can be iterated over in both directions. More...

Data Structures

struct  sol_list
 Structure to add list support to a type. More...
 

Macros

#define SOL_LIST_FOREACH(list, itr)   for (itr = (list)->next; itr != (list); itr = itr->next)
 Macro to iterate over a list easily. More...
 
#define SOL_LIST_FOREACH_SAFE(list, itr, itr_next)   for (itr = (list)->next, itr_next = itr->next; itr != (list); itr = itr_next, itr_next = itr_next->next)
 Macro to iterate over a list with support for node deletion. More...
 
#define SOL_LIST_GET_CONTAINER(list, type, member)   (type *)((char *)(list) - offsetof(type, member))
 Helper macro to retrieve a pointer to the struct containing this list node. More...
 
#define SOL_LIST_INIT(name)   { &(name), &(name) }
 Helper macro to initialize a sol_list structure. More...
 

Typedefs

typedef struct sol_list sol_list
 Structure to add list support to a type. More...
 

Functions

static void sol_list_append (struct sol_list *list, struct sol_list *new_l)
 Append an new node to the end of the list. More...
 
static void sol_list_init (struct sol_list *list)
 Initializes a sol_list struct. More...
 
static bool sol_list_is_empty (struct sol_list *list)
 Convenience function to check if the list is empty. More...
 
static void sol_list_prepend (struct sol_list *list, struct sol_list *new_l)
 Attach an new node to the beginning of the list. More...
 
static void sol_list_remove (struct sol_list *list)
 Remove the node pointed by list from the list. More...
 
static void sol_list_steal (struct sol_list *list, struct sol_list *new_head)
 Steals the list nodes from a list. More...
 

Detailed Description

Doubly linked list, linked lists that can be iterated over in both directions.

This special data type is designed to store node information in the same memory as the data.

See sol_list for more info.

Macro Definition Documentation

#define SOL_LIST_FOREACH (   list,
  itr 
)    for (itr = (list)->next; itr != (list); itr = itr->next)

Macro to iterate over a list easily.

Parameters
listThe list to iterate over
itrVariable pointing to the current node on each iteration
See Also
SOL_LIST_FOREACH_SAFE
#define SOL_LIST_FOREACH_SAFE (   list,
  itr,
  itr_next 
)    for (itr = (list)->next, itr_next = itr->next; itr != (list); itr = itr_next, itr_next = itr_next->next)

Macro to iterate over a list with support for node deletion.

This version allows nodes to be removed without breaking the iteration.

Parameters
listThe list to iterate over
itrVariable pointing to the current node on each iteration
itr_nextVariable pointing to the next node on each iteration
See Also
SOL_LIST_FOREACH
#define SOL_LIST_GET_CONTAINER (   list,
  type,
  member 
)    (type *)((char *)(list) - offsetof(type, member))

Helper macro to retrieve a pointer to the struct containing this list node.

Parameters
listThe list node
typeContainer type
memberName of the sol_list member in the container struct
#define SOL_LIST_INIT (   name)    { &(name), &(name) }

Helper macro to initialize a sol_list structure.

Example:

struct sol_list mylist = SOL_LIST_INIT(mylist);
Parameters
nameList to be initialized

Typedef Documentation

typedef struct sol_list sol_list

Structure to add list support to a type.

To make possible for instances of a given type to be part of a sol_list, the type structure needs to begin with a sol_list field. Example:

struct example_s {
struct sol_list list;
int data;
}

Function Documentation

static void sol_list_append ( struct sol_list list,
struct sol_list new_l 
)
inlinestatic

Append an new node to the end of the list.

Parameters
listList pointer
new_lList node to be added

References sol_list::next, and sol_list::prev.

static void sol_list_init ( struct sol_list list)
inlinestatic

Initializes a sol_list struct.

Parameters
listList pointer

References sol_list::next, and sol_list::prev.

Referenced by sol_list_steal().

static bool sol_list_is_empty ( struct sol_list list)
inlinestatic

Convenience function to check if the list is empty.

Parameters
listList pointer
Returns
true if the list is empty, false otherwise.

References sol_list::next.

static void sol_list_prepend ( struct sol_list list,
struct sol_list new_l 
)
inlinestatic

Attach an new node to the beginning of the list.

Parameters
listList pointer
new_lList node to be added

References sol_list::next, and sol_list::prev.

static void sol_list_remove ( struct sol_list list)
inlinestatic

Remove the node pointed by list from the list.

Parameters
listPointer to the node that will be removed from the list

References sol_list::next, and sol_list::prev.

static void sol_list_steal ( struct sol_list list,
struct sol_list new_head 
)
inlinestatic

Steals the list nodes from a list.

Steals the list nodes from a list by moving them to a new head and reseting the original list to empty state.

Parameters
listOriginal list pointer
new_headPointer to the list that will hold the stolen nodes

References sol_list::next, sol_list::prev, and sol_list_init().