moved env functions to libft
This commit is contained in:
28
libft/srcs/ft_envupdate.c
Normal file
28
libft/srcs/ft_envupdate.c
Normal file
@@ -0,0 +1,28 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_envupdate.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/12/05 19:10:38 by tmaze #+# #+# */
|
||||
/* Updated: 2019/12/05 19:10:52 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);
|
||||
}
|
Reference in New Issue
Block a user