data_structures
array_get.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* array_get.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2020/07/16 23:25:55 by unite #+# #+# */
10 /* Updated: 2020/09/07 21:51:17 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "array.h"
15 
16 void *array_get(const t_array *array, size_t index)
17 {
18  if (index >= array->size)
19  ds_exit_set(EINVAL);
20  return (array->arr[index]);
21 }
array_get
void * array_get(const t_array *array, size_t index)
Returns the item at the specified position in this list.
Definition: array_get.c:16
array.h
s_array::arr
void ** arr
The data.
Definition: array.h:51
s_array
A resizable array.
Definition: array.h:47
s_array::size
size_t size
The number of items in this array.
Definition: array.h:49
ds_exit_set
void ds_exit_set(int err)
Set errno to the specified value, print the error message, and exit the process.
Definition: ds_exit_set.c:22