diff options
author | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2020-02-02 17:18:01 +0100 |
---|---|---|
committer | Rudy Bousset <rbousset@z2r5p6.le-101.fr> | 2020-02-02 17:18:01 +0100 |
commit | 2d05c0e3f57a47f9882dd65144e1479c21f9bab2 (patch) | |
tree | 0aca7f159d649e95d02198d5fcab8e3a95404d60 /libft | |
parent | Correct ft_memdel (diff) | |
download | 42-cub3d-2d05c0e3f57a47f9882dd65144e1479c21f9bab2.tar.gz 42-cub3d-2d05c0e3f57a47f9882dd65144e1479c21f9bab2.tar.bz2 42-cub3d-2d05c0e3f57a47f9882dd65144e1479c21f9bab2.tar.xz 42-cub3d-2d05c0e3f57a47f9882dd65144e1479c21f9bab2.tar.zst 42-cub3d-2d05c0e3f57a47f9882dd65144e1479c21f9bab2.zip |
Norme
Diffstat (limited to 'libft')
-rw-r--r-- | libft/src/ft_split.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/libft/src/ft_split.c b/libft/src/ft_split.c index 1d33dda..5a7bf2d 100644 --- a/libft/src/ft_split.c +++ b/libft/src/ft_split.c @@ -1,10 +1,23 @@ +/* ************************************************************************** */ +/* LE - / */ +/* / */ +/* ft_split.c .:: .:/ . .:: */ +/* +:+:+ +: +: +:+:+ */ +/* By: rbousset <marvin@le-101.fr> +:+ +: +: +:+ */ +/* #+# #+ #+ #+# */ +/* Created: 2020/02/02 17:07:16 by rbousset #+# ## ## #+# */ +/* Updated: 2020/02/02 17:07:17 by rbousset ### #+. /#+ ###.fr */ +/* / */ +/* / */ +/* ************************************************************************** */ + #include <libft.h> #include <stddef.h> #include <stdlib.h> #include <inttypes.h> static size_t -ft_count_words(const char *s, char c) + ft_count_words(const char *s, char c) { size_t i; size_t count; @@ -30,7 +43,7 @@ ft_count_words(const char *s, char c) } static size_t -ft_splitlen(const char *str, char c) + ft_splitlen(const char *str, char c) { size_t i; @@ -58,15 +71,16 @@ static char return (word); } -static void -ft_splitfree(char **best_split, size_t j) +static char + **ft_splitfree(char **best_split, size_t j) { while (j > 0) { - free(best_split[j]); + ft_memdel((void**)&best_split[j]); j--; } - free(best_split); + ft_memdel((void**)best_split); + return (NULL); } char @@ -88,10 +102,7 @@ char while (s[i] != c && s[i]) { if (!(best_split[j] = ft_splitdup(s + i, c))) - { - ft_splitfree(best_split, j); - return (NULL); - } + return (ft_splitfree(best_split, j)); i += ft_splitlen(s + i, c); j++; } |