-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparsing_utils.c
65 lines (56 loc) · 1.61 KB
/
parsing_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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parsing_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lvichi <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 1970/01/01 01:00:00 by lvichi #+# #+# */
/* Updated: 2024/10/22 20:03:08 by lvichi ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void *ft_calloc2(size_t nmemb, size_t size);
int ft_strlen(char *s);
char *ft_strchr(char *s, int c);
void *ft_memset(void *str, int c, size_t n);
void *ft_calloc2(size_t nmemb, size_t size)
{
void *ret;
size = nmemb * size;
ret = malloc(size);
if (!ret)
return (NULL);
while (size)
((char *)ret)[--size] = 0;
return (ret);
}
int ft_strlen(char *s)
{
int length;
length = 0;
while (*s != '\0')
{
s++;
length++;
}
return (length);
}
char *ft_strchr(char *s, int c)
{
while (*s != '\0')
{
if (*s == c)
return (s);
s++;
}
return (NULL);
}
void *ft_memset(void *str, int c, size_t n)
{
unsigned char *ptr;
ptr = (unsigned char *)str;
while (n-- > 0)
*ptr++ = (unsigned char)c;
return (str);
}