copy on git
This commit is contained in:
commit
42653de246
205 changed files with 7459 additions and 0 deletions
27
libft/ft_strdup.c
Executable file
27
libft/ft_strdup.c
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strdup.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/14 18:57:34 by thrieg #+# #+# */
|
||||
/* Updated: 2025/02/16 19:04:44 by thrieg ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strdup(const char *s)
|
||||
{
|
||||
char *dup_str;
|
||||
size_t size;
|
||||
|
||||
if (!s)
|
||||
return (NULL);
|
||||
size = (ft_strlen(s) + 1);
|
||||
dup_str = malloc(sizeof(char) * size);
|
||||
if (!dup_str)
|
||||
return (0);
|
||||
return (ft_memcpy(dup_str, s, size));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue