data_structures
src
data_structures
array
array_set.c
Go to the documentation of this file.
1
/* ************************************************************************** */
3
/* */
4
/* ::: :::::::: */
5
/* array_set.c :+: :+: :+: */
6
/* +:+ +:+ +:+ */
7
/* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8
/* +#+#+#+#+#+ +#+ */
9
/* Created: 2020/07/16 23:44:36 by unite #+# #+# */
10
/* Updated: 2020/09/07 22:28:33 by unite ### ########.fr */
11
/* */
12
/* ************************************************************************** */
13
14
#include "
array.h
"
15
16
void
array_set
(
t_array
*array,
size_t
index,
const
void
*content)
17
{
18
if
(index >= array->
size
)
19
ds_exit_set
(EINVAL);
20
array->
type
->
del
(array->
arr
[index]);
21
array->
arr
[index] = array->
type
->
copy
(content);
22
}
s_type::copy
void *(* copy)(const void *)
A function pointer used to copy the data type.
Definition:
types.h:50
array.h
s_array::type
const t_type * type
The type of items in this array.
Definition:
array.h:52
s_array::arr
void ** arr
The data.
Definition:
array.h:51
s_array
A resizable array.
Definition:
array.h:47
s_type::del
void(* del)(void *)
A function pointer used to free the memory taken by the data type.
Definition:
types.h:51
s_array::size
size_t size
The number of items in this array.
Definition:
array.h:49
array_set
void array_set(t_array *array, size_t index, const void *content)
Replaces the element at the specified position in this array with a copy of the specified element.
Definition:
array_set.c:16
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
Generated by
1.8.16