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/common.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/common.c')
| -rw-r--r-- | philo_one/common.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/philo_one/common.c b/philo_one/common.c index b9d6e9a..f67cd48 100644 --- a/philo_one/common.c +++ b/philo_one/common.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 23:12:55 by cacharle #+# #+# */ -/* Updated: 2020/04/22 13:22:51 by charles ### ########.fr */ +/* Updated: 2020/09/27 10:36:31 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,15 +16,17 @@ bool parse_args(t_philo_conf *philo_args, int argc, char **argv) { if (argc != 5 && argc != 6) return (false); - if ((philo_args->philo_num = h_atoi_strict_unsigned(argv[1])) == -1 - || (philo_args->timeout_death = h_atoi_strict_unsigned(argv[2])) == -1 - || (philo_args->timeout_eat = h_atoi_strict_unsigned(argv[3])) == -1 - || (philo_args->timeout_sleep = h_atoi_strict_unsigned(argv[4])) == -1) - return (false); - if (argc == 6 - && (philo_args->meal_num = h_atoi_strict_unsigned(argv[5])) == -1) + if ((philo_args->philo_num = h_atou_strict(argv[1])) == -1 + || (philo_args->timeout_death = h_atou_strict(argv[2])) == -1 + || (philo_args->timeout_eat = h_atou_strict(argv[3])) == -1 + || (philo_args->timeout_sleep = h_atou_strict(argv[4])) == -1) return (false); + if (argc == 6) + { + if ((philo_args->meal_num = h_atou_strict(argv[5])) == -1) + return (false); + } else - philo_args->meal_num = -1; + philo_args->meal_num = 1; return (true); } |
