leaks
This commit is contained in:
@@ -31,6 +31,13 @@ const char *translate_state(t_state state)
|
||||
return (out);
|
||||
}
|
||||
|
||||
static void else_case(t_dio_node *txt)
|
||||
{
|
||||
txt->cmd = ft_calloc(1, 1);
|
||||
txt->args = ft_calloc(1, 1);
|
||||
txt->files = ft_calloc(1, 1);
|
||||
}
|
||||
|
||||
t_dio_node get_cmd_txt(t_ast_n *node)
|
||||
{
|
||||
t_dio_node txt;
|
||||
@@ -39,8 +46,10 @@ t_dio_node get_cmd_txt(t_ast_n *node)
|
||||
txt.st = translate_state(node->state);
|
||||
if (node->state == _CMD)
|
||||
{
|
||||
if (node->cmd)
|
||||
txt.cmd = ft_sprintf("%s%s", NL, node->cmd);
|
||||
if (txt.cmd)
|
||||
else
|
||||
txt.cmd = ft_strdup(NL);
|
||||
txt.cmd = replace_left_red(txt.cmd);
|
||||
if (node->args && node->args[0])
|
||||
args = ft_tabstr(node->args);
|
||||
@@ -51,10 +60,6 @@ t_dio_node get_cmd_txt(t_ast_n *node)
|
||||
txt.files = ft_sprintf("redir: UNCHECKED\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
txt.cmd = ft_calloc(1, 1);
|
||||
txt.args = ft_calloc(1, 1);
|
||||
txt.files = ft_calloc(1, 1);
|
||||
}
|
||||
else_case(&txt);
|
||||
return (txt);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ char *get_node_txt(t_ast_n *node)
|
||||
else
|
||||
subsh = ft_strdup("");
|
||||
out = ft_sprintf("%s%s%s%s%s", txt.st, txt.cmd, txt.args, subsh, txt.files);
|
||||
free(txt.cmd);
|
||||
ft_free(&txt.cmd);
|
||||
free(txt.args);
|
||||
free(txt.files);
|
||||
free(subsh);
|
||||
|
||||
Reference in New Issue
Block a user