From 6e74d376f1a888f4730b9fa39df1b34b251eb3f5 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 11 Sep 2020 17:45:49 +0200 Subject: Aliases list in progress --- src/s_lvars.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/s_lvars.c') diff --git a/src/s_lvars.c b/src/s_lvars.c index 3eb4943..e4b054e 100644 --- a/src/s_lvars.c +++ b/src/s_lvars.c @@ -11,8 +11,8 @@ /* ************************************************************************** */ #include -#include #include +#include #include #include @@ -24,7 +24,7 @@ void 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; } @@ -33,10 +33,9 @@ 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); } } @@ -71,7 +70,7 @@ void void lvars_add_front(t_lvars **alvars, t_lvars *new) { - if (!alvars || !new) + if (alvars == NULL || new == NULL) { return ; } @@ -88,7 +87,7 @@ void if (lvars == NULL) return ; tmp = *lvars; - while (tmp) + while (tmp != NULL) { renext = tmp->next; ft_memdel((void*)&tmp->name); @@ -104,15 +103,15 @@ t_lvars { 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); } -- cgit v1.2.3