From c3a2f00edc62c7b776fd536f1b9d89a7429eb07b Mon Sep 17 00:00:00 2001 From: max Date: Mon, 28 Oct 2024 19:40:00 +0100 Subject: [PATCH] [ADD] Extended list functionality (added node search) --- src/net/collections/list.c | 19 ++++++++++++++++++- src/net/logging/log.c | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/net/collections/list.c b/src/net/collections/list.c index e8474f9..2e5eb61 100644 --- a/src/net/collections/list.c +++ b/src/net/collections/list.c @@ -4,7 +4,7 @@ #include "list.h" -list_node * insert_end(list_node* list, void* data) +list_node * insert_node(list_node* list, void* data) { list_node* node = (list_node*)malloc(sizeof(list_node)); if (node == NULL) @@ -60,4 +60,21 @@ void iterate_list(list_node* list, bool forward, int (*iterFunc)(const void*)) else current = current->previous; } +} + +list_node* find_node(list_node* list_start, bool forward, int (*findFunc)(const void*)) +{ + if (list_start == NULL || findFunc == NULL) + return NULL; + list_node* current = list_start; + while (current != NULL) + { + if (findFunc(current->data) == 1) + return current; + if (forward) + current = current->next; + else + current = current->previous; + } + return NULL; } \ No newline at end of file diff --git a/src/net/logging/log.c b/src/net/logging/log.c index 8631714..b8ce7cd 100755 --- a/src/net/logging/log.c +++ b/src/net/logging/log.c @@ -20,6 +20,7 @@ int shutdown_logger(const void* data) free(logger); return 0; } + void shutdown_log(app_logger_info* appLogger) { canLog = false;