diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-10-24 11:03:09 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-10-24 11:03:09 +0200 |
| commit | d9b69c88cc2105351e230dd7da6ff77045318b00 (patch) | |
| tree | fb1e3008df2ddcc1e7995073df0aac61798d698a /get_next_line.c | |
| parent | 9d66e3d084f575187b334d171a8bed40c476aa08 (diff) | |
| download | get_next_line-d9b69c88cc2105351e230dd7da6ff77045318b00.tar.gz get_next_line-d9b69c88cc2105351e230dd7da6ff77045318b00.tar.bz2 get_next_line-d9b69c88cc2105351e230dd7da6ff77045318b00.zip | |
normed and protect against BUFFER_SIZE < 0
Diffstat (limited to 'get_next_line.c')
| -rw-r--r-- | get_next_line.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/get_next_line.c b/get_next_line.c index d5c4293..879dd0a 100644 --- a/get_next_line.c +++ b/get_next_line.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/19 09:08:36 by cacharle #+# #+# */ -/* Updated: 2019/10/20 09:04:18 by cacharle ### ########.fr */ +/* Updated: 2019/10/24 10:55:30 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -33,15 +33,13 @@ ** return END_OF_FILE */ -int get_next_line(int fd, char **line) +int real_get_next_line(int fd, char **line, int ret, int split_at) { t_bool had_rest; - int ret; - int split_at; char buf[BUFFER_SIZE + 1]; static char rest[OPEN_MAX][BUFFER_SIZE + 1] = {{0}}; - if (fd < 0 || fd > OPEN_MAX || line == NULL) + if (fd < 0 || fd > OPEN_MAX || line == NULL || BUFFER_SIZE < 0) return (ERROR); if ((had_rest = put_rest(line, rest[fd])) == -1) return (LINE_READ); @@ -63,6 +61,16 @@ int get_next_line(int fd, char **line) return (ret == -1 ? ERROR : END_OF_FILE); } +int get_next_line(int fd, char **line) +{ + int ret; + int split_at; + + split_at = -1; + ret = 0; + return (real_get_next_line(fd, line, ret, split_at)); +} + int put_rest(char **line, char *rest) { int split_at; |
