diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-11 17:45:49 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-09-11 17:45:49 +0200 |
commit | 6e74d376f1a888f4730b9fa39df1b34b251eb3f5 (patch) | |
tree | eb602453b996ca6c67dbe2d281b8252b1e1ed429 /src/s_lvars.c | |
parent | Better (diff) | |
download | 42-minishell-6e74d376f1a888f4730b9fa39df1b34b251eb3f5.tar.gz 42-minishell-6e74d376f1a888f4730b9fa39df1b34b251eb3f5.tar.bz2 42-minishell-6e74d376f1a888f4730b9fa39df1b34b251eb3f5.tar.xz 42-minishell-6e74d376f1a888f4730b9fa39df1b34b251eb3f5.tar.zst 42-minishell-6e74d376f1a888f4730b9fa39df1b34b251eb3f5.zip |
Aliases list in progress
Diffstat (limited to 'src/s_lvars.c')
-rw-r--r-- | src/s_lvars.c | 17 |
1 files changed, 8 insertions, 9 deletions
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 <libft.h> -#include <string.h> #include <stdlib.h> +#include <string.h> #include <errno.h> #include <unistd.h> @@ -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); } |