-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
30 lines (27 loc) · 1.17 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
30
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yde-goes <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/10 23:19:54 by yde-goes #+# #+# */
/* Updated: 2022/06/24 18:09:23 by yde-goes ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s)
{
char *dest;
char *cast_s;
size_t len;
if ((char *)s == NULL)
return (NULL);
len = (ft_strlen(s) + 1);
dest = malloc(len * sizeof(*dest));
cast_s = (char *) s;
if (dest == NULL)
return (NULL);
ft_strlcpy(dest, cast_s, len);
return (dest);
}