-
Notifications
You must be signed in to change notification settings - Fork 1
/
c_vector_access.c
39 lines (33 loc) · 1.33 KB
/
c_vector_access.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* c_vector_access.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aleger <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/02/13 17:56:41 by aleger #+# #+# */
/* Updated: 2014/02/14 17:28:41 by aleger ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "c_vector.h"
void *vector_at(t_vector *self, int request)
{
void *ret;
ret = malloc(self->elt_size);
if (ret)
vector_memcpy(ret, VECTOR_INDEX(request), self->elt_size);
return (ret);
}
void *vector_data(t_vector *self, int request)
{
return (VECTOR_INDEX(request));
}
void *vector_front(t_vector *self)
{
return (VECTOR_INDEX(0));
}
void *vector_back(t_vector *self)
{
return (VECTOR_INDEX(self->size(self) - 1));
}