From 4bc6c1ab202b1bd696e4720ae2af4298d32162a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kha=C3=AFs=20COLIN?= Date: Tue, 4 Mar 2025 13:20:50 +0100 Subject: [PATCH] fix(wordlist copy): copy did not work, like at all --- src/parser/wordlist/wordlist_copy.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/parser/wordlist/wordlist_copy.c b/src/parser/wordlist/wordlist_copy.c index f8dcc2e..6ce74a4 100644 --- a/src/parser/wordlist/wordlist_copy.c +++ b/src/parser/wordlist/wordlist_copy.c @@ -6,7 +6,7 @@ /* By: khais +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/04 12:07:53 by khais #+# #+# */ -/* Updated: 2025/03/04 12:15:38 by khais ### ########.fr */ +/* Updated: 2025/03/04 13:31:08 by khais ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,14 +20,22 @@ t_wordlist *wordlist_copy(const t_wordlist *wordlist) { t_wordlist *outlist; + t_wordlist *current; if (wordlist == NULL) return (NULL); outlist = ft_calloc(1, sizeof(t_wordlist)); outlist->word = worddesc_copy(wordlist->word); + current = outlist; while (wordlist != NULL) { + if (wordlist->next != NULL) + current->next = ft_calloc(1, sizeof(t_wordlist)); wordlist = wordlist->next; + current = current->next; + if (wordlist == NULL) + break ; + current->word = worddesc_copy(wordlist->word); } return (outlist); }