diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-08-20 14:25:24 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-08-20 14:25:24 +0200 |
| commit | ffaebd5ffe714799254d6c520c4ad19a0157e672 (patch) | |
| tree | d00da55c9ec8e0140b41586fcabb1bad7ab07c19 /src/lst | |
| parent | b878aa62024fdff08a9a76d80ddbeb1ee19d9179 (diff) | |
| download | libft-ffaebd5ffe714799254d6c520c4ad19a0157e672.tar.gz libft-ffaebd5ffe714799254d6c520c4ad19a0157e672.tar.bz2 libft-ffaebd5ffe714799254d6c520c4ad19a0157e672.zip | |
Added ft_lstpop_back
Diffstat (limited to 'src/lst')
| -rw-r--r-- | src/lst/ft_lstpop_back.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/lst/ft_lstpop_back.c b/src/lst/ft_lstpop_back.c new file mode 100644 index 0000000..100ffb2 --- /dev/null +++ b/src/lst/ft_lstpop_back.c @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_lstpop_back.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <me@cacharle.xyz> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/08/20 13:07:51 by charles #+# #+# */ +/* Updated: 2020/08/20 13:10:38 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft_lst.h" + +/* +** \brief Delete last node +** \param del Delete function for node data +*/ + +void ft_lstpop_back(t_ftlst **lst, void (*del)(void *)) +{ + if (lst == NULL || *lst == NULL) + return ; + if ((*lst)->next == NULL) + { + ft_lstdelone(*lst, del); + *lst = NULL; + return ; + } + ft_lstpop_back(&(*lst)->next, del); +} |
