aboutsummaryrefslogtreecommitdiff
path: root/ft_strjoin_free_snd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ft_strjoin_free_snd.c')
-rw-r--r--ft_strjoin_free_snd.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/ft_strjoin_free_snd.c b/ft_strjoin_free_snd.c
new file mode 100644
index 0000000..46e36ae
--- /dev/null
+++ b/ft_strjoin_free_snd.c
@@ -0,0 +1,29 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* ft_strjoin_free_snd.c :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2019/11/05 22:12:56 by cacharle #+# #+# */
+/* Updated: 2019/11/05 22:17:15 by cacharle ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#include <stdlib.h>
+#include "libft.h"
+
+char *ft_strjoin_free_snd(char const *s1, char const *s2)
+{
+ char *joined;
+
+ if (s1 == NULL || s2 == NULL)
+ return (NULL);
+ if ((joined = (char*)malloc(sizeof(char)
+ * (ft_strlen(s1) + ft_strlen(s2) + 1))) == NULL)
+ return (NULL);
+ joined = ft_strcpy(joined, s1);
+ joined = ft_strcat(joined, s2);
+ free((void*)s2);
+ return (joined);
+}