-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_next_line_utils.c
42 lines (37 loc) · 1.28 KB
/
get_next_line_utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tlakchai <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/24 14:45:23 by codespace #+# #+# */
/* Updated: 2023/11/27 22:22:18 by tlakchai ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.h"
void *gnl_free(t_gnl *gnl)
{
t_list *tmp;
while (gnl->lst)
{
tmp = gnl->lst;
gnl->lst = gnl->lst->next;
free(tmp);
}
return (NULL);
}
t_list *gnl_lstnew(t_list **lst)
{
t_list *list;
if (*lst != NULL)
return (*lst);
list = malloc(sizeof(t_list));
if (list == NULL)
return (NULL);
list->next = NULL;
list->buffer[0] = '\0';
list->idx = 0;
*lst = list;
return (list);
}