mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-05-10 22:58:45 +02:00
「🔨」 fix: Fixed strjoin free if str not present
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: mmoussou <mmoussou@student.42angouleme.fr +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/03 19:35:01 by mmoussou #+# #+# */
|
||||
/* Updated: 2024/02/26 03:07:16 by mmoussou ### ########.fr */
|
||||
/* Updated: 2024/05/16 17:36:58 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -41,7 +41,7 @@ char *ft_strjoin_free_s1(char *s1, const char *s2)
|
||||
return (NULL);
|
||||
ft_strlcpy(fstr, s1, ft_strlen(s1) + 1);
|
||||
ft_strlcat(fstr, s2, ft_strlen(s1) + ft_strlen(s2) + 1);
|
||||
if (s1[0])
|
||||
if (s1)
|
||||
free(s1);
|
||||
return (fstr);
|
||||
}
|
||||
@ -59,7 +59,8 @@ char *ft_strjoin_free_s2(const char *s1, char *s2)
|
||||
return (NULL);
|
||||
ft_strlcpy(fstr, s1, ft_strlen(s1) + 1);
|
||||
ft_strlcat(fstr, s2, ft_strlen(s1) + ft_strlen(s2) + 1);
|
||||
free(s2);
|
||||
if (s2)
|
||||
free(s2);
|
||||
return (fstr);
|
||||
}
|
||||
|
||||
@ -76,7 +77,9 @@ char *ft_strjoin_free(char *s1, char *s2)
|
||||
return (NULL);
|
||||
ft_strlcpy(fstr, s1, ft_strlen(s1) + 1);
|
||||
ft_strlcat(fstr, s2, ft_strlen(s1) + ft_strlen(s2) + 1);
|
||||
free(s1);
|
||||
free(s2);
|
||||
if (s1)
|
||||
free(s1);
|
||||
if (s2)
|
||||
free(s2);
|
||||
return (fstr);
|
||||
}
|
||||
|
Reference in New Issue
Block a user