mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
fix(wordlist copy): copy did not work, like at all
This commit is contained in:
parent
5cd755b73c
commit
4bc6c1ab20
1 changed files with 9 additions and 1 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: khais <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue