static t_list *get_cut(t_list **list, int fd, int *ret) { t_list *lst; char *buf; if (!(buf = (char *)malloc(sizeof(char) * (BUF_SIZE + 1)))) return (NULL); *ret = read(fd, buf, BUF_SIZE); buf[BUF_SIZE] = '\0'; lst = ft_lstln(buf, BUF_SIZE); ft_lstaddend(list, lst); return (lst); }
t_list *ft_lstln_front(t_list **alst, void const *content, size_t c_size) { t_list *list; if (alst) { if ((list = ft_lstln(content, c_size)) == NULL) return (NULL); ft_lstadd_front(alst, list); return (list); } return (NULL); }
static int read_to_lst(t_fd *fdatas) { t_list *new_lst; char *buffer; buffer = (char *)malloc(BUFF_SIZE + 1); if (buffer == NULL) return (-1); new_lst = ft_lstln(buffer, BUFF_SIZE); if (new_lst == NULL) return (-1); ft_lstaddend(&(fdatas->lst), new_lst); return (read(fdatas->fd, (char *)(new_lst->content), BUFF_SIZE)); }