aboutsummaryrefslogtreecommitdiff
path: root/src/free_token.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/free_token.c')
-rw-r--r--src/free_token.c45
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
+// }
+// }