aboutsummaryrefslogtreecommitdiff
path: root/src/str/ft_strdup.c
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-08-02 11:05:33 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-08-02 11:05:33 +0200
commit5d2f925b20ceaea4122c59d2d2c4e7d4ae991fde (patch)
tree80911dc3c32e9f230750e7e1042d413dfb6efab2 /src/str/ft_strdup.c
parentee32953ea79616e72f5428cdf40c834714a891c9 (diff)
parentb96b82194ccad2cddbb46b77aa1962a57c47ff44 (diff)
downloadlibft-5d2f925b20ceaea4122c59d2d2c4e7d4ae991fde.tar.gz
libft-5d2f925b20ceaea4122c59d2d2c4e7d4ae991fde.tar.bz2
libft-5d2f925b20ceaea4122c59d2d2c4e7d4ae991fde.zip
Merge branch 'master' into ft_ssl
Diffstat (limited to 'src/str/ft_strdup.c')
-rw-r--r--src/str/ft_strdup.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/str/ft_strdup.c b/src/str/ft_strdup.c
index b248272..9493d82 100644
--- a/src/str/ft_strdup.c
+++ b/src/str/ft_strdup.c
@@ -11,12 +11,15 @@
/* ************************************************************************** */
#include "libft.h"
+#include "libft_str.h"
char *ft_strdup(const char *s)
{
char *clone;
+ size_t size;
- if ((clone = (char*)malloc(sizeof(char) * (ft_strlen(s) + 1))) == NULL)
+ size = ft_strlen(s) + 1;
+ if ((clone = (char*)malloc(sizeof(char) * size)) == NULL)
return (NULL);
- return (ft_strcpy(clone, s));
+ return (ft_memcpy(clone, s, size));
}