-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
26 lines (23 loc) · 1.08 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: adiaz-be <adiaz-be@student.42malaga.c +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/26 17:50:20 by adiaz-be #+# #+# */
/* Updated: 2022/09/26 17:50:50 by adiaz-be ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
char *s2;
size_t size;
size = ft_strlen(s1) + 1;
s2 = (char *)malloc(size);
if (!s2)
return (NULL);
ft_memcpy(s2, s1, ft_strlen(s1) + 1);
return (s2);
}