diff options
Diffstat (limited to 'philo_one/src/philo.c')
| -rw-r--r-- | philo_one/src/philo.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/philo_one/src/philo.c b/philo_one/src/philo.c index 6ea1024..30c0a7c 100644 --- a/philo_one/src/philo.c +++ b/philo_one/src/philo.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/09 23:47:14 by cacharle #+# #+# */ -/* Updated: 2020/10/05 14:29:10 by cacharle ### ########.fr */ +/* Updated: 2020/10/05 16:13:10 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -43,8 +43,12 @@ bool philos_start(t_philo *philos, int num) &philos[i].thread, NULL, (t_routine)routine_philo, - (void*)(philos + i)) == -1) + (void*)(philos + i)) != 0) + { + while (--i >= 0) + pthread_detach(philos[i].thread); return (false); + } } return (true); } @@ -53,9 +57,9 @@ void philos_detach(t_philo *philos, int num) { int i; + if (philos == NULL) + return ; i = -1; while (++i < num) - { pthread_detach(philos[i].thread); - } } |
