-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
51 lines (42 loc) · 997 Bytes
/
Copy pathmain.c
File metadata and controls
51 lines (42 loc) · 997 Bytes
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
#include "stdio.h"
#include "allocator.h"
#include <stdio.h>
int main()
{
char *str = (char *)salloc(8);
if (str == NULL)
{
fprintf(stderr, "Allocation failed!\n");
return 1;
}
fgets(str, 100, stdin);
printf("Data: %s\n", str);
sfree(str);
printf("Data after free: %s\n", str);
}
// int main()
// {
// char *str = (char *)salloc(64);
// if (str == NULL)
// {
// fprintf(stderr, "Allocation failed!\n");
// return 1;
// }
// strcpy(str, "Hello Allocator!");
// printf("Data: %s\n", str);
// print_debug();
// str = srealloc(str, 16);
// printf("Data after realloc: %s\n", str);
// print_debug();
// sfree(str);
// printf("Data after free: %s\n", str);
// }
// int main()
// {
// // canary test
// char *str = (char *)salloc(16);
// char *str2 = (char *)salloc(16);
// strcpy(str, "AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHH");
// sfree(str2);
// sfree(str);
// }