-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strdup.c
25 lines (22 loc) · 1.09 KB
/
ft_strdup.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vscabell <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/26 14:34:19 by vscabell #+# #+# */
/* Updated: 2020/02/06 18:14:40 by vscabell ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
char *s2;
size_t lenplus;
lenplus = ft_strlen(s1) + 1;
if (!(s2 = malloc(lenplus * sizeof(char))))
return (NULL);
ft_memcpy(s2, s1, lenplus);
return (s2);
}