/ libft / src / ft_lst / lst_len.c
lst_len.c
 1  /* ************************************************************************** */
 2  /*                                                                            */
 3  /*                                                        :::      ::::::::   */
 4  /*   lst_len.c                                         :+:      :+:    :+:   */
 5  /*                                                    +:+ +:+         +:+     */
 6  /*   By: ll-hotel <ll-hotel@student.42lyon.fr>      +#+  +:+       +#+        */
 7  /*                                                +#+#+#+#+#+   +#+           */
 8  /*   Created: 2024/04/17 22:54:41 by ll-hotel          #+#    #+#             */
 9  /*   Updated: 2024/05/21 14:28:51 by ll-hotel         ###   ########.fr       */
10  /*                                                                            */
11  /* ************************************************************************** */
12  
13  #include "ft_lst.h"
14  
15  long	lst_len(t_lst_head *lst)
16  {
17  	long	len;
18  
19  	len = 0;
20  	if (lst)
21  		lst = (t_lst_head *)lst->first;
22  	while (lst)
23  	{
24  		len += 1;
25  		lst = (t_lst_head *)lst->first;
26  	}
27  	return (len);
28  }