8#if !defined(HAVE_ETH2) && !defined(USE_LIB_ETHEREUM) || defined(HAVE_SDK_LL_LIB)
11#include "os_helpers.h"
19 if ((list == NULL) || (node == NULL)) {
25 if (node->
next != NULL) {
37 if ((list == NULL) || (*list == NULL)) {
42 if (del_func != NULL) {
57 if ((list == NULL) || (node == NULL)) {
69 while (tmp->
next != NULL) {
82 if ((ref == NULL) || (node == NULL)) {
86 if (ref->
next != NULL) {
104 if ((list == NULL) || (node == NULL) || (*list == NULL)) {
109 return pop_front_internal(list, del_func, doubly_linked);
112 while ((it->
next != node) && (it->
next != NULL)) {
115 if (it->
next == NULL) {
125 if (del_func != NULL) {
141 if ((list == NULL) || (pred_func == NULL)) {
145 while (node != NULL) {
147 if (pred_func(node)) {
148 if (remove_internal(list, node, del_func, doubly_linked)) {
163 if ((list == NULL) || (cmp_func == NULL)) {
168 for (tmp = list; (*tmp != NULL) && ((*tmp)->next != NULL); tmp = &(*tmp)->
next) {
171 if (cmp_func(a, b) ==
false) {
178 if (a->
next != NULL) {
196 if ((list == NULL) || (pred_func == NULL)) {
201 while ((node != NULL) && (pred_func(ref, node))) {
203 if (remove_internal(list, node, del_func, doubly_linked)) {
212static bool reverse_internal(
flist_node_t **list,
bool doubly_linked)
222 while (node != NULL) {
241 return push_front_internal(list, node,
false);
246 return pop_front_internal(list, del_func,
false);
251 return push_back_internal(list, node,
false);
258 if ((list == NULL) || (*list == NULL)) {
263 if (tmp->
next == NULL) {
269 if (del_func != NULL) {
279 return insert_after_internal(ref, node,
false);
284 return remove_internal(list, node, del_func,
false);
289 return remove_if_internal(list, pred_func, del_func,
false);
301 while (tmp != NULL) {
303 if (del_func != NULL) {
331 return sort_internal(list, cmp_func,
false);
336 return unique_internal(list, pred_func, del_func,
false);
341 return reverse_internal(list,
false);
355 return pop_front_internal((
flist_node_t **) list, del_func,
true);
370 if ((ref == NULL) || (node == NULL)) {
373 if (ref->
prev == NULL) {
374 if ((list != NULL) && (*list == ref)) {
395 return remove_if_internal((
flist_node_t **) list, pred_func, del_func,
true);
415 return sort_internal((
flist_node_t **) list, cmp_func,
true);
420 return unique_internal((
flist_node_t **) list, pred_func, del_func,
true);
bool list_push_back(list_node_t **list, list_node_t *node)
Add a node at the end of the doubly-linked list.
bool flist_sort(flist_node_t **list, f_list_node_cmp cmp_func)
Sort the forward list using a comparison function.
bool flist_reverse(flist_node_t **list)
Reverse the order of nodes in the forward list.
bool list_remove(list_node_t **list, list_node_t *node, f_list_node_del del_func)
Remove and delete a specific node from the doubly-linked list.
size_t flist_remove_if(flist_node_t **list, f_list_node_pred pred_func, f_list_node_del del_func)
Remove all nodes matching a predicate from the forward list.
bool flist_push_back(flist_node_t **list, flist_node_t *node)
Add a node at the end of the forward list.
bool flist_pop_front(flist_node_t **list, f_list_node_del del_func)
Remove and delete the first node from the forward list.
size_t flist_size(flist_node_t *const *list)
Get the number of nodes in the forward list.
bool list_clear(list_node_t **list, f_list_node_del del_func)
Remove and delete all nodes from the doubly-linked list.
bool list_sort(list_node_t **list, f_list_node_cmp cmp_func)
Sort the doubly-linked list using a comparison function.
bool list_pop_front(list_node_t **list, f_list_node_del del_func)
Remove and delete the first node from the doubly-linked list.
bool list_pop_back(list_node_t **list, f_list_node_del del_func)
Remove and delete the last node from the doubly-linked list.
bool list_empty(list_node_t *const *list)
Check if the doubly-linked list is empty.
bool flist_insert_after(flist_node_t **list, flist_node_t *ref, flist_node_t *node)
Insert a node after a reference node in the forward list.
bool flist_remove(flist_node_t **list, flist_node_t *node, f_list_node_del del_func)
Remove and delete a specific node from the forward list.
size_t list_size(list_node_t *const *list)
Get the number of nodes in the doubly-linked list.
bool list_insert_before(list_node_t **list, list_node_t *ref, list_node_t *node)
Insert a node before a reference node in the doubly-linked list.
size_t flist_unique(flist_node_t **list, f_list_node_bin_pred pred_func, f_list_node_del del_func)
Remove consecutive duplicate nodes from the forward list.
bool flist_empty(flist_node_t *const *list)
Check if the forward list is empty.
bool list_reverse(list_node_t **list)
Reverse the order of nodes in the doubly-linked list.
size_t list_unique(list_node_t **list, f_list_node_bin_pred pred_func, f_list_node_del del_func)
Remove consecutive duplicate nodes from the doubly-linked list.
bool list_push_front(list_node_t **list, list_node_t *node)
Add a node at the beginning of the doubly-linked list.
bool flist_push_front(flist_node_t **list, flist_node_t *node)
Add a node at the beginning of the forward list.
size_t list_remove_if(list_node_t **list, f_list_node_pred pred_func, f_list_node_del del_func)
Remove all nodes matching a predicate from the doubly-linked list.
bool flist_clear(flist_node_t **list, f_list_node_del del_func)
Remove and delete all nodes from the forward list.
bool flist_pop_back(flist_node_t **list, f_list_node_del del_func)
Remove and delete the last node from the forward list.
bool list_insert_after(list_node_t **list, list_node_t *ref, list_node_t *node)
Insert a node after a reference node in the doubly-linked list.
Generic linked list implementation (singly and doubly-linked)
bool(* f_list_node_cmp)(const flist_node_t *a, const flist_node_t *b)
Callback function to compare two nodes for sorting.
bool(* f_list_node_bin_pred)(const flist_node_t *a, const flist_node_t *b)
Callback function to test two nodes for equality (binary predicate)
void(* f_list_node_del)(flist_node_t *node)
Callback function to delete/free a node.
bool(* f_list_node_pred)(const flist_node_t *node)
Callback function to test a single node (unary predicate)
Forward list node structure (singly-linked)
struct flist_node_t * next
Doubly-linked list node structure.
struct list_node_t * prev