aboutsummaryrefslogtreecommitdiff
path: root/philo_one/helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'philo_one/helper.c')
-rw-r--r--philo_one/helper.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/philo_one/helper.c b/philo_one/helper.c
index cd4b8a0..2c3db3d 100644
--- a/philo_one/helper.c
+++ b/philo_one/helper.c
@@ -6,7 +6,7 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/08 23:22:49 by cacharle #+# #+# */
-/* Updated: 2020/04/22 11:57:08 by charles ### ########.fr */
+/* Updated: 2020/09/27 10:43:04 by charles ### ########.fr */
/* */
/* ************************************************************************** */
@@ -22,7 +22,7 @@ static int h_strlen(char *s)
return (counter);
}
-long int h_atoi_strict_unsigned(char *s)
+long int h_atou_strict(char *s)
{
long int num;
@@ -32,12 +32,16 @@ long int h_atoi_strict_unsigned(char *s)
while (*s >= '0' && *s <= '9')
{
num *= 10;
+ if (num > UINT_MAX)
+ return (-1);
num += *s - '0';
+ if (num > UINT_MAX)
+ return (-1);
s++;
}
if (*s != '\0')
return (-1);
- return num;
+ return (num);
}
void h_putnbr(unsigned long int num)
@@ -57,19 +61,6 @@ void h_putstr(char *s)
write(STDOUT_FILENO, s, h_strlen(s));
}
-void *h_calloc(int count, int size)
-{
- int i;
- void *ptr;
-
- if ((ptr = malloc(count * size)) == NULL)
- return (NULL);
- i = count * size;
- while (i-- > 0)
- ((unsigned char*)ptr)[i] = 0x0;
- return (ptr);
-}
-
t_time h_time_now(void)
{
struct timeval tv;