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.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/free_token.c b/src/free_token.c
index 9f5c4e9..9b035ac 100644
--- a/src/free_token.c
+++ b/src/free_token.c
@@ -6,7 +6,7 @@
/* By: dkaiser <dkaiser@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/27 14:38:57 by dkaiser #+# #+# */
-/* Updated: 2024/06/28 14:55:12 by dkaiser ### ########.fr */
+/* Updated: 2024/08/02 14:23:56 by dkaiser ### ########.fr */
/* */
/* ************************************************************************** */
@@ -14,11 +14,28 @@
void free_token(t_token *token)
{
- if (token->type == STRING_TOKEN)
- free(token->content.string);
if (token->previous != NULL)
token->previous->next = NULL;
if (token->next != NULL)
token->next->previous = NULL;
free(token);
}
+
+void free_token_and_connect(t_token *token)
+{
+ if (token->previous != NULL)
+ token->previous->next = token->next;
+ if (token->next != NULL)
+ token->next->previous = token->previous;
+ free(token);
+}
+
+void free_tokens(t_token *tokens)
+{
+ while (tokens->next != NULL)
+ {
+ tokens = tokens->next;
+ free_token(tokens->previous);
+ }
+ free_token(tokens);
+}