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/philo.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/philo.c')
| -rw-r--r-- | philo_one/philo.c | 32 |
1 files changed, 3 insertions, 29 deletions
diff --git a/philo_one/philo.c b/philo_one/philo.c index 97a0616..c32dc76 100644 --- a/philo_one/philo.c +++ b/philo_one/philo.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/09 23:47:14 by cacharle #+# #+# */ -/* Updated: 2020/02/15 01:01:51 by cacharle ### ########.fr */ +/* Updated: 2020/09/27 10:42:25 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,7 @@ t_philo *philos_new(int num) if (num < 0) return (NULL); - if ((philos = (t_philo*)h_calloc(num + 1, sizeof(t_philo))) == NULL) + if ((philos = malloc(num * sizeof(t_philo))) == NULL) return (NULL); i = -1; while (++i < num) @@ -30,14 +30,6 @@ t_philo *philos_new(int num) return (philos); } -void philos_destroy(t_philo *philos, int num) -{ - (void)num; - if (philos == NULL) - return ; - free(philos); -} - bool philos_start(t_philo *philos, t_routine_arg *routine_args, int num) { int i; @@ -47,7 +39,7 @@ bool philos_start(t_philo *philos, t_routine_arg *routine_args, int num) { philos[i].alive = true; if (pthread_create(&philos[i].thread, NULL, - &routine_philo, (void*)(routine_args + i)) == -1) + (void *(*)(void*))routine_philo, (void*)(routine_args + i)) == -1) return (false); } return (true); @@ -67,21 +59,3 @@ void philos_join(t_philo *philos, int num) } } } - -bool philos_starved(t_philo *philos, int num) -{ - int i; - - i = -1; - while (++i < num) - { - if (!philos[i].alive) - { - i = -1; - while (++i < num) - philos[i].alive = false; - return (true); - } - } - return (false); -} |
