-
Notifications
You must be signed in to change notification settings - Fork 0
/
work_queue.c
45 lines (40 loc) · 1.46 KB
/
work_queue.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* work_queue.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tdarchiv <tdarchiv@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/28 16:35:09 by tdarchiv #+# #+# */
/* Updated: 2019/02/28 16:35:14 by tdarchiv ### ########.fr */
/* */
/* ************************************************************************** */
#include "work_queue.h"
#include <stddef.h>
void push_work(t_work_queue **queue, t_work_queue *new_work)
{
t_work_queue *work_queue;
t_work_queue *ptr;
work_queue = *queue;
if (work_queue == NULL)
{
*queue = new_work;
return ;
}
ptr = work_queue;
while (ptr->next != NULL)
ptr = ptr->next;
ptr->next = new_work;
}
t_work_queue *pop_work(t_work_queue **queue)
{
t_work_queue *work_queue;
t_work_queue *work_to_pop;
work_queue = *queue;
if (work_queue == NULL)
return (NULL);
work_to_pop = work_queue;
work_queue = work_queue->next;
*queue = work_queue;
return (work_to_pop);
}