hopefully a working allocator !

This commit is contained in:
Maix0 2024-05-10 21:40:19 +02:00
parent a149e9a860
commit b639b0c14e
8 changed files with 53 additions and 35 deletions

View file

@ -41,6 +41,8 @@ void ft_free_utils(t_utils *s)
free(s->str_input);
if (s->path)
ft_free_strs(s->path);
if (s->env)
drop_hashmap_env(s->env);
ts_parser_delete(s->parser.parser);
}

View file

@ -117,6 +117,8 @@ void ft_take_args(t_utils *shcat)
shcat->str_input = readline((t_const_str)shcat->name_shell);
if (!shcat->str_input)
ft_exit(shcat, 0);
else if (ft_strcmp(shcat->str_input, "exit") == 0)
ft_exit(shcat, 0);
shcat->current_node = parse_str(&shcat->parser, shcat->str_input);
exec_shcat(shcat);
add_history(shcat->str_input);
@ -170,8 +172,8 @@ t_i32 main(t_i32 argc, t_str argv[], t_str envp[])
if (install_signal())
return (1);
utils = (t_utils){};
utils.env = create_env_map();
utils.parser = create_myparser();
utils.env = create_env_map();
utils.name_shell = "\001\x1B[93m\002"
"42sh"
"\001\x1B[32m\002"

View file

@ -81,15 +81,15 @@ t_str node_getstr(t_node *node)
return (node->single_str);
}
void free_node(t_node t)
void free_node(t_node self)
{
// t_usize idx;
//
// idx = 0;
// while (idx < t.childs_count)
// free_node(t.childs[idx++]);
// free(t.childs);
// if (t.single_str != NULL)
// free(t.single_str);
(void)(t);
t_usize idx;
if (self.single_str)
me_free(self.single_str);
idx = 0;
while (idx < self.childs_count)
free_node(self.childs[idx++]);
if (self.childs_count != 0)
me_free(self.childs);
}