![]() |
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. | |
#define | list_foreach(__ITEM_, __LIST_) |
ForEach macro helper. | |
#define | list_pop(__LIST_, __TYPE_) (__TYPE_*)list_pop_f(__LIST_) |
Pop macro helper for void pointer casting. | |
#define | list_shift(__LIST_, __TYPE_) (__TYPE_*)list_shift_f(__LIST_, __FILE__, __LINE__) |
Shift macro helper for void pointer casting. | |
#define | MAX_LIST_ITEMS SIZE_MAX |
flag to pass to new_generic_list for the maximum possible number of item in a list | |
#define | remove_list_node(__LIST_, __NODE_, __TYPE_) (__TYPE_*)remove_list_node_f(__LIST_, __NODE_) |
Remove macro helper for void pointer casting. | |
#define | UNLIMITED_LIST_ITEMS 0 |
flag to pass to new_generic_list for an unlimited number of item in the list. | |
Functions | |
int | list_destroy (LIST **list) |
Empty and Free a list container. | |
int | list_empty (LIST *list) |
Empty a LIST list of pointers. | |
int | list_empty_with_f (LIST *list, void(*free_fnct)(void *ptr)) |
Empty a LIST list of pointers. | |
LIST_NODE * | list_node_pop (LIST *list) |
Get a LIST_NODE pointer from the end of the list. | |
int | list_node_push (LIST *list, LIST_NODE *node) |
Add a filled node to the end of the list. | |
LIST_NODE * | list_node_shift (LIST *list) |
Get a LIST_NODE pointer from the start of the list. | |
int | list_node_unshift (LIST *list, LIST_NODE *node) |
Add a pointer at the start of the list. | |
void * | list_pop_f (LIST *list) |
Get a pointer from the end of the list. | |
int | list_push (LIST *list, void *ptr, void(*destructor)(void *ptr)) |
Add a pointer to the end of the 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. | |
LIST_NODE * | list_search (LIST *list, void *ptr) |
search ptr in list | |
LIST_NODE * | list_search_with_f (LIST *list, int(*checkfunk)(void *ptr)) |
search ptr in list | |
void * | list_shift_f (LIST *list, char *file, size_t line) |
Get a pointer from 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. | |
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 * | new_generic_list (size_t max_items) |
LIST_NODE * | new_list_node (void *ptr, void(*destructor)(void *ptr)) |
Allocate a new node to link in a 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. | |
struct LIST |
Structure of a generic LIST container.
Data Fields | ||
---|---|---|
LIST_NODE * | end | pointer to the end of the list |
size_t | nb_items | number of item currently in the list |
size_t | 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 | |
struct LIST_NODE * | next |
pointer to the next node | |
struct LIST_NODE * | prev |
pointer to the previous node | |
void * | ptr |
void pointer to store | |
void(* LIST_NODE::destroy_func) (void *ptr) |
pointer to destructor function if any, else NULL
Definition at line 29 of file n_list.h.
Referenced by list_empty(), new_list_node(), and tree_insert_child().
struct LIST_NODE* LIST_NODE::next |
pointer to the next node
Definition at line 32 of file n_list.h.
Referenced by draw_particle(), ht_resize(), list_empty(), list_empty_with_f(), list_node_pop(), list_node_push(), list_node_shift(), list_pop_f(), list_push(), list_push_sorted(), list_shift_f(), list_unshift_sorted(), make_str_from_msg(), manage_particle_ex(), move_particles(), n_kafka_poll(), new_list_node(), refresh_thread_pool(), remove_list_node_f(), and tree_delete_node().
struct LIST_NODE* LIST_NODE::prev |
pointer to the previous node
Definition at line 34 of file n_list.h.
Referenced by ht_resize(), list_node_pop(), list_node_push(), list_node_shift(), list_pop_f(), list_push(), list_push_sorted(), list_shift_f(), list_unshift_sorted(), new_list_node(), and remove_list_node_f().
void* LIST_NODE::ptr |
void pointer to store
Definition at line 26 of file n_list.h.
Referenced by draw_particle(), list_pop_f(), list_push_sorted(), list_shift_f(), make_str_from_msg(), manage_particle_ex(), move_particles(), n_kafka_poll(), new_list_node(), new_n_fluid(), refresh_thread_pool(), remove_list_node_f(), tree_delete_node(), and tree_insert_child().
#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_, __FILE__, __LINE__) |
#define MAX_LIST_ITEMS SIZE_MAX |
flag to pass to new_generic_list for the maximum possible number of item in a list
#define remove_list_node | ( | __LIST_, | |
__NODE_, | |||
__TYPE_ | |||
) | (__TYPE_*)remove_list_node_f(__LIST_, __NODE_) |
#define UNLIMITED_LIST_ITEMS 0 |
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 518 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(), create_msg(), 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 471 of file n_list.c.
References __n_assert, LIST_NODE::destroy_func, end, Free, LOG_ERR, n_log, nb_items, LIST_NODE::next, and start.
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 496 of file n_list.c.
References __n_assert, end, Free, LOG_ERR, n_log, nb_items, LIST_NODE::next, and start.
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 120 of file n_list.c.
References __n_assert, end, LOG_ERR, n_log, nb_items, LIST_NODE::next, LIST_NODE::prev, and start.
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 96 of file n_list.c.
References __n_assert, end, LOG_ERR, n_log, nb_items, nb_max_items, LIST_NODE::next, LIST_NODE::prev, and start.
Referenced by ht_resize(), and tree_insert_child().
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 145 of file n_list.c.
References __n_assert, end, LOG_ERR, n_log, nb_items, LIST_NODE::next, LIST_NODE::prev, and start.
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 173 of file n_list.c.
References __n_assert, end, link_node, LOG_ERR, n_log, nb_items, nb_max_items, and start.
void * list_pop_f | ( | LIST * | list | ) |
Get a 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 374 of file n_list.c.
References __n_assert, end, Free, LOG_ERR, n_log, nb_items, LIST_NODE::next, LIST_NODE::prev, LIST_NODE::ptr, and start.
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 199 of file n_list.c.
References __n_assert, end, LOG_ERR, n_log, nb_items, nb_max_items, new_list_node(), LIST_NODE::next, LIST_NODE::prev, and start.
Referenced by _ht_depth_first_search(), _ht_put_double(), _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 233 of file n_list.c.
References __n_assert, end, link_node, list_push(), list_unshift(), LOG_ERR, n_log, nb_items, nb_max_items, new_list_node(), LIST_NODE::next, LIST_NODE::prev, and LIST_NODE::ptr.
Referenced by n_scan_dir().
search ptr in list
list | The target list |
ptr | Searched pointer |
Definition at line 440 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 456 of file n_list.c.
References __n_assert, and list_foreach.
void * list_shift_f | ( | LIST * | list, |
char * | file, | ||
size_t | line | ||
) |
Get a pointer from the start of the list.
Helper function for the list_shift macro.
list | An initilized list container. A null value will cause an error and a _log message. |
file | holder for FILE |
line | holder for LINE |
Definition at line 407 of file n_list.c.
References __n_assert, end, Free, LOG_ERR, n_log, nb_items, LIST_NODE::next, LIST_NODE::prev, LIST_NODE::ptr, and start.
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 288 of file n_list.c.
References __n_assert, end, link_node, LOG_ERR, n_log, nb_items, nb_max_items, new_list_node(), and start.
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 321 of file n_list.c.
References __n_assert, link_node, list_push(), list_unshift(), LOG_ERR, n_log, nb_items, nb_max_items, new_list_node(), LIST_NODE::next, LIST_NODE::prev, and start.
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 38 of file n_list.c.
References __n_assert, LIST_NODE::destroy_func, LOG_ERR, Malloc, n_log, LIST_NODE::next, LIST_NODE::prev, and LIST_NODE::ptr.
Referenced by list_push(), list_push_sorted(), list_unshift(), list_unshift_sorted(), and tree_insert_child().
Internal function called each time we need to get a node out of a list.
list | The list to pick in |
node | The node to remove in the list |
Definition at line 57 of file n_list.c.
References __n_assert, end, Free, LOG_ERR, n_log, nb_items, LIST_NODE::next, LIST_NODE::prev, LIST_NODE::ptr, and start.
Referenced by tree_delete_node().