-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.c
46 lines (39 loc) · 1.52 KB
/
main.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: escura <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/04 14:06:43 by escura #+# #+# */
/* Updated: 2024/05/07 19:12:07 by escura ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_alloc.h"
int main(void)
{
// init list for allocations
ft_alloc_init();
// allocations with ft_malloc
char *str = ft_malloc(455 * sizeof(char));
char *str2 = ft_malloc(455 * sizeof(char));
char *str3 = ft_malloc(455 * sizeof(char));
// manual free
ft_free(str);
ft_free(str2);
ft_free(str3);
int i = 0;
while (i < 10)
{
// allocation without ft_free
char *str4 = ft_malloc(455 * sizeof(char));
(void)str4;
i++;
}
// original malloc - won't be freed with destructor
char *str5 = malloc(455 * sizeof(char));
(void)str5;
// will free everything that was allocated with ft_malloc or ft_calloc
ft_destructor();
return (0);
}