libft/src/ft_strdup.c

27 lines
1.1 KiB
C
Raw Normal View History

2023-04-15 06:46:13 +02:00
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ */
/* By: djonker <marvin@codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/03 09:00:38 by djonker #+# #+# */
/* Updated: 2023/02/07 00:40:50 by houtworm ### ########.fr */
/* */
/* ************************************************************************** */
#include "../libft.h"
char *ft_strdup(const char *s)
{
int i;
char *p;
i = ft_strlen((char *)s) + 1;
p = malloc(i);
if (p == NULL)
return (p);
ft_memcpy(p, s, i);
return (p);
}