Works for BUFFER_SIZE=42
This commit is contained in:
parent
fd2c903d48
commit
1f79bbbb12
1 changed files with 1 additions and 4 deletions
|
|
@ -129,12 +129,10 @@ char *get_next_line(int fd)
|
|||
static char *buffer = NULL;
|
||||
char *read_buffer;
|
||||
int num_bytes_read;
|
||||
size_t length;
|
||||
char *outbuf;
|
||||
|
||||
read_buffer = malloc(BUFFER_SIZE * sizeof(char));
|
||||
num_bytes_read = 1;
|
||||
length = 0;
|
||||
if (buffer == NULL)
|
||||
{
|
||||
buffer = malloc(sizeof(char));
|
||||
|
|
@ -162,7 +160,7 @@ char *get_next_line(int fd)
|
|||
free(read_buffer);
|
||||
return (outbuf);
|
||||
}
|
||||
num_bytes_read = read(fd, read_buffer + length, BUFFER_SIZE - length - 1);
|
||||
num_bytes_read = read(fd, read_buffer, BUFFER_SIZE - 1);
|
||||
if (num_bytes_read < 0)
|
||||
{
|
||||
free(read_buffer);
|
||||
|
|
@ -171,7 +169,6 @@ char *get_next_line(int fd)
|
|||
return (NULL);
|
||||
}
|
||||
read_buffer[num_bytes_read] = '\0';
|
||||
length += num_bytes_read;
|
||||
// DONE: join with big buffer
|
||||
// FIXME: correctly free buffer
|
||||
buffer = ft_strjoin_free_s1(buffer, read_buffer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue