61#define link_node( __NODE_1 , __NODE_2 ) \
64 __NODE_2 -> prev = __NODE_1 ; \
65 __NODE_1 -> next = __NODE_2 ; \
70#define list_foreach( __ITEM_ , __LIST_ ) \
73 n_log( LOG_ERR , "Error in list_foreach, %s is NULL" , #__LIST_ ); \
76 for( LIST_NODE *__ITEM_ = __LIST_ -> start ; __ITEM_ ; __ITEM_ = __ITEM_ -> next )
79#define list_pop( __LIST_ , __TYPE_ ) ( __TYPE_ *)list_pop_f( __LIST_ )
81#define list_shift( __LIST_ , __TYPE_ ) (__TYPE_ *)list_shift_f( __LIST_ )
83#define remove_list_node( __LIST_ ,__NODE_ , __TYPE_ ) (__TYPE_ *)remove_list_node_f( __LIST_ , __NODE_ )
97int list_push(
LIST *list,
void *ptr,
void (*destructor)(
void *ptr ) ) ;
99int list_push_sorted(
LIST *list,
void *ptr,
int (*comparator)(
const void *a,
const void *b ),
void (*destructor)(
void *ptr ) );
103int list_unshift_sorted(
LIST *list,
void *ptr,
int (*comparator)(
const void *a,
const void *b ),
void (*destructor)(
void *ptr ) );
int nb_items
number of item currently in the list
LIST_NODE * end
pointer to the end of the list
void * ptr
void pointer to store
struct LIST_NODE * prev
pointer to the previous node
LIST_NODE * start
pointer to the start of the list
void(* destroy_func)(void *ptr)
pointer to destructor function if any, else NULL
struct LIST_NODE * next
pointer to the next node
int nb_max_items
maximum number of item in the list.
void * list_pop_f(LIST *list)
Get a pointer from the end of the list.
int list_empty(LIST *list)
Empty a LIST list of pointers.
int list_push(LIST *list, void *ptr, void(*destructor)(void *ptr))
Add a pointer to the end of the list.
int list_node_unshift(LIST *list, LIST_NODE *node)
Add a pointer at the start of the list.
int list_unshift(LIST *list, void *ptr, void(*destructor)(void *ptr))
Add a pointer at the start of the list.
LIST_NODE * list_node_shift(LIST *list)
Get a LIST_NODE pointer from the start of the list.
LIST_NODE * new_list_node(void *ptr, void(*destructor)(void *ptr))
Allocate a new node to link in a list.
int list_destroy(LIST **list)
Empty and Free a list container.
int list_unshift_sorted(LIST *list, void *ptr, int(*comparator)(const void *a, const void *b), void(*destructor)(void *ptr))
Add a pointer sorted in the list , starting by the start of the list.
LIST_NODE * list_node_pop(LIST *list)
Get a LIST_NODE pointer from the end of the list.
void * remove_list_node_f(LIST *list, LIST_NODE *node)
Internal function called each time we need to get a node out of a list.
void * list_shift_f(LIST *list)
Get a pointer from the start of the list.
LIST * new_generic_list(int max_items)
Initialiaze a generic list container to max_items pointers.
LIST_NODE * list_search(LIST *list, void *ptr)
search ptr in list
int list_push_sorted(LIST *list, void *ptr, int(*comparator)(const void *a, const void *b), void(*destructor)(void *ptr))
Add a pointer sorted in the list , starting by the end of the list.
int list_empty_with_f(LIST *list, void(*free_fnct)(void *ptr))
Empty a LIST list of pointers.
LIST_NODE * list_search_with_f(LIST *list, int(*checkfunk)(void *ptr))
search ptr in list
int list_node_push(LIST *list, LIST_NODE *node)
Add a filled node to the end of the list.
Structure of a generic LIST container.
Structure of a generic list node.