diff --git a/libraries/libft/build/libft.mk b/libraries/libft/build/libft.mk index 1a554cc2..654e7673 100644 --- a/libraries/libft/build/libft.mk +++ b/libraries/libft/build/libft.mk @@ -78,6 +78,7 @@ SRC += $(addprefix $(DIR), \ ft_lstlast_d.c \ ft_lstnew_back_d.c \ ft_lstnew_d.c \ + ft_lstsize_d.c \ ) # Singly-linked: diff --git a/libraries/libft/inc/libft.h b/libraries/libft/inc/libft.h index 1bf17c37..985d0407 100644 --- a/libraries/libft/inc/libft.h +++ b/libraries/libft/inc/libft.h @@ -6,7 +6,7 @@ /* By: ldulling +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/09/24 16:17:46 by ldulling #+# #+# */ -/* Updated: 2024/06/07 18:59:14 by ldulling ### ########.fr */ +/* Updated: 2024/06/28 19:31:02 by ldulling ### ########.fr */ /* */ /* ************************************************************************** */ @@ -60,6 +60,7 @@ void ft_lstiter_d(t_list_d *lst, void (*f)(void *)); t_list_d *ft_lstlast_d(t_list_d *lst); bool ft_lstnew_back_d(t_list_d **lst, void *content); t_list_d *ft_lstnew_d(void *content); +int ft_lstsize_d(t_list_d *lst); \ /* Lists singly-linked */ diff --git a/libraries/libft/src/lists/doubly_linked/ft_lstsize_d.c b/libraries/libft/src/lists/doubly_linked/ft_lstsize_d.c new file mode 100644 index 00000000..0f1b81a4 --- /dev/null +++ b/libraries/libft/src/lists/doubly_linked/ft_lstsize_d.c @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstsize_d.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: ldulling +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/09/24 16:08:06 by ldulling #+# #+# */ +/* Updated: 2024/06/28 19:30:32 by ldulling ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" + +int ft_lstsize_d(t_list_d *lst) +{ + int n; + t_list_d *cur; + + n = 0; + cur = lst; + while (cur != NULL) + { + n++; + cur = cur->next; + } + return (n); +}