diff options
Diffstat (limited to 'src/lst')
| -rw-r--r-- | src/lst/ft_lstdestroy.c | 10 | ||||
| -rw-r--r-- | src/lst/ft_lstpush_front_node.c | 23 |
2 files changed, 29 insertions, 4 deletions
diff --git a/src/lst/ft_lstdestroy.c b/src/lst/ft_lstdestroy.c index 35da2a5..2af6fb7 100644 --- a/src/lst/ft_lstdestroy.c +++ b/src/lst/ft_lstdestroy.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/09 09:02:39 by cacharle #+# #+# */ -/* Updated: 2019/11/20 04:02:37 by cacharle ### ########.fr */ +/* Updated: 2020/08/20 14:36:17 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,15 +15,17 @@ /* ** \brief Destroy a list and set his pointer to NULL ** \param del Delete Function for data of each node +** \return returns NULL */ -void ft_lstdestroy(t_ftlst **lst, void (*del)(void *)) +void *ft_lstdestroy(t_ftlst **lst, void (*del)(void *)) { if (lst == NULL) - return ; + return (NULL); if (*lst == NULL) - return ; + return (NULL); ft_lstdestroy(&((*lst)->next), del); ft_lstdelone(*lst, del); *lst = NULL; + return (NULL); } diff --git a/src/lst/ft_lstpush_front_node.c b/src/lst/ft_lstpush_front_node.c new file mode 100644 index 0000000..f6ff694 --- /dev/null +++ b/src/lst/ft_lstpush_front_node.c @@ -0,0 +1,23 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstpush_front_node.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <me@cacharle.xyz> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/08/20 14:38:18 by charles #+# #+# */ +/* Updated: 2020/08/20 14:41:14 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft_lst.h" + +t_ftlst *ft_lstpush_front_node(t_ftlst **lst, void *data) +{ + t_ftlst *pushed; + + if (data == NULL || (pushed = ft_lstnew(data)) == NULL) + return (NULL); + ft_lstpush_front(lst, pushed); + return (*lst); +} |
