-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfree.c
39 lines (36 loc) · 1.31 KB
/
free.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rtavabil <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/21 16:54:05 by rtavabil #+# #+# */
/* Updated: 2024/03/21 18:33:29 by rtavabil ### ########.fr */
/* */
/* ************************************************************************** */
#include "philosophers.h"
void ft_free(t_args *args)
{
int i;
t_philo *cur;
t_fork *cur_f;
i = 0;
while (i < args->num_phil)
{
cur = args->philos + i;
ft_mutex(&cur->mutex, "destroy");
i++;
}
i = 0;
while (i < args->num_phil)
{
cur_f = args->forks + i;
ft_mutex(&cur_f->fork, "destroy");
i++;
}
ft_mutex(&args->args_mutex, "destroy");
ft_mutex(&args->pr_mutex, "destroy");
free(args->forks);
free(args->philos);
}