-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_server.c
More file actions
65 lines (57 loc) · 1.61 KB
/
utils_server.c
File metadata and controls
65 lines (57 loc) · 1.61 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
53
54
55
56
57
58
59
60
61
62
63
64
65
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils_server.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lhanna <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/25 17:26:20 by lhanna #+# #+# */
/* Updated: 2022/03/25 17:26:36 by lhanna ### ########.fr */
/* */
/* ************************************************************************** */
#include "minitalk.h"
int ft_recursive_power(int nb, int power)
{
if (power < 0)
return (0);
else if (power == 0 && power == 0)
return (1);
else
return (nb * ft_recursive_power(nb, power - 1));
}
void *ft_calloc_exit(size_t count, size_t size)
{
size_t total_size;
void *ret;
total_size = size * count;
ret = malloc(total_size);
if (!ret)
exit(EXIT_FAILURE);
ft_bzero(ret, total_size);
return (ret);
}
void ft_bzero(void *str, size_t n)
{
size_t i;
unsigned char *my_str;
i = 0;
my_str = (unsigned char *)(str);
while (i < n)
{
my_str[i] = '\0';
i++;
}
}
void ft_putendl_fd(char *s, int fd)
{
int i;
i = 0;
if (s == 0)
return ;
while (s[i] != '\0')
{
ft_putchar_fd(s[i], fd);
i++;
}
ft_putchar_fd('\n', fd);
}