diff options
| author | Christopher Uhlig | 2025-01-22 16:50:05 +0100 |
|---|---|---|
| committer | Christopher Uhlig | 2025-01-22 16:50:05 +0100 |
| commit | ad5eae00584c6c4a88e873b85645c10c47cd7bf8 (patch) | |
| tree | 77d00c9f815d26b05594fe75c11e364b3568e3ec /src/free_token.c | |
| parent | f6e474d27a1398c6d4f2e88c7f2d3797b85217da (diff) | |
| download | minishell-ad5eae00584c6c4a88e873b85645c10c47cd7bf8.tar.gz minishell-ad5eae00584c6c4a88e873b85645c10c47cd7bf8.zip | |
uiuiuiui
Diffstat (limited to 'src/free_token.c')
| -rw-r--r-- | src/free_token.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/src/free_token.c b/src/free_token.c index 64278a8..66ab1dd 100644 --- a/src/free_token.c +++ b/src/free_token.c @@ -6,7 +6,7 @@ /* By: chuhlig <chuhlig@student.42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/06/27 14:38:57 by dkaiser #+# #+# */ -/* Updated: 2025/01/22 00:07:58 by chuhlig ### ########.fr */ +/* Updated: 2025/01/22 15:56:38 by chuhlig ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,8 +19,11 @@ void free_token(t_token *token) token->previous->next = NULL; if (token->next != NULL) token->next->previous = NULL; - // if (token->type == STRING_TOKEN && token->content.string != NULL) - // free(token->content.string); // Ensure content is freed + // if (token->previous == NULL && token->next == NULL) + // { + // if (token->type == STRING_TOKEN && token->content.string != NULL) + // free(token->content.string); // Ensure content is freed + // } free(token);//maybe free token token = NULL; } @@ -35,23 +38,23 @@ void free_token_and_connect(t_token *token) token = NULL; } -// void free_tokens(t_token *tokens) -// { -// while (tokens->next != NULL) -// { -// tokens = tokens->next; -// free_token(tokens->previous); -// } -// free_token(tokens); -// } -void free_tokens(t_token *tokens) +void free_tokens(t_token *tokens) { - t_token *tmp; - - while (tokens) - { - tmp = tokens; - tokens = tokens->next; - free_token(tmp); // Ensure each token is freed - } + while (tokens->next != NULL) + { + tokens = tokens->next; + free_token(tokens->previous); + } + free_token(tokens); } +// void free_tokens(t_token *tokens) +// { +// t_token *tmp; + +// while (tokens) +// { +// tmp = tokens; +// tokens = tokens->next; +// free_token(tmp); // Ensure each token is freed +// } +// } |
