minishell/sources/ft_exit.c
Maix0 cc8567f434
Restore to a stage where it works and is easier to manage (#5)
Everything in the parser that needs to be normed is in a single .c + .h file
(also there is the scanner.c file)
2024-05-01 17:35:42 +02:00

53 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_exit.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/29 11:35:51 by rparodi #+# #+# */
/* Updated: 2024/04/30 22:03:14 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "../includes/minishell.h"
void ts_parser_delete(TSParser *self);
void ft_free(void *ptr)
{
if (!ptr)
free(ptr);
ptr = NULL;
}
void ft_free_strs(t_str *strs)
{
t_usize i;
i = 0;
while (strs[i])
{
ft_free(strs[i]);
i++;
}
ft_free(strs);
}
void ft_free_utils(t_utils *s)
{
(void)(s);
if (s->str_input)
free(s->str_input);
if (s->path)
ft_free_strs(s->path);
ts_parser_delete(s->parser.parser);
}
void ft_exit(t_utils *maiboyerlpb, t_u8 exit_status)
{
if (maiboyerlpb != NULL)
ft_free_utils(maiboyerlpb);
printf("exit\n");
exit(exit_status);
}