Merge branch 'master' of git.chauvet.pro:starnakin/42_Philosopher

This commit is contained in:
Camille Chauvet 2023-05-24 13:55:43 +00:00
commit 550851a5c8
3 changed files with 8 additions and 6 deletions

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 11:34:57 by cchauvet #+# #+# */ /* Created: 2023/04/27 11:34:57 by cchauvet #+# #+# */
/* Updated: 2023/04/27 11:34:58 by cchauvet ### ########.fr */ /* Updated: 2023/05/17 13:43:29 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -30,6 +30,8 @@ static bool check_value(char **av, size_t n)
{ {
if (ft_isnum(av[i]) == 0) if (ft_isnum(av[i]) == 0)
return (1); return (1);
if (!(ft_atoi(av[i]) > 0))
return (1);
i++; i++;
} }
return (0); return (0);

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 11:33:33 by cchauvet #+# #+# */ /* Created: 2023/04/27 11:33:33 by cchauvet #+# #+# */
/* Updated: 2023/05/17 13:22:19 by cchauvet ### ########.fr */ /* Updated: 2023/05/17 13:33:17 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -30,7 +30,7 @@ static void print(t_data *data, size_t id, char *str)
if (stop == false) if (stop == false)
{ {
time = get_time(); time = get_time();
printf("%zu %zu %s\n", time, id, str); printf("%07zu %07zu %s\n", time, id + 1, str);
} }
pthread_mutex_unlock(&data->print_mutex); pthread_mutex_unlock(&data->print_mutex);
} }

View File

@ -6,7 +6,7 @@
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */ /* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/27 11:41:14 by cchauvet #+# #+# */ /* Created: 2023/04/27 11:41:14 by cchauvet #+# #+# */
/* Updated: 2023/05/17 13:21:33 by cchauvet ### ########.fr */ /* Updated: 2023/05/17 13:33:33 by cchauvet ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -22,6 +22,6 @@ void print_died(t_philo *philo)
data = philo->data; data = philo->data;
time = get_time(); time = get_time();
pthread_mutex_lock(&data->print_mutex); pthread_mutex_lock(&data->print_mutex);
printf("%7zu %3zu %s\n", time, philo->id, "died"); printf("%07zu %03zu %s\n", time, philo->id + 1, "died");
pthread_mutex_unlock(&data->print_mutex); pthread_mutex_unlock(&data->print_mutex);
} }