/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strdup.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/11/07 16:53:59 by rparodi #+# #+# */ /* Updated: 2025/09/01 17:58:58 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "str.h" #include /** * @brief Duplicates a string. * * @param s1 The string to duplicate. * * @return A pointer to the duplicated string, * or NULL if memory allocation fails. */ char *ft_strdup(const char *s) { size_t len; char *to_return; len = ft_strlen(s) + 1; to_return = (char *)malloc(sizeof(char) * len); if (!to_return) return (NULL); ft_strlcpy(to_return, s, len); return (to_return); }