diff options
Diffstat (limited to 'philo_one/src/main.c')
| -rw-r--r-- | philo_one/src/main.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/philo_one/src/main.c b/philo_one/src/main.c index 53c1c56..dce44fc 100644 --- a/philo_one/src/main.c +++ b/philo_one/src/main.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/11/24 05:53:02 by cacharle #+# #+# */ -/* Updated: 2020/09/30 08:06:03 by cacharle ### ########.fr */ +/* Updated: 2020/09/30 09:49:48 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,7 +17,6 @@ int main(int argc, char **argv) t_philo_conf conf; t_philo *philos; pthread_mutex_t *forks; - t_routine_arg *routine_args; if (!parse_args((t_philo_args*)&conf, argc, argv)) return (1); @@ -25,22 +24,17 @@ int main(int argc, char **argv) return (0); if ((forks = forks_new(conf.philo_num)) == NULL) return (1); - if ((philos = philos_new(conf.philo_num)) == NULL) - return (1); - if ((routine_args = forks_dispatch(philos, forks, &conf)) == NULL) + if ((philos = philos_new(&conf, forks)) == NULL) return (1); conf.all_alive = true; - pthread_mutex_init(&conf.mutex_all_alive, NULL); pthread_mutex_init(&conf.mutex_stdout, NULL); - if (!philos_start(philos, routine_args, conf.philo_num)) + if (!philos_start(philos, conf.philo_num)) return (1); while (conf.all_alive) ; philos_detach(philos, conf.philo_num); + forks_destroy(forks, conf.philo_num); pthread_mutex_destroy(&conf.mutex_stdout); - pthread_mutex_destroy(&conf.mutex_all_alive); - free(routine_args); free(philos); - forks_destroy(forks, conf.philo_num); return (0); } |
