/home/aaron/olsrd-current/olsrd/src/common/list.h File Reference

#include <stddef.h>
#include "common/container_of.h"
#include "common/common_types.h"
Include dependency graph for list.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  list_entity

Defines

#define list_first_element(head, element, list_member)   container_of((head)->next, typeof(*(element)), list_member)
#define list_last_element(head, element, list_member)   container_of((head)->prev, typeof(*(element)), list_member)
#define list_next_element(element, list_member)   container_of((&(element)->list_member)->next, typeof(*(element)), list_member)
#define list_prev_element(element, list_member)   container_of((&(element)->list_member)->prev, typeof(*(element)), list_member)
#define list_for_element_range(first_element, last_element, element, list_member)
#define list_for_element_range_reverse(first_element, last_element, element, list_member)
#define list_for_each_element(head, element, list_member)
#define list_for_each_element_reverse(head, element, list_member)
#define list_for_element_to_last(head, first, element, list_member)   list_for_element_range(first, list_last_element(head, element, list_member), element, list_member)
#define list_for_element_to_last_reverse(head, first, element, list_member)   list_for_element_range_reverse(first, list_last_element(head, element, list_member), element, list_member)
#define list_for_first_to_element(head, last, element, list_member)   list_for_element_range(list_first_element(head, element, list_member), last, element, list_member)
#define list_for_first_to_element_reverse(head, last, element, list_member)   list_for_element_range_reverse(list_first_element(head, element, list_member), last, element, list_member)
#define list_for_element_range_safe(first_element, last_element, element, list_member, ptr)
#define list_for_element_range_reverse_safe(first_element, last_element, element, list_member, ptr)
#define list_for_each_element_safe(head, element, list_member, ptr)
#define list_for_each_element_reverse_safe(head, element, list_member, ptr)

Functions

static INLINE void list_init_head (struct list_entity *head)
static INLINE void list_init_node (struct list_entity *entity)
static INLINE void __list_add (struct list_entity *prev, struct list_entity *next, struct list_entity *new)
static INLINE void list_add_head (struct list_entity *head, struct list_entity *new)
static INLINE void list_add_tail (struct list_entity *head, struct list_entity *new)
static INLINE void list_add_before (struct list_entity *before, struct list_entity *new)
static INLINE void list_add_after (struct list_entity *after, struct list_entity *new)
static INLINE void __list_remove (struct list_entity *prev, struct list_entity *next)
static INLINE void list_remove (struct list_entity *entity)
static INLINE bool list_is_empty (struct list_entity *head)
static INLINE bool list_node_added (struct list_entity *node)
static INLINE bool list_is_first (const struct list_entity *head, const struct list_entity *entity)
static INLINE bool list_is_last (const struct list_entity *head, const struct list_entity *entity)
static INLINE void list_merge (struct list_entity *add_to, struct list_entity *remove_from)

Define Documentation

#define list_first_element ( head,
element,
list_member   )     container_of((head)->next, typeof(*(element)), list_member)
Parameters:
head pointer to list-head
element pointer to a node element (don't need to be initialized)
list_member name of the list_entity element inside the larger struct
Returns:
pointer to the first element of the list (automatically converted to type 'element')

Definition at line 233 of file list.h.

Referenced by olsr_calculate_routing_table(), olsr_memcookie_malloc(), olsr_timer_cleanup(), and olsr_timer_walk().

#define list_for_each_element ( head,
element,
list_member   ) 
Value:
list_for_element_range(list_first_element(head, element, list_member), \
                         list_last_element(head, element, list_member), \
                         element, list_member)

Loop over all elements of a list, used similar to a for() command. This loop should not be used if elements are removed from the list during the loop.

Parameters:
head pointer to list-head
element pointer to a node of the list, this element will contain the current node of the list during the loop
list_member name of the list_entity element inside the larger struct

Definition at line 315 of file list.h.

Referenced by insert_new_name_in_list(), lookup_name_latlon(), lookup_position_latlon(), mapwrite_work(), write_hosts_file(), write_resolv_file(), and write_services_file().

#define list_for_each_element_reverse ( head,
element,
list_member   ) 
Value:
list_for_element_range_reverse(list_first_element(head, element, list_member), \
                                 list_last_element(head, element, list_member), \
                                 element, list_member)

Loop over all elements of a list backwards, used similar to a for() command. This loop should not be used if elements are removed from the list during the loop.

Parameters:
head pointer to list-head
element pointer to a node of the list, this element will contain the current node of the list during the loop
list_member name of the list_entity element inside the larger struct

Definition at line 331 of file list.h.

#define list_for_each_element_reverse_safe ( head,
element,
list_member,
ptr   ) 
Value:
list_for_element_range_reverse_safe(list_first_element(head, element, list_member), \
                                      list_last_element(head, element, list_member), \
                                      element, list_member, ptr)

Loop over all elements of a list backwards, used similar to a for() command. This loop can be used if the current element might be removed from the list during the loop. Other elements should not be removed during the loop.

Parameters:
head pointer to list-head
element pointer to a node of the list, this element will contain the current node of the list during the loop
list_member name of the list_entity element inside the larger struct
ptr pointer to an list element struct which is used to store the next node during the loop

Definition at line 471 of file list.h.

#define list_for_each_element_safe ( head,
element,
list_member,
ptr   ) 
Value:
list_for_element_range_safe(list_first_element(head, element, list_member), \
                              list_last_element(head, element, list_member), \
                              element, list_member, ptr)

Loop over all elements of a list, used similar to a for() command. This loop can be used if the current element might be removed from the list during the loop. Other elements should not be removed during the loop.

Parameters:
head pointer to list-head
element pointer to a node of the list, this element will contain the current node of the list during the loop
list_member name of the list_entity element inside the larger struct
ptr pointer to an list element struct which is used to store the next node during the loop

Definition at line 452 of file list.h.

Referenced by arproaming_client_update(), arproaming_list_remove(), free_all_listold_entries(), and olsr_timer_remove().

#define list_for_element_range ( first_element,
last_element,
element,
list_member   ) 
Value:
for (element = (first_element); \
       element->list_member.prev != &(last_element)->list_member; \
       element = list_next_element(element, list_member))

Loop over a block of elements of a list, used similar to a for() command. This loop should not be used if elements are removed from the list during the loop.

Parameters:
first_element first element of loop
last_element last element of loop
element iterator pointer to list element struct
list_member name of list_entity within list element struct

Definition at line 284 of file list.h.

#define list_for_element_range_reverse ( first_element,
last_element,
element,
list_member   ) 
Value:
for (element = (last_element); \
       element->list_member.next != &(first_element)->list_member; \
       element = list_prev_element(element, list_member))

Loop over a block of elements of a list backwards, used similar to a for() command. This loop should not be used if elements are removed from the list during the loop.

Parameters:
first_element first element of range (will be last returned by the loop)
last_element last element of range (will be first returned by the loop)
element iterator pointer to list element struct
list_member name of list_entity within list element struct

Definition at line 299 of file list.h.

#define list_for_element_range_reverse_safe ( first_element,
last_element,
element,
list_member,
ptr   ) 
Value:
for (element = (last_element), ptr = list_prev_element(last_element, list_member); \
       element->list_member.next != &(first_element)->list_member; \
       element = ptr, ptr = list_prev_element(ptr, list_member))

Loop over a block of elements of a list backwards, used similar to a for() command. This loop can be used if the current element might be removed from the list during the loop. Other elements should not be removed during the loop.

Parameters:
first_element first element of range (will be last returned by the loop)
last_element last element of range (will be first returned by the loop)
element iterator pointer to list element struct
list_member name of list_entity within list element struct
ptr pointer to list element struct which is used to store the previous node during the loop

Definition at line 433 of file list.h.

#define list_for_element_range_safe ( first_element,
last_element,
element,
list_member,
ptr   ) 
Value:
for (element = (first_element), ptr = list_next_element(first_element, list_member); \
       element->list_member.prev != &(last_element)->list_member; \
       element = ptr, ptr = list_next_element(ptr, list_member))

Loop over a block of elements of a list, used similar to a for() command. This loop can be used if the current element might be removed from the list during the loop. Other elements should not be removed during the loop.

Parameters:
first_element first element of loop
last_element last element of loop
element iterator pointer to list element struct
list_member name of list_entity within list element struct
ptr pointer to list element struct which is used to store the next node during the loop

Definition at line 415 of file list.h.

#define list_for_element_to_last ( head,
first,
element,
list_member   )     list_for_element_range(first, list_last_element(head, element, list_member), element, list_member)

Loop over a block of elements of a list, used similar to a for() command. This loop should not be used if elements are removed from the list during the loop. The loop runs from the element 'first' to the end of the list.

Parameters:
head pointer to head of list
first pointer to first element of loop
element pointer to a node of the list, this element will contain the current node of the list during the loop
list_member name of the list_entity element inside the larger struct

Definition at line 349 of file list.h.

#define list_for_element_to_last_reverse ( head,
first,
element,
list_member   )     list_for_element_range_reverse(first, list_last_element(head, element, list_member), element, list_member)

Loop over a block of elements of a list backwards, used similar to a for() command. This loop should not be used if elements are removed from the list during the loop. The loop runs from the end of the list to the element 'first'.

Parameters:
head pointer to head of list
first pointer to first element of loop
element pointer to a node of the list, this element will contain the current node of the list during the loop
list_member name of the list_entity element inside the larger struct

Definition at line 365 of file list.h.

#define list_for_first_to_element ( head,
last,
element,
list_member   )     list_for_element_range(list_first_element(head, element, list_member), last, element, list_member)

Loop over a block of elements of a list, used similar to a for() command. This loop should not be used if elements are removed from the list during the loop. The loop runs from the start of the list to the element 'last'.

Parameters:
head pointer to head of list
last pointer to last element of loop
element pointer to a node of the list, this element will contain the current node of the list during the loop
list_member name of the list_entity element inside the larger struct

Definition at line 381 of file list.h.

#define list_for_first_to_element_reverse ( head,
last,
element,
list_member   )     list_for_element_range_reverse(list_first_element(head, element, list_member), last, element, list_member)

Loop over a block of elements of a list backwards, used similar to a for() command. This loop should not be used if elements are removed from the list during the loop. The loop runs from the element 'last' to the start of the list.

Parameters:
head pointer to head of list
last pointer to last element of loop
element pointer to a node of the list, this element will contain the current node of the list during the loop
list_member name of the list_entity element inside the larger struct
loop_ptr pointer to an list_entity which is used as the internal iterator

Definition at line 399 of file list.h.

#define list_last_element ( head,
element,
list_member   )     container_of((head)->prev, typeof(*(element)), list_member)
Parameters:
head pointer to list-head
element pointer to a node element (don't need to be initialized)
list_member name of the list_entity element inside the larger struct
Returns:
pointer to the last element of the list (automatically converted to type 'element')

Definition at line 245 of file list.h.

#define list_next_element ( element,
list_member   )     container_of((&(element)->list_member)->next, typeof(*(element)), list_member)

This function must not be called for the last element of a list

Parameters:
element pointer to a node of the list
list_member name of the list_entity element inside the larger struct
Returns:
pointer to the node after 'element' (automatically converted to type 'element')

Definition at line 258 of file list.h.

Referenced by avl_insert(), and avl_remove().

#define list_prev_element ( element,
list_member   )     container_of((&(element)->list_member)->prev, typeof(*(element)), list_member)

This function must not be called for the first element of a list

Parameters:
element pointer to a node of the list
list_member name of the list_entity element inside the larger struct
Returns:
pointer to the node before 'element' (automatically converted to type 'element')

Definition at line 271 of file list.h.


Function Documentation

static INLINE void __list_add ( struct list_entity prev,
struct list_entity next,
struct list_entity new 
) [static]

internal function to add a new node between two other nodes.

Parameters:
prev node before the insertion point
next node after the insertion point
new node which will be added to the list between 'prev' and 'next'

Definition at line 93 of file list.h.

References list_entity::next, and list_entity::prev.

Referenced by list_add_after(), list_add_before(), list_add_head(), and list_add_tail().

static INLINE void __list_remove ( struct list_entity prev,
struct list_entity next 
) [static]

internal function that removes the nodes between two other nodes.

Parameters:
prev node before the removed part of the list
next node after the removed part of the list

Definition at line 146 of file list.h.

References list_entity::next, and list_entity::prev.

Referenced by list_remove().

static INLINE void list_add_after ( struct list_entity after,
struct list_entity new 
) [static]

adds a node after another node

Parameters:
before reference node in the list
new node which will be added to the list

Definition at line 136 of file list.h.

References __list_add(), and list_entity::next.

Referenced by _avl_insert_after(), olsr_com_parse_request(), olsr_enqueue_rt(), and olsr_timer_walk().

Here is the call graph for this function:

static INLINE void list_add_before ( struct list_entity before,
struct list_entity new 
) [static]

adds a node before another node

Parameters:
before reference node in the list
new node which will be added to the list

Definition at line 126 of file list.h.

References __list_add(), and list_entity::prev.

Referenced by _avl_insert_before(), add_interface(), add_link_entry(), ip_prefix_list_add(), olsr_enqueue_rt(), olsr_socket_add(), olsr_spf_add_path_list(), olsr_timer_change(), and olsr_timer_start().

Here is the call graph for this function:

static INLINE void list_add_head ( struct list_entity head,
struct list_entity new 
) [static]

adds a node at the beginning of a list

Parameters:
head pointer to list head
new node which will be added to the list

Definition at line 106 of file list.h.

References __list_add(), and list_entity::next.

Referenced by addObampNode4(), and avl_insert().

Here is the call graph for this function:

static INLINE void list_add_tail ( struct list_entity head,
struct list_entity new 
) [static]

adds a node at the end of a list

Parameters:
head pointer to list head
new node which will be added to the list

Definition at line 116 of file list.h.

References __list_add(), and list_entity::prev.

Referenced by addObampNode4(), AddObampSniffingIf(), arproaming_list_add(), insert_new_name_in_list(), olsr_callback_cons_register(), olsr_log_addhandler(), olsr_memcookie_add_custom(), olsr_memcookie_free(), olsr_memcookie_malloc(), and olsr_timer_add().

Here is the call graph for this function:

static INLINE void list_init_head ( struct list_entity head  )  [static]
static INLINE void list_init_node ( struct list_entity entity  )  [static]

initialize a list-node

Parameters:
pointer to list-node

Definition at line 82 of file list.h.

References list_entity::next, and list_entity::prev.

static INLINE bool list_is_empty ( struct list_entity head  )  [static]
static INLINE bool list_is_first ( const struct list_entity head,
const struct list_entity entity 
) [static]

checks if a node is the first element of a list

Parameters:
head pointer to list head
entity pointer to node
Returns:
true if node is first element of list, false otherwise

Definition at line 189 of file list.h.

References list_entity::next.

Referenced by avl_find_greaterequal(), and avl_find_lessequal().

static INLINE bool list_is_last ( const struct list_entity head,
const struct list_entity entity 
) [static]

checks if node is the last element of a list

Parameters:
head pointer to list head
entity pointer to node
Returns:
true if node is last element of list, false otherwise

Definition at line 200 of file list.h.

References list_entity::prev.

Referenced by avl_find_greaterequal(), avl_find_lessequal(), avl_insert(), and avl_remove().

static INLINE void list_merge ( struct list_entity add_to,
struct list_entity remove_from 
) [static]

Merge two lists and clear the second head

Parameters:
add_to head of the list which will contain all elements
remove_from head of the list which elements will be added after the elements of the first one

Definition at line 211 of file list.h.

References list_init_head(), list_is_empty(), list_entity::next, and list_entity::prev.

Referenced by olsr_timer_walk().

Here is the call graph for this function:

static INLINE bool list_node_added ( struct list_entity node  )  [static]

checks if node has been added to a list

Parameters:
node pointer to node
Returns:
true if both pointers of the node are initialized, false otherwise

Definition at line 178 of file list.h.

References list_entity::next, and list_entity::prev.

Referenced by olsr_enqueue_rt(), olsr_spf_relax(), and unlock_interface().

static INLINE void list_remove ( struct list_entity entity  )  [static]
Generated on Wed Jun 19 06:00:05 2013 for olsrd by  doxygen 1.6.3