feat: added lst structure
This commit is contained in:
parent
f3377656e4
commit
3287cd402f
6 changed files with 93 additions and 0 deletions
23
srcs/lst/ft_lstpop.c
Normal file
23
srcs/lst/ft_lstpop.c
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#include "libft.h"
|
||||
|
||||
t_list *ft_lstpop(t_list **lst)
|
||||
{
|
||||
t_list *current;
|
||||
t_list *prev;
|
||||
|
||||
if (!lst || !*lst)
|
||||
return NULL;
|
||||
current = *lst;
|
||||
if (current->next == NULL)
|
||||
{
|
||||
*lst = NULL;
|
||||
return current;
|
||||
}
|
||||
while (current->next)
|
||||
{
|
||||
prev = current;
|
||||
current = current->next;
|
||||
}
|
||||
prev->next = NULL;
|
||||
return current;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue