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