diff options
Diffstat (limited to 'get_next_line.c')
| -rw-r--r-- | get_next_line.c | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/get_next_line.c b/get_next_line.c index a5c2288..39305f5 100644 --- a/get_next_line.c +++ b/get_next_line.c @@ -5,43 +5,49 @@ static unsigned int cursor; -static void *ft_memcat(void *ptr, void *tail, - unsigned int size, unsigned int tail_size); +/* static void *ft_memcat(void *ptr, void *tail, */ +/* unsigned int size, unsigned int tail_size); */ int get_next_line(const int fd, char **line) { - unsigned int newline_i; - char buf[BUFF_SIZE]; - - if (read(fd, buf, BUFF_SIZE) < 0) - return (-1); - if ((*line = ft_strnew(0)) == NULL) - return (-1); - newline_i = 0; - while (buf[newline_i]) - { - while (buf[newline_i] != '\n') - newline_i++; - ft_memcat(*line, buf, 0, newline_i); - if (read(fd, buf, BUFF_SIZE) < 0) - return (-1); - } + /* unsigned int newline_i; */ + /* char buf[BUFF_SIZE]; */ + /* */ + /* if (read(fd, buf, BUFF_SIZE) < 0) */ + /* return (-1); */ + /* if ((*line = ft_strnew(0)) == NULL) */ + /* return (-1); */ + /* newline_i = 0; */ + /* while (buf[newline_i]) */ + /* { */ + /* while (buf[newline_i] != '\n') */ + /* newline_i++; */ + /* ft_memcat(*line, buf, 0, newline_i); */ + /* if (read(fd, buf, BUFF_SIZE) < 0) */ + /* return (-1); */ + /* } */ return (0); } +/* */ +/* static void *ft_memcat(void *ptr, void *tail, */ +/* unsigned int size, unsigned int tail_size) */ +/* { */ +/* void *copy; */ +/* */ +/* if ((copy = malloc(size)) == NULL) */ +/* return (NULL); */ +/* ft_memcpy(copy, ptr, size); */ +/* free(ptr); */ +/* if ((ptr = malloc(size + tail_size)) == NULL) */ +/* return (NULL); */ +/* ft_memcpy(ptr, copy, size); */ +/* free(copy); */ +/* ft_memcpy(ptr + size, tail, tail_size); */ +/* return (ptr); */ +/* } */ -static void *ft_memcat(void *ptr, void *tail, - unsigned int size, unsigned int tail_size) +int main() { - void *copy; - - if ((copy = malloc(size)) == NULL) - return (NULL); - ft_memcpy(copy, ptr, size); - free(ptr); - if ((ptr = malloc(size + tail_size)) == NULL) - return (NULL); - ft_memcpy(ptr, copy, size); - free(copy); - ft_memcpy(ptr + size, tail, tail_size); - return (ptr); + printf("test\n"); + return 0; } |
