minishell/src/enviroment/add_enviroment.c
2025-02-04 15:57:26 +01:00

25 lines
510 B
C

#include "enviroment.h"
#include "libft.h"
#include <stdlib.h>
#include <stdio.h>
void add_enviroment(t_enviroment **enviroment, char *name, char *value)
{
t_enviroment *new_enviroment;
if (name != NULL && value != NULL)
{
new_enviroment = malloc(sizeof(t_enviroment));
if (new_enviroment == NULL)
{
perror("malloc");
return ;
}
new_enviroment->name = ft_strdup(name);
new_enviroment->value = ft_strdup(value);
new_enviroment->next = *enviroment;
*enviroment = new_enviroment;
}
}