This repository was archived by the owner on Aug 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strjoin_free.c
More file actions
39 lines (35 loc) · 1.3 KB
/
Copy pathft_strjoin_free.c
File metadata and controls
39 lines (35 loc) · 1.3 KB
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
35
36
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoin_free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mkristie <kukinpower@ya.ru> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/06/07 13:23:18 by mkristie #+# #+# */
/* Updated: 2020/06/28 03:51:07 by mkristie ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
** Pass 0 to which_to_free if want to free s1 (src) after join
** Pass 1 if want to free s2 (dst)
*/
char *ft_strjoin_free(char *s1, char *s2, int which_to_free)
{
char *str;
if (!s2)
return (s1);
if (!(str = ft_strjoin(s1, s2)))
return (NULL);
if (which_to_free == 0)
{
ft_free_and_clear(s1);
s1 = NULL;
}
else if (which_to_free == 1)
{
ft_free_and_clear(s2);
s2 = NULL;
}
return (str);
}