data_structures
src
data_structures
array
array_delete.c
Go to the documentation of this file.
1
/* ************************************************************************** */
3
/* */
4
/* ::: :::::::: */
5
/* array_delete.c :+: :+: :+: */
6
/* +:+ +:+ +:+ */
7
/* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8
/* +#+#+#+#+#+ +#+ */
9
/* Created: 2020/07/16 23:56:40 by unite #+# #+# */
10
/* Updated: 2020/07/16 23:58:34 by unite ### ########.fr */
11
/* */
12
/* ************************************************************************** */
13
14
#include "
array.h
"
15
16
void
array_delete
(
t_array
*array)
17
{
18
size_t
i;
19
20
if
(array)
21
{
22
if
(array->
arr
)
23
{
24
i = 0;
25
while
(i < array->size)
26
{
27
array->
type
->
del
(array->
arr
[i]);
28
i++;
29
}
30
free(array->
arr
);
31
}
32
free(array);
33
}
34
}
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
array_delete
void array_delete(t_array *array)
Deletes this array and free all its items and the associated data.
Definition:
array_delete.c:16
s_type::del
void(* del)(void *)
A function pointer used to free the memory taken by the data type.
Definition:
types.h:51
Generated by
1.8.16