Fix: leak with env hashmap

This commit is contained in:
Maix0 2024-05-04 19:25:04 +02:00
parent f86947a852
commit b5c7344851

View file

@ -6,11 +6,13 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/29 11:35:51 by rparodi #+# #+# */ /* Created: 2024/03/29 11:35:51 by rparodi #+# #+# */
/* Updated: 2024/05/02 13:46:39 by maiboyer ### ########.fr */ /* Updated: 2024/05/04 19:24:44 by maiboyer ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "../includes/minishell.h" #include "../includes/minishell.h"
#include "app/env.h"
#include "me/hashmap/hashmap_env.h"
void ts_parser_delete(t_first_parser *self); void ts_parser_delete(t_first_parser *self);
@ -18,7 +20,6 @@ void ft_free(void *ptr)
{ {
if (!ptr) if (!ptr)
free(ptr); free(ptr);
ptr = NULL;
} }
void ft_free_strs(t_str *strs) void ft_free_strs(t_str *strs)
@ -27,10 +28,7 @@ void ft_free_strs(t_str *strs)
i = 0; i = 0;
while (strs[i]) while (strs[i])
{ ft_free(strs[i++]);
ft_free(strs[i]);
i++;
}
ft_free(strs); ft_free(strs);
} }
@ -41,6 +39,8 @@ void ft_free_utils(t_utils *s)
free(s->str_input); free(s->str_input);
if (s->path) if (s->path)
ft_free_strs(s->path); ft_free_strs(s->path);
if (s->env)
drop_hashmap_env(s->env);
ts_parser_delete(s->parser.parser); ts_parser_delete(s->parser.parser);
} }