Fixed leaks in hashmap

This commit is contained in:
Maix0 2024-05-21 15:00:17 +02:00
parent 544ed8b045
commit f75685a6c7
12 changed files with 99 additions and 75 deletions

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/04 18:32:50 by maiboyer #+# #+# */
/* Updated: 2024/05/19 14:55:56 by maiboyer ### ########.fr */
/* Updated: 2024/05/21 14:55:11 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -47,7 +47,7 @@ static void _free_env(t_kv_env kv)
t_hashmap_env *create_env_map(void)
{
return (hmap_new_env(_hash_str, _cmp_str, _free_env));
return (hmap_env_new(_hash_str, _cmp_str, _free_env));
}
t_error _build_envp_iterator(t_usize idx, const t_str *key, t_str *val,

View file

@ -6,7 +6,7 @@
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/09 15:00:53 by rparodi #+# #+# */
/* Updated: 2024/05/19 14:56:22 by maiboyer ### ########.fr */
/* Updated: 2024/05/21 14:57:28 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -14,6 +14,7 @@
#include "app/node.h"
#include "app/state.h"
#include "gmr/symbols.h"
#include "me/mem/mem.h"
#include "me/types.h"
#include "me/vec/vec_str.h"
// #include "app/node/handle_program.h"
@ -22,6 +23,14 @@
#include "minishell.h"
#include <time.h>
void handle_command_free_infork(void *vshcat)
{
t_utils *shcat;
shcat = vshcat;
ft_exit(shcat, 255);
}
t_error handle_command(t_node *self, t_utils *shcat, t_i32 *out_exit_code)
{
t_usize i;
@ -55,11 +64,10 @@ t_error handle_command(t_node *self, t_utils *shcat, t_i32 *out_exit_code)
}
i++;
}
// vec_str_push(&spawn_info.arguments, NULL);
spawn_info.stdin = inherited();
spawn_info.stdout = inherited();
spawn_info.stderr = inherited();
spawn_info.forked_free = NULL;
spawn_info.forked_free = handle_command_free_infork;
if (build_envp(shcat->env, &spawn_info.environement))
return (vec_str_free(spawn_info.arguments), ERROR);
if (spawn_process(spawn_info, &shcat->ret))

View file

@ -40,7 +40,7 @@ void ft_free_utils(t_utils *s)
if (s->path)
ft_free_strs(s->path);
if (s->env)
hmap_free_env(s->env);
hmap_env_free(s->env);
ts_parser_delete(s->parser.parser);
}

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */
/* Updated: 2024/05/19 14:55:28 by maiboyer ### ########.fr */
/* Updated: 2024/05/21 14:53:26 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -75,7 +75,8 @@ t_error populate_env(t_hashmap_env *env, t_str envp[])
return (ERROR);
if (temp[0] == NULL || temp[1] == NULL)
return (printf("TEMP NULL\n"), ERROR);
hmap_insert_env(env, temp[0], temp[1]);
if (hmap_env_insert(env, temp[0], temp[1]))
printf("'%s' was already in the hmap ?????\n", temp[0]);
i++;
}
return (NO_ERROR);