-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strdup.c
28 lines (25 loc) · 1.11 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: javellis <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/05 13:51:54 by javellis #+# #+# */
/* Updated: 2022/10/05 13:51:58 by javellis ### ########.fr */
/* */
/* ************************************************************************** */
#include <stddef.h>
#include <stdlib.h>
#include "libft.h"
char *ft_strdup(const char *s)
{
int size;
char *dup;
size = ft_strlen(s) + 1;
dup = malloc(size);
if (dup == 0)
return (NULL);
ft_strlcpy(dup, (char *)s, size);
return (dup);
}