remove a bunch of lines
This commit is contained in:
parent
8f37c424ad
commit
330db7596a
2 changed files with 1 additions and 9 deletions
|
|
@ -81,10 +81,8 @@ char *get_next_line(int fd)
|
|||
num_bytes_read = 1;
|
||||
while (num_bytes_read != 0)
|
||||
{
|
||||
// DONE: if newline found,
|
||||
if (ft_strchr(buffer, '\n'))
|
||||
{
|
||||
// DONE: copy string until newline to new buffer,
|
||||
outbuf = malloc((ft_strchr(buffer, '\n') - buffer + 2));
|
||||
if (outbuf == NULL)
|
||||
{
|
||||
|
|
@ -94,10 +92,7 @@ char *get_next_line(int fd)
|
|||
return (NULL);
|
||||
}
|
||||
ft_strlcpy(outbuf, buffer, ft_strchr(buffer, '\n') - buffer + 2);
|
||||
// DONE: shorten current buffer,
|
||||
// buffer += ft_strchr(buffer, '\n') - buffer + 1;
|
||||
buffer = shorten_buffer(buffer);
|
||||
// DONE: and return.
|
||||
free(read_buffer);
|
||||
return (outbuf);
|
||||
}
|
||||
|
|
@ -110,13 +105,9 @@ char *get_next_line(int fd)
|
|||
return (NULL);
|
||||
}
|
||||
read_buffer[num_bytes_read] = '\0';
|
||||
// DONE: join with big buffer
|
||||
buffer = ft_strjoin_free_s1(buffer, read_buffer);
|
||||
if (buffer == NULL)
|
||||
{
|
||||
free(read_buffer);
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
free(read_buffer);
|
||||
outbuf = buffer;
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ char *ft_strjoin_free_s1(char const *s1, char const *s2)
|
|||
if (out == NULL)
|
||||
{
|
||||
free((void *)s1);
|
||||
free((void *)s2);
|
||||
return (NULL);
|
||||
}
|
||||
ft_strlcpy(out, s1, len);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue