-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_next_line_utils.c
45 lines (40 loc) · 1.38 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
43
44
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ple-stra <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/10 14:21:07 by ple-stra #+# #+# */
/* Updated: 2022/01/02 21:32:24 by ple-stra ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.h"
size_t ft_strllen(char const *str, char c, size_t l)
{
char *str2;
if (!str)
return (0);
str2 = (char *)str;
l++;
while (--l && *str != c)
str++;
if (l && *str == c && c != 0)
return (str - str2 + 1);
return (str - str2);
}
void *free_all(t_lstring *l_line, char **sbuf)
{
t_lstring *to_free;
free(*sbuf);
*sbuf = 0;
while (l_line)
{
to_free = l_line;
l_line = l_line->previous;
if (to_free->string)
free(to_free->string);
free(to_free);
}
return (NULL);
}