-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup.c
26 lines (23 loc) · 1.14 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: hshinaga <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/02 15:32:09 by hshinaga #+# #+# */
/* Updated: 2024/11/06 00:04:02 by hshinaga ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *src_str)
{
char *new_str;
size_t str_len;
str_len = ft_strlen(src_str);
new_str = (char *)malloc(sizeof(char) * (str_len + 1));
if (!new_str)
return (NULL);
ft_strlcpy(new_str, src_str, str_len + 1);
return (new_str);
}