-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strjoin_free.c
34 lines (31 loc) · 1.22 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
33
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin_free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dcherend <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/06/25 16:53:18 by dcherend #+# #+# */
/* Updated: 2018/07/04 18:46:02 by dcherend ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoin_free(char *s1, char *s2, _Bool s1b, _Bool s2b)
{
char *str;
if (s1 && s2)
{
str = ft_strnew(ft_strlen(s1) + ft_strlen(s2));
if (str)
{
str = ft_strncat(str, s1, ft_strlen(s1));
str = ft_strncat(str, s2, ft_strlen(s2));
return (str);
}
if (s1b)
free(s1);
if (s2b)
free(s2);
}
return (NULL);
}