-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
41 lines (36 loc) · 1.33 KB
/
main.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
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: smia <smia@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/23 03:56:05 by smia #+# #+# */
/* Updated: 2022/03/15 03:54:37 by smia ### ########.fr */
/* */
/* ************************************************************************** */
#include "philo.h"
int ft_free(t_data *data)
{
int i;
i = -1;
while (++i < data->n_philo)
pthread_mutex_destroy(&(data->forks[i]));
pthread_mutex_destroy(&(data->mutex));
free(data->philos);
free(data->forks);
return (0);
}
int main(int ac, char **av)
{
t_data data;
if (check_args(ac, av) == -1)
return (1);
get_args(&data, av, ac);
if (ft_init(&data) == -1)
return (1);
ft_init_philo(&data);
manager(&data);
ft_free(&data);
return (0);
}