-
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: nopereir <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/19 17:29:58 by nopereir #+# #+# */
/* Updated: 2022/06/19 18:09:50 by nopereir ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s)
{
int s_len;
char *aux;
s_len = ft_strlen(s) + 1;
aux = (char *)malloc(s_len * sizeof(char));
if (!aux || s_len == 0)
return (NULL);
ft_strlcpy(aux, s, s_len);
return (aux);
}