ft_lstdel.c 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_lstdel.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2017/12/08 14:22:40 by bchanot #+# #+# */
  9. /* Updated: 2017/12/08 14:28:35 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "libft.h"
  13. void ft_lstdel(t_slist **alst, void (*del)(void *, size_t))
  14. {
  15. t_slist *next;
  16. t_slist *tmp;
  17. if (alst != NULL)
  18. {
  19. tmp = *alst;
  20. while (tmp != NULL)
  21. {
  22. if (del != NULL)
  23. (*del)(tmp->content, (*tmp).content_size);
  24. next = tmp->next;
  25. ft_memdel((void **)&tmp);
  26. tmp = next;
  27. }
  28. *alst = NULL;
  29. }
  30. }