created local find_request function

it is basically why2_list_find but I changed it a bit
This commit is contained in:
Václav Šmejkal 2023-04-18 21:08:18 +02:00
parent 6857f5a67a
commit 4fc6d36262
Signed by: ENGO150
GPG Key ID: 4A57E86482968843

View File

@ -347,6 +347,25 @@ void *stop_oldest_thread(void *id)
return NULL; 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 //GLOBAL
void why2_send_socket(char *text, char *username, int socket) void why2_send_socket(char *text, char *username, int socket)
{ {