summaryrefslogtreecommitdiffstats
path: root/libft/src/get_next_line.c
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-09-29 19:54:12 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-09-29 19:54:12 +0200
commit5ef27d97f1dc36b4e9dd2420ba25166e370913d1 (patch)
tree05fe79b148c750a30c3f0149e933cb3ebc211738 /libft/src/get_next_line.c
parentUpdate (diff)
download42-minishell-5ef27d97f1dc36b4e9dd2420ba25166e370913d1.tar.gz
42-minishell-5ef27d97f1dc36b4e9dd2420ba25166e370913d1.tar.bz2
42-minishell-5ef27d97f1dc36b4e9dd2420ba25166e370913d1.tar.xz
42-minishell-5ef27d97f1dc36b4e9dd2420ba25166e370913d1.tar.zst
42-minishell-5ef27d97f1dc36b4e9dd2420ba25166e370913d1.zip
End
Diffstat (limited to 'libft/src/get_next_line.c')
-rw-r--r--libft/src/get_next_line.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/libft/src/get_next_line.c b/libft/src/get_next_line.c
index 2b2ba80..032ad95 100644
--- a/libft/src/get_next_line.c
+++ b/libft/src/get_next_line.c
@@ -16,8 +16,7 @@
#include <stdint.h>
#include <unistd.h>
-static char
- *ft_strjoin_gnl(char *s1, char *s2)
+static char *ft_strjoin_gnl(char *s1, char *s2)
{
size_t i;
size_t j;
@@ -40,14 +39,13 @@ static char
return (dst);
}
-static int
- ft_read_gnl(int fd, char **line, t_gnl *curr)
+static int ft_read_gnl(int fd, char **line, t_gnl *curr)
{
char *buf;
char *end;
int64_t size;
- if (!(buf = malloc(BUFFER_SIZE + 1)))
+ if ((buf = malloc(BUFFER_SIZE + 1)) == NULL)
return (-1);
*buf = 0;
*line = ft_strjoin_gnl(*line, curr->rest);
@@ -70,8 +68,7 @@ static int
return (size);
}
-int
- get_next_line(int fd, char **line)
+int get_next_line(int fd, char **line)
{
static t_gnl *list;
t_gnl *curr;
@@ -80,7 +77,7 @@ int
if (fd < 0 || BUFFER_SIZE <= 0)
return (-1);
- if (!(*line = (char *)malloc(1 * sizeof(char))))
+ if ((*line = (char *)malloc(1 * sizeof(char))) == NULL)
return (-1);
**line = 0;
curr = ft_find_fd(fd, &list);