-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_next_line_utils.c
84 lines (73 loc) · 1.75 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
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
79
80
81
82
83
84
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jteissie <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/27 16:04:51 by jteissie #+# #+# */
/* Updated: 2024/05/30 20:55:46 by jteissie ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.h"
int ft_strlen(char *str)
{
int i;
i = 0;
while (str[i])
{
i++;
}
return (i);
}
void ft_bzero(void *s, size_t n)
{
unsigned int i;
unsigned char *str;
i = 0;
str = s;
while (i < n)
str[i++] = '\0';
}
void copy_and_cat(char *out, char *cpy_src, char *cat_src)
{
int i;
int src_i;
i = 0;
src_i = 0;
while (cpy_src[src_i])
{
out[i] = cpy_src[src_i];
i++;
src_i++;
}
src_i = 0;
while (cat_src[src_i])
out[i++] = cat_src[src_i++];
out[i] = '\0';
}
void *ft_calloc(size_t nmemb, size_t size)
{
void *ptr;
size_t total_size;
total_size = size * nmemb;
if (total_size < size && total_size != 0)
return (NULL);
ptr = malloc(total_size);
if (!ptr)
return (NULL);
ft_bzero(ptr, nmemb);
return (ptr);
}
int find_eol(char *str)
{
int i;
i = 0;
while (str[i])
{
if (str[i] == '\n')
return (1);
i++;
}
return (0);
}