minishell/libft/srcs/ft_envupdate.c
2020-02-07 15:57:21 +01:00

29 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_envupdate.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/05 19:10:38 by tmaze #+# #+# */
/* Updated: 2020/02/07 15:26:10 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_envupdate(char *key, t_env *env, char *val)
{
t_env *elem;
char *new;
new = NULL;
if ((elem = ft_envgetelem(key, env)) != NULL)
if ((new = ft_strdup(val)) != NULL)
{
ft_strdel(&elem->val);
elem->val = new;
}
return (new);
}