From 4fc6d36262248a442b33cf984474245c7dfc33ea Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Tue, 18 Apr 2023 21:08:18 +0200 Subject: [PATCH] created local find_request function it is basically why2_list_find but I changed it a bit --- src/chat/misc.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/chat/misc.c b/src/chat/misc.c index 1bc1518..cfd6abf 100644 --- a/src/chat/misc.c +++ b/src/chat/misc.c @@ -347,6 +347,25 @@ void *stop_oldest_thread(void *id) return NULL; } +why2_node_t *find_request(void *thread) //COPIED FROM why2_list_find; using double pointers +{ + why2_node_t *head = waiting_list.head; + if (head == NULL) return NULL; //EMPTY LIST + + why2_node_t *buffer = head; + + while (buffer -> next != NULL) + { + if (*(void**) buffer -> value == thread) return buffer; + + buffer = buffer -> next; + } + + if (thread != *(void**) buffer -> value) buffer = NULL; //PREVENT FROM RETURNING INVALID NODE + + return buffer; +} + //GLOBAL void why2_send_socket(char *text, char *username, int socket) {