diff options
Diffstat (limited to 'philo_one/src/forks.c')
| -rw-r--r-- | philo_one/src/forks.c | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/philo_one/src/forks.c b/philo_one/src/forks.c index ebe5261..fef1de0 100644 --- a/philo_one/src/forks.c +++ b/philo_one/src/forks.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/09 23:46:40 by cacharle #+# #+# */ -/* Updated: 2020/09/27 09:26:12 by charles ### ########.fr */ +/* Updated: 2020/09/30 09:45:46 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -24,7 +24,7 @@ pthread_mutex_t *forks_new(int num) { if (pthread_mutex_init(&forks[i], NULL) != 0) { - forks_destroy(forks, i + 1); + forks_destroy(forks, i); return (NULL); } } @@ -37,24 +37,3 @@ void forks_destroy(pthread_mutex_t *forks, int num) pthread_mutex_destroy(&forks[num]); free(forks); } - -t_routine_arg *forks_dispatch( - t_philo *philos, - pthread_mutex_t *forks, - t_philo_conf *conf) -{ - int i; - t_routine_arg *routine_args; - - if ((routine_args = malloc(conf->philo_num * sizeof(t_routine_arg))) == NULL) - return (NULL); - i = -1; - while (++i < conf->philo_num) - { - routine_args[i].conf = conf; - routine_args[i].philo = philos + i; - routine_args[i].fork_left = forks + i % conf->philo_num; - routine_args[i].fork_right = forks + (i + 1) % conf->philo_num; - } - return (routine_args); -} |
