From adbe9cdb61e5d12299b8872b2ac27a48036bc95d Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 14 Feb 2020 01:42:10 +0100 Subject: WIP: philo_one running a bit --- philo_one/main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'philo_one/main.c') diff --git a/philo_one/main.c b/philo_one/main.c index ef00a0b..94ac0f7 100644 --- a/philo_one/main.c +++ b/philo_one/main.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/11/24 05:53:02 by cacharle #+# #+# */ -/* Updated: 2020/02/10 01:29:50 by cacharle ### ########.fr */ +/* Updated: 2020/02/14 01:41:21 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,10 +19,12 @@ int main(int argc, char **argv) t_philo *philos; t_fork *forks; t_routine_arg *routine_args; + /* mutex_t mutex_stdout; */ + /* pthread_mutex_init(mutex_stdout); */ if (!parse_args(&philo_args, argc, argv)) return (1); - if ((forks = forks_new(philo_args.philo_num - 1)) == NULL) + if ((forks = forks_new(philo_args.philo_num)) == NULL) return (1); if ((philos = philos_new(philo_args.philo_num)) == NULL) { @@ -31,8 +33,8 @@ int main(int argc, char **argv) } if ((routine_args = forks_dispatch(philos, forks, &philo_args)) == NULL) { - free(forks); free(philos); + free(forks); return (1); } if (!philos_start(philos, routine_args, philo_args.philo_num)) @@ -46,8 +48,8 @@ int main(int argc, char **argv) if (philos_starved(philos, philo_args.philo_num)) break; philos_join(philos, philo_args.philo_num); - free(philos); - free(forks); free(routine_args); + free(philos); + forks_destroy(forks, philo_args.philo_num); return (0); } -- cgit