-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strdup_del.c
33 lines (30 loc) · 1.15 KB
/
ft_strdup_del.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
29
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup_del.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thifranc <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/04/18 17:18:02 by thifranc #+# #+# */
/* Updated: 2016/04/18 17:24:56 by thifranc ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup_del(const char *str)
{
char *out;
int i;
i = 0;
while (str && str[i])
i++;
if (!(out = (char*)malloc(sizeof(char) * i + 1)))
return (NULL);
if (str)
{
ft_strcpy(out, str);
ft_memdel((void*)&str);
}
else
*out = '\0';
return (out);
}