41 ft_memcpy(s2, *s1, len);
43 new_s1_len = ft_strlen(*s1 + len);
47 new_s1 = malloc(new_s1_len + 1);
53 ft_memcpy(new_s1, *s1 + len, new_s1_len + 1);
76 if (s[(*len)++] ==
'\n')
94static size_t fill_line_buf(
int fd,
char **line_buf,
size_t *first_line_len)
105 return (*first_line_len = 0);
106 read_buf[read_len] =
'\0';
108 *line_buf = ft_strdup(read_buf);
112 *line_buf = ft_strjoin(*line_buf, read_buf);
116 return (*first_line_len = 0);
119 *first_line_len = ft_strlen(*line_buf);
120 return (*first_line_len);
133 static char *line_buf[
MAX_FD + 1] = {0};
134 size_t first_line_len;
144 return (line_buf[fd] = 0);
#define BUFFER_SIZE
Set default BUFFER_SIZE if it is not defined at compile time.
#define MAX_FD
Max open file descriptors per process.
static char * consume_and_resize(char **s1, size_t len)
Allocate and return a new string of size len + 1 containing len characters from string pointed to by ...
static size_t find_line_end(char *s, size_t *len)
Find the first newline in string s and write its index + 1 into len.
char * get_next_line(int fd)
Return the next segment of text ending in a newline or EOF from file descriptor fd.
static size_t fill_line_buf(int fd, char **line_buf, size_t *first_line_len)
Reading from fd, fill and / or allocate line buffer at line_buf, set first_line_len to the length of ...