-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strdup.c
29 lines (26 loc) · 1.1 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
26
27
28
29
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ewilliam <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 17:26:36 by ewilliam #+# #+# */
/* Updated: 2016/11/29 21:08:53 by ewilliam ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
size_t len;
char *s2;
len = ft_strlen(s1);
s2 = malloc(sizeof(char) * len + 1);
if (s2)
{
ft_memcpy(s2, s1, len);
s2[len] = '\0';
return (s2);
}
return (NULL);
}