-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strjoinfree.c
29 lines (26 loc) · 1.26 KB
/
ft_strjoinfree.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
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_strjoinfree.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: davfelix <[email protected]> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2018/11/10 11:33:10 by davfelix #+# ## ## #+# */
/* Updated: 2018/11/15 11:46:23 by davfelix ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include "libft.h"
char *ft_strjoinfree(char const **s1, char const **s2, int free)
{
char *new;
if (!s1 || !s2)
return (NULL);
if (!(new = ft_strjoin(*s1, *s2)))
return (NULL);
if (free == 1 || free == 3)
ft_memdel((void **)s1);
if (free == 2 || free == 3)
ft_memdel((void **)s2);
return (new);
}