Skip to content

Commit

Permalink
feat: Add ft_lstsize_d() to libft
Browse files Browse the repository at this point in the history
  • Loading branch information
itislu committed Jul 3, 2024
1 parent 06d2497 commit 93bb7ce
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions libraries/libft/build/libft.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion libraries/libft/inc/libft.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: ldulling <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -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 */
Expand Down
28 changes: 28 additions & 0 deletions libraries/libft/src/lists/doubly_linked/ft_lstsize_d.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstsize_d.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ldulling <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

0 comments on commit 93bb7ce

Please sign in to comment.