Nilorea Library list api test.
#define LIST_LIMIT 10
#define NB_TEST_ELEM 15
}
int nstrcmp(
const void* a,
const void* b) {
return 1;
return -1;
}
nstrprintf(nstr,
"Nombre aleatoire : %d", rand() % 1000);
if (nstr) {
int func = rand() % 4;
switch (func) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
default:
break;
}
nstr = NULL;
}
}
nstrprintf(nstr,
"Nombre aleatoire : %d", rand() % 1000);
if (nstr) {
int func = rand() % 4;
switch (func) {
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
default:
break;
}
nstr = NULL;
}
}
}
if (popped) {
}
if (shifted) {
}
if (found) {
}
}
if (removed_ptr) {
}
}
if (nstr) {
if (manual_node) {
}
if (popped_node) {
}
}
nstr = NULL;
}
if (nstr) {
if (manual_node2) {
}
if (shifted_node) {
}
}
nstr = NULL;
}
exit(0);
}
void print_list_info(LIST *list)
int nstrcmp(const void *a, const void *b)
#define __n_assert(__ptr, __ret)
macro to assert things
#define Free(__ptr)
Free Handler to get errors.
#define _nstr(__PTR)
N_STR or "NULL" string for logging purposes.
void * ptr
void pointer to store
size_t nb_max_items
Maximum number of items in the list.
LIST_NODE * start
pointer to the start of the list
size_t nb_items
number of item currently in the list
void(* destroy_func)(void *ptr)
pointer to destructor function if any, else NULL
#define UNLIMITED_LIST_ITEMS
flag to pass to new_generic_list for an unlimited number of item in the list.
#define list_shift(__LIST_, __TYPE_)
Shift macro helper for void pointer casting.
#define list_pop(__LIST_, __TYPE_)
Pop macro helper for void pointer casting.
int list_empty(LIST *list)
Empty a LIST list of pointers.
LIST_NODE * list_search(LIST *list, const void *ptr)
search ptr in list
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.
#define list_foreach(__ITEM_, __LIST_)
ForEach macro helper, safe for node removal during iteration.
#define remove_list_node(__LIST_, __NODE_, __TYPE_)
Remove macro helper for void pointer casting.
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.
LIST * new_generic_list(size_t max_items)
Initialiaze a generic list container to max_items pointers.
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_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.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_DEBUG
debug-level messages
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
#define LOG_NOTICE
normal but significant condition
#define LOG_INFO
informational
void free_nstr_ptr(void *ptr)
Free a N_STR pointer structure.
#define free_nstr(__ptr)
free a N_STR structure and set the pointer to NULL
#define nstrprintf(__nstr_var, __format,...)
Macro to quickly allocate and sprintf to N_STR.
A box including a string and his lenght.
List structures and definitions.
N_STR and string function declaration.