42-archive/libft/srcs/str/ft_strdup.c
2017-03-31 18:40:30 +02:00

23 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/07 14:25:41 by jhalford #+# #+# */
/* Updated: 2017/03/07 14:27:58 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
char *dup;
if (!s1 || !(dup = (char*)malloc(sizeof(*dup) * (ft_strlen(s1) + 1))))
return (NULL);
ft_strcpy(dup, s1);
return (dup);
}