diff options
Diffstat (limited to 'libft/ft_strdup.c')
-rw-r--r-- | libft/ft_strdup.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libft/ft_strdup.c b/libft/ft_strdup.c new file mode 100644 index 0000000..0bbfc2e --- /dev/null +++ b/libft/ft_strdup.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strdup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: kdx <kdx @student.42angouleme.fr +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2022/09/28 05:21:01 by kdx #+# #+# */ +/* Updated: 2022/09/28 05:28:25 by kdx ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +char *ft_strdup(const char *s) +{ + char *copy; + size_t s_len; + + s_len = ft_strlen(s) + 1; + copy = malloc(s_len); + if (copy == NULL) + return (NULL); + ft_memcpy(copy, s, s_len); + return (copy); +} |