-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strdup.c
25 lines (22 loc) · 1.06 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lenzo-pe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/11 20:59:13 by lenzo-pe #+# #+# */
/* Updated: 2021/04/06 22:35:26 by lenzo-pe ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_string.h"
char *ft_strdup(const char *str)
{
size_t len;
char *ptr;
len = ft_strlen(str) + 1;
ptr = malloc(len);
if (!ptr)
return (NULL);
return (ft_memcpy(ptr, str, len));
}