From 3eaba0e0c4114f809d487729ee63415480d1e41d Mon Sep 17 00:00:00 2001 From: ENGO150 <v.smejkal06@gmail.com> Date: Wed, 12 Apr 2023 16:52:43 +0200 Subject: [PATCH] moved llist_head into 1st parameter --- include/llist.h | 6 +++--- src/core/lib/utils/llist.c | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/llist.h b/include/llist.h index e76bb4d..6fca169 100644 --- a/include/llist.h +++ b/include/llist.h @@ -25,8 +25,8 @@ typedef struct _why2_node struct _why2_node *next; } why2_node_t; //SINGLE LINKED LIST -void why2_push(void *value); //PUSH ELEMENT TO LIST BACK -void why2_remove(why2_node_t *node); //REMOVE ELEMENT -why2_node_t *why2_find(void *value); //FIND ELEMENT IN LIST +void why2_push(why2_node_t *llist_head, void *value); //PUSH ELEMENT TO LIST BACK +void why2_remove(why2_node_t *llist_head, why2_node_t *node); //REMOVE ELEMENT +why2_node_t *why2_find(why2_node_t *llist_head, void *value); //FIND ELEMENT IN LIST #endif \ No newline at end of file diff --git a/src/core/lib/utils/llist.c b/src/core/lib/utils/llist.c index d7e401b..da6c017 100644 --- a/src/core/lib/utils/llist.c +++ b/src/core/lib/utils/llist.c @@ -22,9 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. #include <stdlib.h> #include <string.h> -why2_node_t *llist_head = NULL; - -void why2_push(void *value) +void why2_push(why2_node_t *llist_head, void *value) { //CREATE NODE why2_node_t *new_node = malloc(sizeof(why2_node_t)); @@ -45,7 +43,7 @@ void why2_push(void *value) } } -void why2_remove(why2_node_t *node) +void why2_remove(why2_node_t *llist_head, why2_node_t *node) { if (node == NULL) return; //NULL NODE @@ -80,7 +78,7 @@ void why2_remove(why2_node_t *node) free(node); } -why2_node_t *why2_find(void *value) +why2_node_t *why2_find(why2_node_t *llist_head, void *value) { if (llist_head == NULL) return NULL; //EMPTY LIST