summaryrefslogtreecommitdiffstats
path: root/src/s_lvars.c
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-10-26 13:42:56 +0100
committersalad <fmoenne-@student.le-101.fr>2020-10-26 13:42:56 +0100
commit0277ddfac754ab4ad5bdd2b692e31a717efbe569 (patch)
tree49d7c5fd3a12248af85e2c3a3254bc1538ae5775 /src/s_lvars.c
parentreqdy for MERGE (diff)
parentTODO update (diff)
download42-minishell-0277ddfac754ab4ad5bdd2b692e31a717efbe569.tar.gz
42-minishell-0277ddfac754ab4ad5bdd2b692e31a717efbe569.tar.bz2
42-minishell-0277ddfac754ab4ad5bdd2b692e31a717efbe569.tar.xz
42-minishell-0277ddfac754ab4ad5bdd2b692e31a717efbe569.tar.zst
42-minishell-0277ddfac754ab4ad5bdd2b692e31a717efbe569.zip
merge wif master
Diffstat (limited to 'src/s_lvars.c')
-rw-r--r--src/s_lvars.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/s_lvars.c b/src/s_lvars.c
index 9369f84..e4b054e 100644
--- a/src/s_lvars.c
+++ b/src/s_lvars.c
@@ -11,22 +11,20 @@
/* ************************************************************************** */
#include <libft.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include <errno.h>
#include <unistd.h>
#include "s_struct.h"
void
- lvars_rebind(t_lvars **lvars,
- const char name[],
- const char newval[])
+ lvars_rebind(t_lvars **lvars, const char name[], const char newval[])
{
t_lvars *tmp;
tmp = *lvars;
- while (tmp && ft_strncmp(tmp->name, name, ft_strlen(name) + 1))
+ while (tmp != NULL && ft_strncmp(tmp->name, name, ft_strlen(name) + 1) != 0)
{
tmp = tmp->next;
}
@@ -35,16 +33,14 @@ void
return ;
}
ft_memdel((void*)&tmp->val);
- if (!(tmp->val = ft_strdup(newval)))
+ if ((tmp->val = ft_strdup(newval)) == NULL)
{
ft_dprintf(STDERR_FILENO, "%s\n", strerror(errno));
- exit(FT_RET_ALLOC);
}
}
void
- lvars_delone(t_lvars **lvars,
- const char name[])
+ lvars_delone(t_lvars **lvars, const char name[])
{
t_lvars *tmp;
t_lvars *prev;
@@ -72,10 +68,9 @@ void
}
void
- lvars_add_front(t_lvars **alvars,
- t_lvars *new)
+ lvars_add_front(t_lvars **alvars, t_lvars *new)
{
- if (!alvars || !new)
+ if (alvars == NULL || new == NULL)
{
return ;
}
@@ -89,10 +84,10 @@ void
t_lvars *tmp;
t_lvars *renext;
- if (!lvars)
+ if (lvars == NULL)
return ;
tmp = *lvars;
- while (tmp)
+ while (tmp != NULL)
{
renext = tmp->next;
ft_memdel((void*)&tmp->name);
@@ -104,20 +99,19 @@ void
}
t_lvars
- *lvars_new(const char name[],
- const char val[])
+ *lvars_new(const char name[], const char val[])
{
t_lvars *link;
- if (!(link = (t_lvars*)malloc(sizeof(t_lvars))))
+ if ((link = (t_lvars*)malloc(sizeof(t_lvars))) == NULL)
{
return (NULL);
}
- if (!(link->name = ft_strdup(name)))
+ if ((link->name = ft_strdup(name)) == NULL)
{
return (NULL);
}
- if (!(link->val = ft_strdup(val)))
+ if ((link->val = ft_strdup(val)) == NULL)
{
return (NULL);
}