-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
54 lines (43 loc) · 924 Bytes
/
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
47
48
49
50
51
52
53
54
#include <stdio.h>
#include <stdlib.h>
#include "gptmalloc.h"
int main()
{
int* ptr = (int*) malloc(5 * sizeof(int));
int* gpt_ptr = (int*)malloc_with_ai("Enough memory to store up to five integers.");
// test normal ptr
printf("testing normal ptr...\n");
if (ptr == NULL)
{
printf("normal pointer allocation failed\n");
return 1;
}
for (int i = 0; i < 5; i++)
{
ptr[i] = i + 1;
}
for (int i = 0; i < 5; i++)
{
printf("%d ", ptr[i]);
}
printf("\n");
// test gpt ptr
printf("testing gpt ptr...\n");
if (gpt_ptr == NULL)
{
printf("gpt pointer allocation failed\n");
return 1;
}
for (int i = 0; i < 5; i++)
{
gpt_ptr[i] = i + 1;
}
for (int i = 0; i < 5; i++)
{
printf("%d ", gpt_ptr[i]);
}
printf("\n");
free(ptr);
free(gpt_ptr);
return 0;
}