diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-09-27 10:43:43 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-09-27 10:43:43 +0200 |
| commit | f0a36076950bf0c3356ad73382ce3d341cdb0463 (patch) | |
| tree | 5678bcfa57c94abb918b3d53b8e3ccd28a9c770a /philo_one/forks.c | |
| parent | 3c2c3a07396c001f51eac8d0fd0fc84e83eb127b (diff) | |
| download | philosophers-f0a36076950bf0c3356ad73382ce3d341cdb0463.tar.gz philosophers-f0a36076950bf0c3356ad73382ce3d341cdb0463.tar.bz2 philosophers-f0a36076950bf0c3356ad73382ce3d341cdb0463.zip | |
Added multiple meal, Removing bloat
Diffstat (limited to 'philo_one/forks.c')
| -rw-r--r-- | philo_one/forks.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/philo_one/forks.c b/philo_one/forks.c index 065c7c6..ebe5261 100644 --- a/philo_one/forks.c +++ b/philo_one/forks.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/09 23:46:40 by cacharle #+# #+# */ -/* Updated: 2020/04/22 13:26:58 by charles ### ########.fr */ +/* Updated: 2020/09/27 09:26:12 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,8 +17,7 @@ pthread_mutex_t *forks_new(int num) int i; pthread_mutex_t *forks; - if ((forks = (pthread_mutex_t*)malloc( - sizeof(pthread_mutex_t) * num)) == NULL) + if ((forks = malloc(num * sizeof(pthread_mutex_t))) == NULL) return (NULL); i = -1; while (++i < num) @@ -40,15 +39,14 @@ void forks_destroy(pthread_mutex_t *forks, int num) } t_routine_arg *forks_dispatch( - t_philo *philos, - pthread_mutex_t *forks, - t_philo_conf *conf) + t_philo *philos, + pthread_mutex_t *forks, + t_philo_conf *conf) { int i; t_routine_arg *routine_args; - if ((routine_args = (t_routine_arg*)malloc( - sizeof(t_routine_arg) * conf->philo_num)) == NULL) + if ((routine_args = malloc(conf->philo_num * sizeof(t_routine_arg))) == NULL) return (NULL); i = -1; while (++i < conf->philo_num) |
