From ce100d4c7f1128ed3c364a97ab105db39c609350 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Fri, 31 Mar 2017 18:38:57 +0200 Subject: [PATCH] stuff --- libft/includes/libft.h | 9 ++------- libft/includes/lst.h | 4 ++-- libft/includes/types.h | 22 ++++++++++++++++++++++ libft/src/lst/ft_lstiter.c | 16 +++++++--------- 4 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 libft/includes/types.h diff --git a/libft/includes/libft.h b/libft/includes/libft.h index aa81b9a9..7daf9464 100644 --- a/libft/includes/libft.h +++ b/libft/includes/libft.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */ -/* Updated: 2017/03/26 17:07:15 by jhalford ### ########.fr */ +/* Updated: 2017/03/28 10:58:15 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,6 +21,7 @@ # include # include +# include "types.h" # include "error.h" # include "color.h" # include "cliopts.h" @@ -36,12 +37,6 @@ # include "get_next_line.h" # include "sys.h" -typedef struct s_stos t_stos; -typedef struct s_stof t_stof; -typedef struct s_itof t_itof; -typedef long long t_type; -typedef long long t_flag; - struct s_stos { char *key; diff --git a/libft/includes/lst.h b/libft/includes/lst.h index b62bf152..4b5eb5c0 100644 --- a/libft/includes/lst.h +++ b/libft/includes/lst.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:27:46 by jhalford #+# #+# */ -/* Updated: 2017/03/26 17:08:28 by jhalford ### ########.fr */ +/* Updated: 2017/03/28 20:34:27 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -31,7 +31,7 @@ t_list *ft_lstnew(void const *content, size_t content_size); void ft_lstdel(t_list **alst, void (*del)(void *, size_t)); void ft_lstdelone(t_list **alst, void (*del)(void *, size_t)); void ft_lstadd(t_list **alst, t_list *new); -int ft_lstiter(t_list *lst, int (*f)()); +int ft_lstiter(t_list *lst, int (*f)(), void *data); t_list *ft_lstmap(t_list *lst, void *(*f)(void *)); t_list *ft_lstnew_range(int a, int b); diff --git a/libft/includes/types.h b/libft/includes/types.h new file mode 100644 index 00000000..45f81361 --- /dev/null +++ b/libft/includes/types.h @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/28 10:57:17 by jhalford #+# #+# */ +/* Updated: 2017/03/28 10:57:34 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_H +# define TYPES_H + +typedef struct s_stos t_stos; +typedef struct s_stof t_stof; +typedef struct s_itof t_itof; +typedef long long t_type; +typedef long long t_flag; + +#endif diff --git a/libft/src/lst/ft_lstiter.c b/libft/src/lst/ft_lstiter.c index 217f803c..49a96476 100644 --- a/libft/src/lst/ft_lstiter.c +++ b/libft/src/lst/ft_lstiter.c @@ -6,19 +6,17 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:57:19 by jhalford #+# #+# */ -/* Updated: 2017/03/11 16:17:43 by jhalford ### ########.fr */ +/* Updated: 2017/03/28 11:27:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" -int ft_lstiter(t_list *lst, int (*f)()) +int ft_lstiter(t_list *lst, int (*f)(), void *data) { - while (lst) - { - if ((*f)(lst->content)) - return (1); - lst = lst->next; - } - return (0); + if (!lst) + return (0); + if ((*f)(lst->content, data)) + return (1); + return (ft_lstiter(lst->next, f, data)); }