aboutsummaryrefslogtreecommitdiff
path: root/ft_split.c
diff options
context:
space:
mode:
Diffstat (limited to 'ft_split.c')
-rw-r--r--ft_split.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/ft_split.c b/ft_split.c
index d4ceabf..6fb5964 100644
--- a/ft_split.c
+++ b/ft_split.c
@@ -6,11 +6,11 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/17 08:29:02 by cacharle #+# #+# */
-/* Updated: 2019/10/17 08:39:40 by cacharle ### ########.fr */
+/* Updated: 2019/11/20 04:08:27 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
-#include <stdlib.h>
+#include "libft.h"
static size_t count_segment(char const *s, char c)
{
@@ -33,30 +33,12 @@ static size_t count_segment(char const *s, char c)
return (counter);
}
-static char *ft_strndup(const char *s1, size_t n)
-{
- char *clone;
- size_t i;
-
- if ((clone = (char*)malloc(sizeof(char) * (n + 1))) == NULL)
- return (NULL);
- i = 0;
- while (i < n)
- {
- clone[i] = s1[i];
- i++;
- }
- clone[i] = '\0';
- return (clone);
-}
-
static void *destroy_strs(char **strs)
{
- int i;
-
- i = 0;
- while (strs[i] != NULL)
- free(strs[i++]);
+ if (strs == NULL)
+ return (NULL);
+ while (*strs != NULL)
+ free(*strs++);
free(strs);
return (NULL);
}