From edb265b68ec24e0ae99d0f3303629ef1f0f7eeda Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Tue, 30 Aug 2016 00:40:33 +0200 Subject: [PATCH] strlen 0 if NULL strng --- libftasm/ft_strlen.c | 2 ++ libftasm/libft.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/libftasm/ft_strlen.c b/libftasm/ft_strlen.c index 2e73dbb9..cf3f6c5a 100644 --- a/libftasm/ft_strlen.c +++ b/libftasm/ft_strlen.c @@ -5,6 +5,8 @@ size_t ft_strlen(const char *s) int i; i = 0; + if (!s) + return (0); while (s[i]) i++; return (i); diff --git a/libftasm/libft.h b/libftasm/libft.h index 7b82a039..87ba3de0 100644 --- a/libftasm/libft.h +++ b/libftasm/libft.h @@ -7,6 +7,9 @@ # define ABS(x) (((x) < 0) ? -(x) : (x)) # define NEG(x) (((x) < 0) ? 1 : 0) # define POS(x) (((x) > 0) ? 1 : 0) +# define MIN(a, b) ((a) < (b) ? (a) : (b)) +# define MAX(a, b) ((a) > (b) ? (a) : (b)) +# define DIST(a, b) (ABS((a) - (b))) typedef struct s_list {