From 47e1a7b4af69e1998182126310e42af83cf214ed Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Mon, 5 Oct 2020 17:00:51 +0200 Subject: Norming and destroy on error --- common/helper.c | 10 +++++++--- common/io.c | 12 ++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'common') diff --git a/common/helper.c b/common/helper.c index b2107ae..9f29ad9 100644 --- a/common/helper.c +++ b/common/helper.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 23:22:49 by cacharle #+# #+# */ -/* Updated: 2020/09/30 10:15:14 by cacharle ### ########.fr */ +/* Updated: 2020/10/05 15:28:35 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -36,11 +36,15 @@ long int h_atou_strict(char *s) return (num); } +/* +** No need to check error of gettimeofday +** (only for settimeofday and passed pointer validity) +*/ + t_time h_time_now(void) { struct timeval tv; - if (gettimeofday(&tv, NULL) == -1) - return (-1); + gettimeofday(&tv, NULL); return (tv.tv_sec * 1000 + tv.tv_usec / 1000); } diff --git a/common/io.c b/common/io.c index 355135a..48bb8cc 100644 --- a/common/io.c +++ b/common/io.c @@ -6,13 +6,13 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/09/30 10:03:53 by cacharle #+# #+# */ -/* Updated: 2020/10/05 14:27:13 by cacharle ### ########.fr */ +/* Updated: 2020/10/05 15:29:09 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ #include "common.h" -size_t st_strlen(char *s) +static size_t st_strlen(char *s) { int counter; @@ -22,7 +22,7 @@ size_t st_strlen(char *s) return (counter); } -static char *st_nbrcpy(char *dst, long long int num) +static char *st_nbrcpy(char *dst, long long int num) { if (num > 9) dst = st_nbrcpy(dst, num / 10); @@ -31,7 +31,7 @@ static char *st_nbrcpy(char *dst, long long int num) return (dst + 1); } -static void st_strcat(char *dst, char *str) +static void st_strcat(char *dst, char *str) { while (*dst != '\0') dst++; @@ -40,7 +40,7 @@ static void st_strcat(char *dst, char *str) *dst = '\0'; } -void philo_put(size_t id, t_philo_event event) +void philo_put(size_t id, t_philo_event event) { static char buf[2048]; @@ -61,7 +61,7 @@ void philo_put(size_t id, t_philo_event event) write(STDOUT_FILENO, buf, st_strlen(buf)); } -int h_err(int ret, const char *format, char *str) +int h_err(int ret, const char *format, char *str) { while (*format != '\0') { -- cgit