From dedd68047ca557280cc6ec313d3870ee4dd01927 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Sat, 11 Mar 2017 18:33:39 +0100 Subject: [PATCH] lstiter better usage --- libft/includes/lst.h | 4 ++-- libft/src/ft_printf/ft_printf.c | 2 +- libft/src/lst/ft_lstiter.c | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libft/includes/lst.h b/libft/includes/lst.h index 33849050..166cf985 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/08 11:58:26 by jhalford ### ########.fr */ +/* Updated: 2017/03/11 16:18:00 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); -void ft_lstiter(t_list *lst, void (*f)(t_list *elem)); +int ft_lstiter(t_list *lst, int (*f)()); t_list *ft_lstmap(t_list *lst, void *(*f)(void *)); t_list *ft_lstnew_range(int a, int b); diff --git a/libft/src/ft_printf/ft_printf.c b/libft/src/ft_printf/ft_printf.c index b94ab68d..4bfe428f 100644 --- a/libft/src/ft_printf/ft_printf.c +++ b/libft/src/ft_printf/ft_printf.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */ -/* Updated: 2017/03/11 13:14:24 by jhalford ### ########.fr */ +/* Updated: 2017/03/11 18:17:48 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/lst/ft_lstiter.c b/libft/src/lst/ft_lstiter.c index 06bec80f..217f803c 100644 --- a/libft/src/lst/ft_lstiter.c +++ b/libft/src/lst/ft_lstiter.c @@ -6,17 +6,19 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:57:19 by jhalford #+# #+# */ -/* Updated: 2016/12/12 13:31:59 by jhalford ### ########.fr */ +/* Updated: 2017/03/11 16:17:43 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" -void ft_lstiter(t_list *lst, void (*f)(t_list *elem)) +int ft_lstiter(t_list *lst, int (*f)()) { while (lst) { - (*f)(lst); + if ((*f)(lst->content)) + return (1); lst = lst->next; } + return (0); }