Skip to content

Commit

Permalink
add function lstclear
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusVinix committed May 29, 2021
1 parent ac5269a commit e5e532e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ SRCS_BONUS = ft_lstnew.c \
ft_lstsize.c \
ft_lstlast.c \
ft_lstadd_back.c \
ft_lstdelone.c
ft_lstdelone.c \
ft_lstclear.c

OBJS = $(SRCS:.c=.o)

Expand Down
28 changes: 28 additions & 0 deletions ft_lstclear.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: marcus <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/05/29 11:33:00 by marcus #+# #+# */
/* Updated: 2021/05/29 11:47:47 by marcus ### ########.fr */
/* */
/* ************************************************************************** */

#include "libft.h"

void ft_lstclear(t_list **lst, void(*del)(void *))
{
t_list *tmp;

if (*lst == NULL)
return;
while (*lst)
{
tmp = *lst->next;
ft_lstdelone(*lst, del);
*lst = tmp;
}
*lst = NULL;
}
1 change: 1 addition & 0 deletions libft.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ int ft_lstsize(t_list *lst);
t_list *ft_lstlast(t_list *lst);
void ft_lstadd_back(t_list **lst, t_list *new);
void ft_lstdelone(t_list *lst, void (*del)(void *));
void ft_lstclear(t_list **lst, void (*del)(void *));
#endif
2 changes: 1 addition & 1 deletion script.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
git add .
git commit -m "add function lstdelone"
git commit -m "add function lstclear"
git push origin master

0 comments on commit e5e532e

Please sign in to comment.