Browse Source

[enh] libft: better handling.

Moul 3 years ago
parent
commit
3071439e11
2 changed files with 3 additions and 2 deletions
  1. 2 1
      src/ft_strjoinf.c
  2. 1 1
      src/ft_strsplit.c

+ 2 - 1
src/ft_strjoinf.c

@@ -22,7 +22,8 @@ char	*ft_strjoinf(char const *s1, char const *s2, int p)
 {
 	char	*str;
 
-	str = ft_strjoin(s1, s2);
+	if ((str = ft_strjoin(s1, s2)) == NULL)
+		return (NULL);
 	(p == 1 || p == 3) ? ft_strdel((char **)&s1) : ft_strdel((char **)&s2);
 	if (p == 3)
 		ft_strdel((char**)&s2);

+ 1 - 1
src/ft_strsplit.c

@@ -41,7 +41,7 @@ char			**ft_strsplit(char const *s, char c)
 	int		j;
 	int		start;
 
-	if ((s == 0) || (c == 0))
+	if (s == NULL || c == 0)
 		return (NULL);
 	sp = ft_count_words(s, c);
 	tab = malloc((sizeof(char *) * (sp + 1)));