-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strdup.c
28 lines (25 loc) · 1.16 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aaslan <aaslan@student.42kocaeli.com.tr +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/13 01:13:29 by aaslan #+# #+# */
/* Updated: 2022/06/02 16:37:04 by aaslan ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s)
{
char *copy_string;
size_t s_len;
if (s == NULL)
return (NULL);
s_len = ft_strlen(s);
copy_string = (char *)malloc(s_len + 1);
if (copy_string == NULL)
return (NULL);
ft_strlcpy(copy_string, s, s_len + 1);
return (copy_string);
}