-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqueue_pop.c
32 lines (29 loc) · 1.23 KB
/
queue_pop.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* queue_pop.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mihykim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/03/24 13:13:57 by mihykim #+# #+# */
/* Updated: 2020/03/24 15:41:23 by mihykim ### ########.fr */
/* */
/* ************************************************************************** */
#include "queue.h"
void *queue_pop(t_queue *queue)
{
void *storage;
int i;
if (queue == NULL || queue->data == NULL || queue->last_index < 0)
return (NULL);
storage = queue->data[0];
i = 0;
while (i < queue->last_index)
{
queue->data[i] = queue->data[i + 1];
i++;
}
queue->data[queue->last_index] = 0;
queue->last_index--;
return (storage);
}