diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-08-02 11:05:33 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-08-02 11:05:33 +0200 |
| commit | 5d2f925b20ceaea4122c59d2d2c4e7d4ae991fde (patch) | |
| tree | 80911dc3c32e9f230750e7e1042d413dfb6efab2 /src/str/ft_strdup.c | |
| parent | ee32953ea79616e72f5428cdf40c834714a891c9 (diff) | |
| parent | b96b82194ccad2cddbb46b77aa1962a57c47ff44 (diff) | |
| download | libft-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.c | 7 |
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)); } |
