diff --git a/libft/Makefile b/libft/Makefile index 82bdc215..b699473b 100644 --- a/libft/Makefile +++ b/libft/Makefile @@ -6,7 +6,7 @@ # By: jhalford +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2017/02/07 16:09:36 by jhalford #+# #+# # -# Updated: 2017/03/07 14:28:55 by ariard ### ########.fr # +# Updated: 2017/03/08 01:11:01 by ariard ### ########.fr # # # # **************************************************************************** # @@ -94,6 +94,7 @@ lst/ft_lst_sorted_merge.c\ lst/ft_lstadd.c\ lst/ft_lstdel.c\ lst/ft_lstdelone.c\ +lst/ft_lstdup.c\ lst/ft_lsteadd.c\ lst/ft_lstiter.c\ lst/ft_lstlast.c\ @@ -150,6 +151,7 @@ str/ft_strbetween.c\ str/ft_strcat.c\ str/ft_strcatf.c\ str/ft_strchr.c\ +str/ft_strchrcpy.c\ str/ft_strclr.c\ str/ft_strcmp.c\ str/ft_strcpy.c\ @@ -173,7 +175,6 @@ str/ft_strmapi.c\ str/ft_strncat.c\ str/ft_strncmp.c\ str/ft_strncpy.c\ -str/ft_strchrcpy.c\ str/ft_strnequ.c\ str/ft_strnew.c\ str/ft_strnstr.c\ diff --git a/libft/includes/lst.h b/libft/includes/lst.h index ef3ccf6d..049809f9 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/03 13:36:18 by jhalford ### ########.fr */ +/* Updated: 2017/03/08 01:44:29 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,6 +33,7 @@ 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)); t_list *ft_lstmap(t_list *lst, t_list *(*f)(t_list *elem)); +t_list *ft_lstdup(t_list **lst, void *(*f)(void *content)); t_list *ft_lstnew_range(int a, int b); void ft_lsteadd(t_list **alst, t_list *new); diff --git a/libft/src/btree/btree_create_node.c b/libft/src/btree/btree_create_node.c index 18f50233..53a90bf7 100644 --- a/libft/src/btree/btree_create_node.c +++ b/libft/src/btree/btree_create_node.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/08/16 13:43:51 by jhalford #+# #+# */ -/* Updated: 2016/11/14 16:11:49 by jhalford ### ########.fr */ +/* Updated: 2017/03/08 00:35:44 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/btree/btree_map.c b/libft/src/btree/btree_map.c index 04d16491..ce828b31 100644 --- a/libft/src/btree/btree_map.c +++ b/libft/src/btree/btree_map.c @@ -6,8 +6,7 @@ t_btree *btree_map(t_btree *root, void *(*f)(void *)) if (!root) return (NULL); - new = btree_create_node(root->item, root->content_size); - new->item = (*f)(new->item); + new = btree_create_node((*f)(root->item), root->content_size); new->left = btree_map(root->left, f); new->right = btree_map(root->right, f); return (new); diff --git a/libft/src/lst/ft_id.c b/libft/src/lst/ft_id.c index 367202d8..d5bac3fb 100644 --- a/libft/src/lst/ft_id.c +++ b/libft/src/lst/ft_id.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/04 11:08:55 by jhalford #+# #+# */ -/* Updated: 2017/03/02 17:47:34 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 22:43:40 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/lst/ft_lst_reverse.c b/libft/src/lst/ft_lst_reverse.c index 48b14d9e..7765d598 100644 --- a/libft/src/lst/ft_lst_reverse.c +++ b/libft/src/lst/ft_lst_reverse.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* ft_list_reverse.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/08/14 13:20:13 by jhalford #+# #+# */ -/* Updated: 2016/11/04 11:09:34 by jhalford ### ########.fr */ +/* Updated: 2017/03/08 00:31:33 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/lst/ft_lstadd.c b/libft/src/lst/ft_lstadd.c index aec063b0..1d465dd1 100644 --- a/libft/src/lst/ft_lstadd.c +++ b/libft/src/lst/ft_lstadd.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:57:13 by jhalford #+# #+# */ -/* Updated: 2017/02/09 21:50:08 by jhalford ### ########.fr */ +/* Updated: 2017/03/08 00:19:43 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/lst/ft_lstdup.c b/libft/src/lst/ft_lstdup.c new file mode 100644 index 00000000..44ef5d19 --- /dev/null +++ b/libft/src/lst/ft_lstdup.c @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstdup.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ariard +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/08 00:14:44 by ariard #+# #+# */ +/* Updated: 2017/03/08 01:44:22 by ariard ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +t_list *ft_lstdup(t_list **lst, void *(*f)(void *content)) +{ + t_list *new; + t_list *tp; + void *temp; + + + new = NULL; + tp = *lst; + while (tp) + { + temp = (*f)((*lst)->content); + ft_lstadd(&new, ft_lstnew(temp, sizeof(temp))); + tp = tp->next; + } + ft_lst_reverse(&new); + return (new); +} diff --git a/libft/src/lst/ft_lstmap.c b/libft/src/lst/ft_lstmap.c index 689c64ae..e9ab0896 100644 --- a/libft/src/lst/ft_lstmap.c +++ b/libft/src/lst/ft_lstmap.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:57:21 by jhalford #+# #+# */ -/* Updated: 2017/03/02 17:48:58 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 22:45:41 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/lst/ft_lstnew.c b/libft/src/lst/ft_lstnew.c index 178ade1d..2b5a45ec 100644 --- a/libft/src/lst/ft_lstnew.c +++ b/libft/src/lst/ft_lstnew.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/29 15:57:38 by jhalford #+# #+# */ -/* Updated: 2017/02/09 21:37:14 by jhalford ### ########.fr */ +/* Updated: 2017/03/08 00:21:44 by ariard ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/libft/src/sstr/ft_sstrdup.c b/libft/src/sstr/ft_sstrdup.c index ee8c4f5a..e68e0d35 100644 --- a/libft/src/sstr/ft_sstrdup.c +++ b/libft/src/sstr/ft_sstrdup.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/07 14:25:45 by jhalford #+# #+# */ -/* Updated: 2017/01/11 17:49:34 by jhalford ### ########.fr */ +/* Updated: 2017/03/07 19:58:12 by ariard ### ########.fr */ /* */ /* ************************************************************************** */