Nilorea Library
C utilities for networking, threading, graphics
|
Data Structures | |
struct | LIST |
Structure of a generic LIST container. More... | |
struct | LIST_NODE |
Structure of a generic list node. More... | |
Macros | |
#define | link_node(__NODE_1, __NODE_2) |
Macro helper for linking two nodes. More... | |
#define | list_foreach(__ITEM_, __LIST_) |
ForEach macro helper. More... | |
#define | list_pop(__LIST_, __TYPE_) ( __TYPE_ *)list_pop_f( __LIST_ ) |
Pop macro helper for void pointer casting. More... | |
#define | list_shift(__LIST_, __TYPE_) (__TYPE_ *)list_shift_f( __LIST_ ) |
Shift macro helper for void pointer casting. More... | |
#define | remove_list_node(__LIST_, __NODE_, __TYPE_) (__TYPE_ *)remove_list_node_f( __LIST_ , __NODE_ ) |
Remove macro helper for void pointer casting. More... | |
Functions | |
int | list_destroy (LIST **list) |
Empty and Free a list container. More... | |
int | list_empty (LIST *list) |
Empty a LIST list of pointers. More... | |
int | list_empty_with_f (LIST *list, void(*free_fnct)(void *ptr)) |
Empty a LIST list of pointers. More... | |
LIST_NODE * | list_node_pop (LIST *list) |
Get a LIST_NODE pointer from the end of the list. More... | |
int | list_node_push (LIST *list, LIST_NODE *node) |
Add a filled node to the end of the list. More... | |
LIST_NODE * | list_node_shift (LIST *list) |
Get a LIST_NODE pointer from the start of the list. More... | |
int | list_node_unshift (LIST *list, LIST_NODE *node) |
Add a pointer at the start of the list. More... | |
void * | list_pop_f (LIST *list) |
Get a pointer from the end of the list. More... | |
int | list_push (LIST *list, void *ptr, void(*destructor)(void *ptr)) |
Add a pointer to the end of the list. More... | |
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. More... | |
LIST_NODE * | list_search (LIST *list, void *ptr) |
search ptr in list More... | |
LIST_NODE * | list_search_with_f (LIST *list, int(*checkfunk)(void *ptr)) |
search ptr in list More... | |
void * | list_shift_f (LIST *list) |
Get a pointer from the start of the list. More... | |
int | list_unshift (LIST *list, void *ptr, void(*destructor)(void *ptr)) |
Add a pointer at the start of the list. More... | |
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. More... | |
LIST * | new_generic_list (int max_items) |
Initialiaze a generic list container to max_items pointers. More... | |
LIST_NODE * | new_list_node (void *ptr, void(*destructor)(void *ptr)) |
Allocate a new node to link in a list. More... | |
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. More... | |
struct LIST |
Structure of a generic LIST container.
Data Fields | ||
---|---|---|
LIST_NODE * | end | pointer to the end of the list |
int | nb_items | number of item currently in the list |
int | nb_max_items |
maximum number of item in the list. Unlimited 0 or negative |
LIST_NODE * | start | pointer to the start of the list |
struct LIST_NODE |
Data Fields | |
void(* | destroy_func )(void *ptr) |
pointer to destructor function if any, else NULL More... | |
struct LIST_NODE * | next |
pointer to the next node More... | |
struct LIST_NODE * | prev |
pointer to the previous node More... | |
void * | ptr |
void pointer to store More... | |
void(* LIST_NODE::destroy_func) (void *ptr) |
struct LIST_NODE* LIST_NODE::prev |
#define link_node | ( | __NODE_1, | |
__NODE_2 | |||
) |
#define list_foreach | ( | __ITEM_, | |
__LIST_ | |||
) |
ForEach macro helper.
#define list_pop | ( | __LIST_, | |
__TYPE_ | |||
) | ( __TYPE_ *)list_pop_f( __LIST_ ) |
#define list_shift | ( | __LIST_, | |
__TYPE_ | |||
) | (__TYPE_ *)list_shift_f( __LIST_ ) |
#define remove_list_node | ( | __LIST_, | |
__NODE_, | |||
__TYPE_ | |||
) | (__TYPE_ *)remove_list_node_f( __LIST_ , __NODE_ ) |
int list_destroy | ( | LIST ** | list | ) |
Empty and Free a list container.
Call the destructor each time.
list | The list to destroy. An already empty or null list will cause an error and a _log message. |
Definition at line 603 of file n_list.c.
References __n_assert, Free, list_empty(), LOG_ERR, and n_log.
Referenced by _destroy_ht(), _ht_search(), _ht_search_trie(), delete_msg(), destroy_config_file(), destroy_threaded_pool(), ht_get_completion_list(), ht_resize(), n_kafka_delete(), n_kafka_event_destroy_ptr(), netw_close(), netw_set(), new_ht(), and userlist_destroy().
int list_empty | ( | LIST * | list | ) |
Empty a LIST list of pointers.
list | The list to empty. An already empty or null list will cause an error and a _log message. |
Definition at line 547 of file n_list.c.
References __n_assert, Free, LOG_ERR, and n_log.
Referenced by empty_msg(), list_destroy(), netw_set(), userlist_del_user(), userlist_send_waiting_msgs(), and userlist_user_send_waiting_msgs().
int list_empty_with_f | ( | LIST * | list, |
void(*)(void *ptr) | free_fnct | ||
) |
Empty a LIST list of pointers.
list | The list to empty. An already empty or null list will cause an error and a _log message. |
free_fnct | a function ptr to a void func( void *ptr ) |
Definition at line 577 of file n_list.c.
References __n_assert, Free, LOG_ERR, and n_log.
Get a LIST_NODE pointer from the end of the list.
list | An initilized list container. A null value will cause an error and a _log message. |
Definition at line 150 of file n_list.c.
References __n_assert, LOG_ERR, and n_log.
Add a filled node to the end of the list.
list | An initilized list container. A null value will cause an error and a _log message. |
node | The node pointer you want to put in the list. A null value will cause an error and a _log message. |
Definition at line 120 of file n_list.c.
References __n_assert, LOG_ERR, and n_log.
Referenced by ht_resize().
Get a LIST_NODE pointer from the start of the list.
list | An initilized list container. A null value will cause an error and a _log message. |
Definition at line 179 of file n_list.c.
References __n_assert, LOG_ERR, and n_log.
Referenced by ht_resize().
Add a pointer at the start of the list.
list | An initilized list container. A null value will cause an error and a _log message. |
node | The node pointer you wan to put in the list. A null value will cause an error and a _log message. |
Definition at line 212 of file n_list.c.
References __n_assert, link_node, LOG_ERR, and n_log.
void * list_pop_f | ( | LIST * | list | ) |
int list_push | ( | LIST * | list, |
void * | ptr, | ||
void(*)(void *ptr) | destructor | ||
) |
Add a pointer to the end of the list.
list | An initilized list container. A null value will cause an error and a _log message. |
ptr | The pointer you wan to put in the list. A null value will cause an error and a _log message. |
destructor | Pointer to the ptr type destructor function. Leave to NULL if there isn't. |
Definition at line 244 of file n_list.c.
References __n_assert, LOG_ERR, n_log, and new_list_node().
Referenced by _ht_depth_first_search(), _ht_put_double(), _ht_put_int(), _ht_put_ptr(), _ht_put_string(), _ht_put_string_ptr(), _ht_search(), _ht_search_trie_helper(), add_int_to_msg(), add_nb_to_msg(), add_nstrdup_to_msg(), add_nstrptr_to_msg(), add_particle(), add_strdup_to_msg(), add_threaded_process(), ht_get_completion_list(), ht_put_ptr_ex(), list_push_sorted(), list_unshift_sorted(), load_config_file(), n_kafka_poll(), n_kafka_produce(), netw_add_msg(), netw_add_msg_ex(), netw_pool_add(), netw_recv_func(), new_n_fluid(), scan_dir_ex(), and userlist_user_add_waiting_msg().
int list_push_sorted | ( | LIST * | list, |
void * | ptr, | ||
int(*)(const void *a, const void *b) | comparator, | ||
void(*)(void *ptr) | destructor | ||
) |
Add a pointer sorted in the list , starting by the end of the list.
list | An initilized list container. A null value will cause an error and a _log message. |
ptr | The pointer you wan to put in the list. A null value will cause an error and a _log message. |
comparator | A pointer to a function which take two void * pointers and return an int. |
destructor | Pointer to the ptr type destructor function. Leave to NULL if there isn't. |
Definition at line 285 of file n_list.c.
References __n_assert, link_node, list_push(), list_unshift(), LOG_ERR, n_log, and new_list_node().
Referenced by n_scan_dir().
search ptr in list
list | The target list |
ptr | Searched pointer |
Definition at line 508 of file n_list.c.
References __n_assert, and list_foreach.
Referenced by netw_pool_remove().
search ptr in list
list | The target list |
checkfunk | Function pointer who should return 1 if it matches or 0 if it's not |
Definition at line 528 of file n_list.c.
References __n_assert, and list_foreach.
void * list_shift_f | ( | LIST * | list | ) |
int list_unshift | ( | LIST * | list, |
void * | ptr, | ||
void(*)(void *ptr) | destructor | ||
) |
Add a pointer at the start of the list.
list | An initilized list container. A null value will cause an error and a _log message. |
ptr | The pointer you wan to put in the list. A null value will cause an error and a _log message. |
destructor | Pointer to the ptr type destructor function. Leave to NULL if there isn't. |
Definition at line 342 of file n_list.c.
References __n_assert, link_node, LOG_ERR, n_log, and new_list_node().
Referenced by list_push_sorted(), and list_unshift_sorted().
int list_unshift_sorted | ( | LIST * | list, |
void * | ptr, | ||
int(*)(const void *a, const void *b) | comparator, | ||
void(*)(void *ptr) | destructor | ||
) |
Add a pointer sorted in the list , starting by the start of the list.
list | An initilized list container. A null value will cause an error and a _log message. |
ptr | The pointer you wan to put in the list. A null value will cause an error and a _log message. |
comparator | A pointer to a function which take two void * pointers and return an int. |
destructor | Pointer to the ptr type destructor function. Leave to NULL if there isn't. |
Definition at line 382 of file n_list.c.
References __n_assert, link_node, list_push(), list_unshift(), LOG_ERR, n_log, and new_list_node().
LIST * new_generic_list | ( | int | max_items | ) |
Initialiaze a generic list container to max_items pointers.
max_items | Specify a max size for the list container, 0 or negative for unlimited lists. |
Definition at line 20 of file n_list.c.
References __n_assert, and Malloc.
Referenced by _ht_search(), _ht_search_trie(), create_msg(), ht_get_completion_list(), ht_resize(), init_particle_system(), load_config_file(), n_kafka_new(), n_kafka_poll(), netw_new(), new_ht(), new_n_fluid(), new_thread_pool(), and userlist_new().
LIST_NODE * new_list_node | ( | void * | ptr, |
void(*)(void *ptr) | destructor | ||
) |
Allocate a new node to link in a list.
ptr | The pointer you want to put in the node. |
destructor | Pointer to the ptr type destructor function. Leave to NULL if there isn't. |
Definition at line 46 of file n_list.c.
References __n_assert, LOG_ERR, Malloc, and n_log.
Referenced by list_push(), list_push_sorted(), list_unshift(), and list_unshift_sorted().