MiniDevil As beautiful as a shell
ast_utils.c File Reference

AST utilities: frees entire AST tree recursively. More...

#include "ast.h"
#include "libft.h"
+ Include dependency graph for ast_utils.c:

Detailed Description

AST utilities: frees entire AST tree recursively.

Definition in file ast_utils.c.

Functions

static void free_args (char **args)
 Free a string array and its entries. More...
 
void free_ast (t_ast *node)
 Recursively free an entire AST tree. More...
 

Function Documentation

◆ free_args()

static void free_args ( char **  args)
static

Free a string array and its entries.

Parameters
argsArray to free

Definition at line 21 of file ast_utils.c.

Referenced by free_ast().

+ Here is the caller graph for this function:

◆ free_ast()

void free_ast ( t_ast node)

Recursively free an entire AST tree.

  • NODE_COMMAND: frees the args array
  • NODE_PIPE: recurses into left and right children
  • NODE_REDIR: closes heredoc_fd if >= 0, frees the filename and recurses into the command subtree
Parameters
nodeRoot of tree to free

Definition at line 46 of file ast_utils.c.

References t_cmd_node::args, t_ast_data::binary, t_redir_node::cmd, t_ast_data::cmd, t_ast::data, t_redir_node::file, free_args(), t_redir_node::heredoc_fd, t_binary_node::left, NODE_COMMAND, NODE_PIPE, NODE_REDIR_HEREDOC, NODE_REDIR_IN, t_ast_data::redir, t_binary_node::right, and t_ast::type.

Referenced by child_execute(), create_pipe_node(), exec_left_pipe_child(), exec_right_pipe_child(), parse_one_redirection(), parse_pipeline(), process_input(), and process_ui_input().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Go to the source code of this file.