minishell
Minishell Project for École 42
Loading...
Searching...
No Matches
free_heap.c File Reference

Functions for freeing allocated memory in the minishell. More...

#include "minishell.h"
Include dependency graph for free_heap.c:

Functions

char ** free_str_arr (char **arr)
 Frees the allocated memory of a string array.
 
void free_environ (t_environ_list *environ)
 Frees the memory used by the environment list and its nodes.
 
t_lexer_listfree_lex (t_lexer_list *lex_head)
 Frees the allocated memory of a linked list of lexer elements.
 
t_executorfree_executor_list (t_executor *list)
 Frees the allocated memory of a linked list of t_executor elements.
 
void free_heap (t_shell *shell)
 Frees the memory used by the main data structure (shell environment).
 

Detailed Description

Functions for freeing allocated memory in the minishell.

Function Documentation

◆ free_environ()

void free_environ ( t_environ_list environ)

Frees the memory used by the environment list and its nodes.

Releases the memory allocated for the environment list and its associated nodes, freeing the memory used by keys and values as well.

Parameters
[in,out]environA pointer the the environment list to be freed.

◆ free_executor_list()

t_executor * free_executor_list ( t_executor list)

Frees the allocated memory of a linked list of t_executor elements.

Frees the memory of each node in the linked list, also frees the allocated members path and execs of each node. The entire linked list is freed. Its pointer is set to NULL.

Parameters
listA pointer to the head of the t_executor linked list.
Returns
Always NULL.

◆ free_heap()

void free_heap ( t_shell shell)

Frees the memory used by the main data structure (shell environment).

Releases the memory allocated for the main data structure and it's components, including the environment list, readline input, etc.

Parameters
[in,out]shellA pointer to the shell structure to be freed.

◆ free_lex()

t_lexer_list * free_lex ( t_lexer_list lex_head)

Frees the allocated memory of a linked list of lexer elements.

Frees the memory of each node in the linked list, starting from the "lex_head" node. Also frees the allocated 'str' member of each node. The entire linked list is then freed and 'lex_head' is set to NULL.

Parameters
lex_headA pointer to the head of the lexer list.
Returns
Always NULL.

◆ free_str_arr()

char ** free_str_arr ( char **  arr)

Frees the allocated memory of a string array.

Frees the memory of a string array by each string in the array.

Parameters
arrThe pointer the the array of strings.
Returns
Always NULL.