43 lines
1.5 KiB
C
43 lines
1.5 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* :::::::: */
|
|
/* environment_del.c :+: :+: */
|
|
/* +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ */
|
|
/* +#+ */
|
|
/* Created: 2025/02/11 14:17:53 by whaffman #+# #+# */
|
|
/* Updated: 2025/02/26 16:09:12 by whaffman ######## odam.nl */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "minishell.h"
|
|
|
|
void environment_del(t_minishell *msh, char *name)
|
|
{
|
|
t_list *prev;
|
|
t_list *current;
|
|
t_list *next;
|
|
t_environment *env;
|
|
|
|
prev = NULL;
|
|
next = NULL;
|
|
current = msh->environment;
|
|
while (current != NULL)
|
|
{
|
|
env = (t_environment *)current->content;
|
|
if (ft_strncmp(env->name, name, ft_strlen(name) + 1) == 0)
|
|
{
|
|
next = current->next;
|
|
environment_free(msh, current->content);
|
|
free_safe(msh, (void **)&(current));
|
|
if (prev == NULL)
|
|
msh->environment = next;
|
|
else
|
|
prev->next = next;
|
|
return ;
|
|
}
|
|
prev = current;
|
|
current = current->next;
|
|
}
|
|
}
|