-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_next_line_utils_bonus.c
78 lines (67 loc) · 1.62 KB
/
get_next_line_utils_bonus.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_utils_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: anraymon <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/07 17:05:49 by anraymon #+# #+# */
/* Updated: 2023/11/27 19:10:49 by anraymon ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line_bonus.h"
size_t ft_strlen(const char *s)
{
size_t i;
i = 0;
while (s[i])
i++;
return (i);
}
char *ft_meminit(size_t n)
{
char *buffer;
size_t i;
buffer = malloc(n * sizeof(char));
if (!buffer)
return (NULL);
i = 0;
while (i < n)
buffer[i++] = 0;
return (buffer);
}
void ft_memclear(char *s, size_t n)
{
size_t i;
i = 0;
while (i < n)
s[i++] = 0;
}
size_t ft_search_end(char *s, size_t start)
{
size_t i;
i = start;
while (s[i])
{
if (s[i] == '\n')
return (1);
i++;
}
if (i != BUFFER_SIZE)
return (1);
return (0);
}
size_t ft_get_end(char *s, size_t start)
{
size_t i;
i = start;
while (s[i])
{
if (s[i] == '\n')
return (i);
i++;
}
if (i != BUFFER_SIZE)
return (i);
return (0);
}