diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-11-03 00:19:45 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-11-03 00:19:45 +0100 |
| commit | 0a966722ec0236521d99706632a7fe56b7245379 (patch) | |
| tree | 461cbc387c4691363873bbf5a43c487be82019ea /get_next_line.h | |
| parent | 9f8c7ca113f0c69d17d8044120fcbd0ba78e1f92 (diff) | |
| download | get_next_line-0a966722ec0236521d99706632a7fe56b7245379.tar.gz get_next_line-0a966722ec0236521d99706632a7fe56b7245379.tar.bz2 get_next_line-0a966722ec0236521d99706632a7fe56b7245379.zip | |
Rewrite to handle massive BUFFER_SIZE
The rest is malloc'd (memory leaks if user doesnt read entier file)
The tmp buf in also malloc'd because the stack hasnt enought memory
Diffstat (limited to 'get_next_line.h')
| -rw-r--r-- | get_next_line.h | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/get_next_line.h b/get_next_line.h index 151de60..0924d0c 100644 --- a/get_next_line.h +++ b/get_next_line.h @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/09 13:52:59 by cacharle #+# #+# */ -/* Updated: 2019/10/27 21:50:05 by cacharle ### ########.fr */ +/* Updated: 2019/11/03 00:10:24 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,33 +19,34 @@ # define BUFFER_SIZE 32 # endif -# define LINE_READ 1 -# define GNL_EOF 0 -# define ERROR -1 +# define STATUS_LINE 1 +# define STATUS_EOF 0 +# define STATUS_ERROR -1 # define TRUE 1 # define FALSE 0 +# define FT_STRNCPY_BUF(dest, src) (ft_strncpy(dest, src, BUFFER_SIZE + 1)) + typedef int t_bool; /* ** get_next_line.c */ -int real_get_next_line(int fd, char **line, int ret, int counter); int get_next_line(int fd, char **line); -int put_rest(char **line, char *rest); +int read_line(int fd, char **line, char **rest); int find_newline(char *str); -int clean_line(char **line, int ret); +int free_return(char **ptr, int ret); /* ** get_next_line_utils.c - helper functions */ +char *ft_strappend(char *dest, char *src); char *ft_strncpy(char *dest, const char *src, int n); int ft_strlen(char *str); -char *ft_strcat(char *dest, const char *src); char *ft_strcpy(char *dest, const char *src); -char *ft_strappend(char *dest, char *src); +char *ft_strdup(const char *s); #endif |
