diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-01 21:25:09 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-08-01 21:25:09 +0200 |
commit | 8680737a802539f3c21a295ad45eb9be72c73f5f (patch) | |
tree | 337018ce1574f425847d5f1c089694f3e0996b1c /src/f_alloc.c | |
parent | Makefile update (diff) | |
download | 42-minishell-8680737a802539f3c21a295ad45eb9be72c73f5f.tar.gz 42-minishell-8680737a802539f3c21a295ad45eb9be72c73f5f.tar.bz2 42-minishell-8680737a802539f3c21a295ad45eb9be72c73f5f.tar.xz 42-minishell-8680737a802539f3c21a295ad45eb9be72c73f5f.tar.zst 42-minishell-8680737a802539f3c21a295ad45eb9be72c73f5f.zip |
More UNIX friendly libft
Diffstat (limited to '')
-rw-r--r-- | src/f_alloc.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/f_alloc.c b/src/f_alloc.c new file mode 100644 index 0000000..bfa75c3 --- /dev/null +++ b/src/f_alloc.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* f_alloc.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ +/* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include <libft.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> + +#include "s_destroy.h" +#include "s_lcom.h" +#include "s_struct.h" + +void + f_fail_alloc(t_msh *msh) +{ + ft_dprintf(STDERR_FILENO, "%s: %s\n", msh->shname, strerror(errno)); + exit(FT_RET_ALLOC); +} + +void + f_fail_alloc_and_destroy(t_msh *msh) +{ + lcom_clear(&msh->curr); + s_destroy(msh); + f_fail_alloc(msh); +} |