14-04-2026
26 lines
1.1 kB
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* ft_strdup.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: mleitao <mleitao@student.42.fr> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2026/03/12 22:16:43 by mleitao #+# #+# */
9/* Updated: 2026/04/14 19:22:06 by mleitao ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "libft.h"
14#include <stdlib.h>
15
16char *ft_strdup(const char *s)
17{
18 size_t slen;
19 char *res;
20
21 slen = ft_strlen(s);
22 res = malloc(sizeof(char) * (slen + 1));
23 if (!res)
24 return (NULL);
25 return (ft_memcpy(res, s, slen + 1));
26}