-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvec_stack.c
28 lines (25 loc) · 1.15 KB
/
vec_stack.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* vec_stack.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alischyn <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/25 16:23:23 by alischyn #+# #+# */
/* Updated: 2017/03/25 16:28:50 by alischyn ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "vec.h"
void vec_push(t_vec *vec, void *item)
{
if (vec->length == vec->capacity)
vec_realloc(vec, 1);
vec->data[vec->length++] = item;
}
void *vec_pop(t_vec *vec)
{
if (vec->length > 0)
return (vec->data[--vec->length]);
return (NULL);
}