ft_lstadd_back - gabrielcoelhodacunha-old/42sp-libft GitHub Wiki

Description

Adds the element new at the end of lst.

Implementation

void	ft_lstadd_back(t_list **lst, t_list *new)
{
	t_list	*last;

	// Checks if `lst` hast at least one element
	if (*lst)
	{
		last = ft_lstlast(*lst);
		last->next = new;
	}
	else
		*lst = new;
}

References