Fixed a leak using hmap_<name>_remove
This commit is contained in:
parent
6a504cab3e
commit
132d7d8bc7
3 changed files with 10 additions and 6 deletions
|
|
@ -6,11 +6,12 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
/* Created: 2024/08/10 18:43:18 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/08/11 11:26:16 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/12 17:11:12 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "exec/builtins.h"
|
#include "exec/builtins.h"
|
||||||
|
#include "me/hashmap/hashmap_env.h"
|
||||||
#include "me/printf/printf.h"
|
#include "me/printf/printf.h"
|
||||||
#include "me/str/str.h"
|
#include "me/str/str.h"
|
||||||
#include "me/string/string.h"
|
#include "me/string/string.h"
|
||||||
|
|
@ -18,5 +19,10 @@
|
||||||
|
|
||||||
t_error builtin_unset_(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code)
|
t_error builtin_unset_(t_state *state, t_builtin_spawn_info info, t_i32 *exit_code)
|
||||||
{
|
{
|
||||||
return (*exit_code = 0, ERROR);
|
t_usize i;
|
||||||
|
|
||||||
|
i = 1;
|
||||||
|
while (i < info.args.len)
|
||||||
|
hmap_env_remove(state->env, &info.args.buffer[i++]);
|
||||||
|
return (*exit_code = 0, NO_ERROR);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
5
output/src/hashmap/env/env_utils.c
vendored
5
output/src/hashmap/env/env_utils.c
vendored
|
|
@ -1,12 +1,12 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* hashmap_env_utils.c :+: :+: :+: */
|
/* env_utils.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/12/06 10:58:20 by maiboyer #+# #+# */
|
/* Created: 2023/12/06 10:58:20 by maiboyer #+# #+# */
|
||||||
/* Updated: 2023/12/11 15:35:37 by maiboyer ### ########.fr */
|
/* Updated: 2024/08/12 17:14:03 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -39,7 +39,6 @@ void hmap_env_remove(t_hashmap_env *hmap, t_str *key)
|
||||||
|
|
||||||
hmap->hfunc(&hmap->hasher, key);
|
hmap->hfunc(&hmap->hasher, key);
|
||||||
hashed_key = hasher_reset_and_finish(&hmap->hasher);
|
hashed_key = hasher_reset_and_finish(&hmap->hasher);
|
||||||
hmap->hasher = hasher_sip13_new();
|
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
entry = hmap_env_get_entry(hmap, hashed_key, key, &prev);
|
entry = hmap_env_get_entry(hmap, hashed_key, key, &prev);
|
||||||
if (entry == NULL)
|
if (entry == NULL)
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ void hmap_C__PREFIX___remove(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ *key)
|
||||||
|
|
||||||
hmap->hfunc(&hmap->hasher, key);
|
hmap->hfunc(&hmap->hasher, key);
|
||||||
hashed_key = hasher_reset_and_finish(&hmap->hasher);
|
hashed_key = hasher_reset_and_finish(&hmap->hasher);
|
||||||
hmap->hasher = hasher_sip13_new();
|
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
entry = hmap_C__PREFIX___get_entry(hmap, hashed_key, key, &prev);
|
entry = hmap_C__PREFIX___get_entry(hmap, hashed_key, key, &prev);
|
||||||
if (entry == NULL)
|
if (entry == NULL)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue