libft/ft_strdup.c
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jlasne <jlasne@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/09/03 17:32:21 by jlasne #+# #+# */
/* Updated: 2016/11/05 10:43:08 by jlasne ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdlib.h>
char *ft_strdup(const char *s)
{
int size_s;
int i;
char *ret;
i = -1;
size_s = ft_strlen(s);
if (!(ret = (char *)malloc((size_s + 1) * sizeof(char))))
return (NULL);
while (s[++i] != '\0')
ret[i] = s[i];
ret[i] = '\0';
return (ret);
}