aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/common.h5
-rw-r--r--common/helper.c2
-rw-r--r--common/io.c9
3 files changed, 10 insertions, 6 deletions
diff --git a/common/common.h b/common/common.h
index 2415e73..30a00a2 100644
--- a/common/common.h
+++ b/common/common.h
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/08 22:58:35 by cacharle #+# #+# */
-/* Updated: 2020/10/05 14:30:07 by cacharle ### ########.fr */
+/* Updated: 2021/01/02 11:01:23 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -54,12 +54,13 @@ bool parse_args(t_philo_args *args, int argc, char **argv);
long int h_atou_strict(char *s);
t_time h_time_now(void);
+int h_err(int ret, const char *format, char *str);
/*
** io.c
*/
+void philo_put_set_initial_time(void);
void philo_put(size_t id, t_philo_event event);
-int h_err(int ret, const char *format, char *str);
#endif
diff --git a/common/helper.c b/common/helper.c
index 9f29ad9..e1cc1e2 100644
--- a/common/helper.c
+++ b/common/helper.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/08 23:22:49 by cacharle #+# #+# */
-/* Updated: 2020/10/05 15:28:35 by cacharle ### ########.fr */
+/* Updated: 2021/01/02 12:07:49 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
diff --git a/common/io.c b/common/io.c
index 48bb8cc..cbaa69f 100644
--- a/common/io.c
+++ b/common/io.c
@@ -6,7 +6,7 @@
/* By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/09/30 10:03:53 by cacharle #+# #+# */
-/* Updated: 2020/10/05 15:29:09 by cacharle ### ########.fr */
+/* Updated: 2021/01/02 12:08:16 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
@@ -42,10 +42,13 @@ static void st_strcat(char *dst, char *str)
void philo_put(size_t id, t_philo_event event)
{
- static char buf[2048];
+ static char buf[2048];
+ static t_time initial_time = -1;
+ if (initial_time == -1)
+ initial_time = h_time_now();
buf[0] = '\0';
- st_nbrcpy(buf, h_time_now());
+ st_nbrcpy(buf, h_time_now() - initial_time);
st_strcat(buf, " ");
st_nbrcpy(buf + st_strlen(buf), id);
if (event == EVENT_FORK)