From: Dominik Kaiser Date: Mon, 8 Jul 2024 14:03:48 +0000 (+0200) Subject: Add free_token_and_connect() function X-Git-Url: https://git.dkaiser.de/?a=commitdiff_plain;h=bc5e39df2154abfdf308b6cbe644b8953586be2d;p=42%2Fminishell.git Add free_token_and_connect() function --- diff --git a/include/token.h b/include/token.h index 38e758f..32b042d 100644 --- a/include/token.h +++ b/include/token.h @@ -6,7 +6,7 @@ /* By: dkaiser next->previous = NULL; free(token); } + +void free_token_and_connect(t_token *token) +{ + if (token->type == STRING_TOKEN) + free(token->content.string); + if (token->previous != NULL) + token->previous->next = token->next; + if (token->next != NULL) + token->next->previous = token->previous; + free(token); +}