From 9a915b797a80c2a776027b1fcc37f1e7b8ab1b24 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Tue, 29 Sep 2020 19:50:20 +0200 Subject: Update --- libft/src/ft_strdup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libft/src/ft_strdup.c') diff --git a/libft/src/ft_strdup.c b/libft/src/ft_strdup.c index ab5b5c1..7de0674 100644 --- a/libft/src/ft_strdup.c +++ b/libft/src/ft_strdup.c @@ -13,18 +13,17 @@ #include #include -char - *ft_strdup(const char *s1) +char *ft_strdup(const char *s1) { char *n_str; size_t slen; size_t i; slen = ft_strlen(s1); - if (!(n_str = (char*)malloc((slen + 1) * sizeof(char)))) + if ((n_str = (char*)malloc((slen + 1) * sizeof(char))) == NULL) return (NULL); i = 0; - while (s1[i]) + while (s1[i] != '\0') { n_str[i] = s1[i]; i++; -- cgit v1.2.3