/* ************************************************************************** */ /* */ /* :::::::: */ /* environment_add.c :+: :+: */ /* +:+ */ /* By: whaffman +#+ */ /* +#+ */ /* Created: 2025/02/04 16:13:33 by whaffman #+# #+# */ /* Updated: 2025/02/25 14:28:43 by whaffman ######## odam.nl */ /* */ /* ************************************************************************** */ #include "minishell.h" void environment_add(t_minishell *minishell, char *name, char *value) { t_environment *new_environment; t_list *new_node; t_list **environment; environment = &minishell->environment; if (name != NULL && value != NULL) { new_environment = malloc_safe(minishell, sizeof(t_environment)); if (new_environment == NULL) return (perror("malloc")); new_environment->name = ft_strdup(name); new_environment->value = ft_strdup(value); new_node = ft_lstnew(new_environment); if (new_node == NULL || new_environment->name == NULL || new_environment->value == NULL) { environment_free(new_environment); return (perror("malloc")); } ft_lstadd_back(environment, new_node); } }