-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strjoin_free.c
32 lines (29 loc) · 1.27 KB
/
ft_strjoin_free.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin_free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mesafi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/21 20:59:59 by mesafi #+# #+# */
/* Updated: 2020/01/21 21:00:02 by mesafi ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin_free(char const *s1, char const *s2, int option)
{
char *str;
if (s2 == NULL || *s2 == 0)
str = ft_strdup(s1);
else if (s1 == NULL || *s1 == 0)
str = ft_strdup(s2);
else
str = ft_strjoin(s1, s2);
if (option == 1 || option == 0)
if (s1 != NULL)
free((void *)s1);
if (option == 2 || option == 0)
if (s2 != NULL)
free((void *)s2);
return (str);
}