23 lines
392 B
C
23 lines
392 B
C
#include "libft.h"
|
|
|
|
t_slist *ft_list_pop(t_slist **lst)
|
|
{
|
|
t_slist *current;
|
|
t_slist *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;
|
|
}
|