-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strdup.c
26 lines (23 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: myoshie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/07 02:40:12 by myoshie #+# #+# */
/* Updated: 2022/05/27 03:21:22 by myoshie ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
char *ptr;
size_t s1len;
s1len = ft_strlen(s1);
ptr = (char *)malloc(sizeof(char) * (s1len + 1));
if (!ptr)
return (NULL);
ft_strlcpy(ptr, s1, s1len + 1);
return (ptr);
}