/* ************************************************************************** */ /* */ /* :::::::: */ /* check_malloc.c :+: :+: */ /* +:+ */ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/02/20 18:00:10 by whaffman #+# #+# */ /* Updated: 2025/02/20 18:01:08 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ #include "minishell.h" void check_malloc(t_minishell *msh, void *ptr) { t_list *new; if (ptr == NULL) { error_msg("malloc", "can't allocate memory"); ft_lstclear(&(msh->freelist), free); exit(1); } else { new = ft_lstnew(ptr); if (new == NULL) { error_msg("malloc", "can't allocate memory"); ft_lstclear(&(msh->freelist), free); exit(1); } else ft_lstadd_front(&(msh->freelist), new); } }