-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_utils2.c
More file actions
52 lines (44 loc) · 1.4 KB
/
ft_utils2.c
File metadata and controls
52 lines (44 loc) · 1.4 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: slepetit <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/03 21:09:10 by slepetit #+# #+# */
/* Updated: 2022/10/19 17:36:40 by slepetit ### ########.fr */
/* */
/* ************************************************************************** */
#include "minitalk.h"
int ft_putchar(char c)
{
return (write(1, &c, 1));
}
size_t ft_strlen(const char *s)
{
int i;
i = 0;
while (s[i])
i++;
return (i);
}
int ft_putstr(char *s)
{
return (write(1, s, ft_strlen(s)));
}
void *ft_calloc(size_t nmemb, size_t size)
{
void *p;
if (nmemb >= 65535 && size >= 65535)
return (NULL);
p = (void *)malloc(nmemb * size);
if (p == NULL)
return (NULL);
ft_bzero(p, (nmemb * size));
return (p);
}
void ft_protect(char **str)
{
if (*str == NULL)
*str = ft_calloc(sizeof(char), 2);
}